Dynamic Table Columns Cleanup for view-cache

This commit is contained in:
Timo Bejan 2021-08-23 13:20:44 +03:00
parent 79da25c747
commit 3b1c194fba
3 changed files with 11 additions and 8 deletions

View File

@ -2,7 +2,7 @@
@import '../../../../../assets/styles/red-mixins'; @import '../../../../../assets/styles/red-mixins';
:root { :root {
--dynamic-columns: ''; --dynamic-columns: '0';
} }
.file-upload-input { .file-upload-input {

View File

@ -62,7 +62,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<FileStatusW
hide: !this.currentUser.isManager hide: !this.currentUser.isManager
} }
]; ];
tableColumnConfigs: readonly TableColumnConfig<FileStatusWrapper>[] = [ private readonly _defaultTableConfigs: readonly TableColumnConfig<FileStatusWrapper>[] = [
{ {
label: _('dossier-overview.table-col-names.name'), label: _('dossier-overview.table-col-names.name'),
sortByKey: 'filename' sortByKey: 'filename'
@ -89,6 +89,8 @@ export class DossierOverviewScreenComponent extends ListingComponent<FileStatusW
sortByKey: 'statusSort' sortByKey: 'statusSort'
} }
]; ];
tableColumnConfigs: readonly TableColumnConfig<FileStatusWrapper>[] = [];
collapsedDetails = false; collapsedDetails = false;
dossierAttributes: DossierAttributeWithValue[] = []; dossierAttributes: DossierAttributeWithValue[] = [];
fileAttributeConfigs: FileAttributeConfig[]; fileAttributeConfigs: FileAttributeConfig[];
@ -159,7 +161,7 @@ export class DossierOverviewScreenComponent extends ListingComponent<FileStatusW
this.dossierAttributes = await this._dossierAttributesService.getValues(this.currentDossier); this.dossierAttributes = await this._dossierAttributesService.getValues(this.currentDossier);
this.searchService.setSearchKey('filename'); this.searchService.setSearchKey('filename');
this._addDynamicColumns(); this._configureTableColumns();
} catch (e) { } catch (e) {
} finally { } finally {
this._loadingService.stop(); this._loadingService.stop();
@ -261,14 +263,14 @@ export class DossierOverviewScreenComponent extends ListingComponent<FileStatusW
recentlyModifiedChecker = (file: FileStatusWrapper) => recentlyModifiedChecker = (file: FileStatusWrapper) =>
moment(file.lastUpdated).add(this._appConfigService.getConfig(AppConfigKey.RECENT_PERIOD_IN_HOURS), 'hours').isAfter(moment()); moment(file.lastUpdated).add(this._appConfigService.getConfig(AppConfigKey.RECENT_PERIOD_IN_HOURS), 'hours').isAfter(moment());
private _addDynamicColumns() { private _configureTableColumns() {
const dynamicColumns: TableColumnConfig<FileStatusWrapper>[] = []; const dynamicColumns: TableColumnConfig<FileStatusWrapper>[] = [];
for (const config of this.displayedInFileListAttributes) { for (const config of this.displayedInFileListAttributes) {
if (config.displayedInFileList) { if (config.displayedInFileList) {
dynamicColumns.push({ label: config.label, notTranslatable: true }); dynamicColumns.push({ label: config.label, notTranslatable: true });
} }
} }
this.tableColumnConfigs = [this.tableColumnConfigs[0], ...dynamicColumns, ...this.tableColumnConfigs.slice(1)]; this.tableColumnConfigs = [this._defaultTableConfigs[0], ...dynamicColumns, ...this._defaultTableConfigs.slice(1)];
this.dynamicColumnsCount = dynamicColumns.length; this.dynamicColumnsCount = dynamicColumns.length;
(this._elementRef.nativeElement as HTMLElement).style.setProperty('--dynamic-columns', `${this.dynamicColumnsCount}`); (this._elementRef.nativeElement as HTMLElement).style.setProperty('--dynamic-columns', `${this.dynamicColumnsCount}`);
} }
@ -318,8 +320,8 @@ export class DossierOverviewScreenComponent extends ListingComponent<FileStatusW
} }
let filterValue = file.fileAttributes?.attributeIdToValue[config.id]; let filterValue = file.fileAttributes?.attributeIdToValue[config.id];
if (!filterValue) { if (!filterValue) {
filterValue = 'Empty'; filterValue = this._translateService.instant('filters.empty');
file.fileAttributes.attributeIdToValue[config.id] = filterValue; file.fileAttributes.attributeIdToValue[config.id] = '-';
} }
filters.add(filterValue); filters.add(filterValue);
} }

View File

@ -1044,7 +1044,8 @@
"filter-by": "Filter:", "filter-by": "Filter:",
"needs-work": "Workload", "needs-work": "Workload",
"people": "Dossier Member(s)", "people": "Dossier Member(s)",
"status": "Status" "status": "Status",
"empty": "Empty"
}, },
"general-config-screen": { "general-config-screen": {
"actions": { "actions": {