RED-2844: Update file attributes in dossier overview

This commit is contained in:
Adina Țeudan 2021-12-14 12:01:32 +02:00
parent 9a86f096b0
commit f5f6f11c19
19 changed files with 48 additions and 31 deletions

View File

@ -1,4 +1,5 @@
import { Component, ViewContainerRef } from '@angular/core';
import { RouterHistoryService } from '@services/router-history.service';
@Component({
selector: 'redaction-root',
@ -6,6 +7,7 @@ import { Component, ViewContainerRef } from '@angular/core';
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
// View container ref needs to be injected for the color picker to work
constructor(public viewContainerRef: ViewContainerRef) {}
// ViewContainerRef needs to be injected for the color picker to work
// RouterHistoryService needs to be injected for last dossiers screen to be updated on first app load
constructor(public viewContainerRef: ViewContainerRef, private readonly _routerHistoryService: RouterHistoryService) {}
}

View File

@ -8,6 +8,7 @@
[itemSize]="80"
[noDataText]="'downloads-list.no-data.title' | translate"
[selectionEnabled]="true"
[tableColumnConfigs]="tableColumnConfigs"
noDataIcon="iqser:download"
></iqser-table>
</div>

View File

@ -5,6 +5,7 @@
[itemSize]="50"
[noDataText]="'file-attributes-csv-import.no-data.title' | translate"
[selectionEnabled]="true"
[tableColumnConfigs]="tableColumnConfigs"
emptyColumnWidth="auto"
noDataIcon="red:attribute"
></iqser-table>

View File

@ -25,6 +25,7 @@
[itemSize]="80"
[noDataIcon]="'iqser:document'"
[noDataText]="'audit-screen.no-data.title' | translate"
[tableColumnConfigs]="tableColumnConfigs"
[totalSize]="logs?.totalHits || 0"
>
</iqser-table>

View File

@ -20,7 +20,7 @@
<redaction-admin-side-nav type="dossierTemplates"></redaction-admin-side-nav>
<div class="content-container">
<iqser-table [itemSize]="80" emptyColumnWidth="2fr"></iqser-table>
<iqser-table [itemSize]="80" [tableColumnConfigs]="tableColumnConfigs" emptyColumnWidth="2fr"></iqser-table>
</div>
</div>
</section>

View File

@ -30,6 +30,7 @@
[noMatchText]="'dictionary-listing.no-match.title' | translate"
[selectionEnabled]="true"
[showNoDataButton]="currentUser.isAdmin"
[tableColumnConfigs]="tableColumnConfigs"
emptyColumnWidth="1fr"
noDataIcon="red:dictionary"
></iqser-table>

View File

@ -30,6 +30,7 @@
[noMatchText]="'dossier-attributes-listing.no-match.title' | translate"
[selectionEnabled]="true"
[showNoDataButton]="currentUser.isAdmin"
[tableColumnConfigs]="tableColumnConfigs"
emptyColumnWidth="1fr"
noDataIcon="red:attribute"
></iqser-table>

View File

@ -19,6 +19,7 @@
[noDataText]="'dossier-templates-listing.no-data.title' | translate"
[noMatchText]="'dossier-templates-listing.no-match.title' | translate"
[selectionEnabled]="true"
[tableColumnConfigs]="tableColumnConfigs"
noDataIcon="red:template"
></iqser-table>
</div>

View File

@ -27,6 +27,7 @@
[noDataText]="'file-attributes-listing.no-data.title' | translate"
[noMatchText]="'file-attributes-listing.no-match.title' | translate"
[selectionEnabled]="true"
[tableColumnConfigs]="tableColumnConfigs"
emptyColumnWidth="1fr"
noDataIcon="red:attribute"
></iqser-table>

View File

@ -4,6 +4,7 @@
[itemSize]="80"
[noDataText]="'justifications-listing.no-data.title' | translate"
[selectionEnabled]="true"
[tableColumnConfigs]="tableColumnConfigs"
noDataIcon="iqser:document"
></iqser-table>

View File

@ -15,6 +15,7 @@
[noDataText]="'trash.no-data.title' | translate"
[noMatchText]="'trash.no-match.title' | translate"
[selectionEnabled]="true"
[tableColumnConfigs]="tableColumnConfigs"
[tableItemClasses]="{ disabled: disabledFn }"
noDataIcon="red:template"
></iqser-table>

View File

@ -37,6 +37,7 @@
[itemSize]="80"
[noMatchText]="'user-listing.no-match.title' | translate"
[selectionEnabled]="true"
[tableColumnConfigs]="tableColumnConfigs"
emptyColumnWidth="1fr"
></iqser-table>
</div>

View File

@ -4,6 +4,7 @@
[itemSize]="50"
[noDataText]="'edit-dossier-dialog.deleted-documents.no-data.title' | translate"
[selectionEnabled]="true"
[tableColumnConfigs]="tableColumnConfigs"
[tableItemClasses]="{ disabled: disabledFn }"
noDataIcon="iqser:document"
></iqser-table>

View File

@ -23,6 +23,7 @@
[noMatchText]="'dossier-overview.no-match.title' | translate"
[selectionEnabled]="true"
[showNoDataButton]="true"
[tableColumnConfigs]="tableColumnConfigs"
[tableItemClasses]="{ disabled: disabledFn, 'last-opened': lastOpenedFn }"
helpModeKey="document-list"
></iqser-table>

View File

@ -17,7 +17,7 @@ import { FileUploadService } from '@upload-download/services/file-upload.service
import { StatusOverlayService } from '@upload-download/services/status-overlay.service';
import * as moment from 'moment';
import { Observable, timer } from 'rxjs';
import { filter, switchMap, tap } from 'rxjs/operators';
import { filter, skip, switchMap, tap } from 'rxjs/operators';
import { convertFiles, Files, handleFileDrop } from '@utils/index';
import {
CircleButtonTypes,
@ -73,6 +73,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
private readonly _needsWorkFilterTemplate: TemplateRef<unknown>;
@ViewChild('fileInput', { static: true }) private readonly _fileInput: ElementRef;
@ViewChild(TableComponent) private readonly _tableComponent: TableComponent<Dossier>;
private _fileAttributeConfigs: IFileAttributeConfig[];
constructor(
protected readonly _injector: Injector,
@ -99,19 +100,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
.getEntityChanged$(this.dossierId)
.pipe(tap(dossier => (this.dossierTemplateId = dossier.dossierTemplateId)));
this.currentDossier = this._dossiersService.find(this.dossierId);
this.fileAttributeConfigs = this._fileAttributesService.getFileAttributeConfig(
this.currentDossier.dossierTemplateId,
)?.fileAttributeConfigs;
this.tableColumnConfigs = this.configService.tableConfig(this.displayedAttributes);
}
private _fileAttributeConfigs: IFileAttributeConfig[];
set fileAttributeConfigs(value: IFileAttributeConfig[]) {
this._fileAttributeConfigs = value || [];
this.displayedInFileListAttributes = this._fileAttributeConfigs.filter(config => config.displayedInFileList);
this.displayedAttributes = this.displayedInFileListAttributes.filter(c => c.displayedInFileList);
this._updateFileAttributes();
}
get checkedRequiredFilters(): NestedFilter[] {
@ -123,6 +112,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
}
disabledFn = (file: File) => file.excluded;
lastOpenedFn = (file: File) => this._userPreferenceService.getLastOpenedFileForDossier(file.dossierId) === file.id;
async ngOnInit(): Promise<void> {
@ -150,11 +140,15 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
this._computeAllFilters();
});
this.addSubscription = this._dossierTemplatesService.entityChanged$.subscribe(() => {
this.fileAttributeConfigs = this._fileAttributesService.getFileAttributeConfig(
this.currentDossier.dossierTemplateId,
)?.fileAttributeConfigs;
});
this.addSubscription = this._dossierTemplatesService
.getEntityChanged$(this.currentDossier.dossierTemplateId)
.pipe(
skip(1),
tap(() => {
this._updateFileAttributes();
}),
)
.subscribe();
try {
this.dossierAttributes = await this._dossierAttributesService.getWithValues(this.currentDossier);
@ -170,14 +164,12 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
super.ngOnDestroy();
}
async ngOnAttach() {
await this.ngOnInit();
ngOnAttach() {
this._fileDropOverlayService.initFileDropHandling(this.dossierId);
this._tableComponent?.scrollToLastIndex();
}
ngOnDetach() {
this.ngOnDestroy();
}
ngOnDetach() {}
forceReanalysisAction($event: LongPressEvent) {
this.analysisForced = !$event.touchEnd && this._userPreferenceService.areDevFeaturesEnabled;
@ -203,6 +195,15 @@ export class DossierOverviewScreenComponent extends ListingComponent<File> imple
recentlyModifiedChecker = (file: File) =>
moment(file.lastUpdated).add(this._appConfigService.values.RECENT_PERIOD_IN_HOURS, 'hours').isAfter(moment());
private _updateFileAttributes(): void {
this._fileAttributeConfigs =
this._fileAttributesService.getFileAttributeConfig(this.currentDossier.dossierTemplateId)?.fileAttributeConfigs || [];
this.displayedInFileListAttributes = this._fileAttributeConfigs.filter(config => config.displayedInFileList);
this.displayedAttributes = this.displayedInFileListAttributes.filter(c => c.displayedInFileList);
this.tableColumnConfigs = this.configService.tableConfig(this.displayedAttributes);
this._computeAllFilters();
}
private async _reloadFiles() {
await this._filesService.loadAll(this.dossierId).toPromise();
this._computeAllFilters();

View File

@ -13,6 +13,7 @@
[noDataText]="'dossier-listing.no-data.title' | translate"
[noMatchText]="'dossier-listing.no-match.title' | translate"
[showNoDataButton]="currentUser.isManager"
[tableColumnConfigs]="tableColumnConfigs"
helpModeKey="dossier-list"
noDataIcon="red:folder"
></iqser-table>

View File

@ -27,9 +27,9 @@ export class DocumentInfoService {
fileAttributes$(fileId: string, dossierId: string, dossierTemplateId: string) {
const getAttributes = () => this._fileAttributesService.getFileAttributeConfig(dossierTemplateId).fileAttributeConfigs;
const dossierTemplateChange$ = this._dossierTemplatesService.entityChanged$.pipe(
filter(template => template.dossierTemplateId === dossierTemplateId),
);
const dossierTemplateChange$ = this._dossierTemplatesService
.getEntityChanged$(dossierTemplateId)
.pipe(filter(template => template.dossierTemplateId === dossierTemplateId));
const fileChange$ = this._filesMapService.watch$(dossierId, fileId);
return merge(dossierTemplateChange$, fileChange$).pipe(
map(getAttributes),

View File

@ -16,6 +16,7 @@
[itemSize]="85"
[noDataText]="'search-screen.no-data' | translate"
[noMatchText]="'search-screen.no-match' | translate"
[tableColumnConfigs]="tableColumnConfigs"
noDataIcon="iqser:search"
></iqser-table>
</div>

@ -1 +1 @@
Subproject commit c3244477c0479dd174fa7d17c2a7e3621f26bd6d
Subproject commit e0de29cb68bc171b2737f613eafb162a43ca32ca