allow loading layout presets from app.config (#2310)

This commit is contained in:
Denys Vuika
2017-09-08 15:25:35 +01:00
committed by Popovics András
parent a8dfbeb572
commit 0e219687ec
3 changed files with 467 additions and 5 deletions

View File

@@ -25,5 +25,230 @@
} }
] ]
} }
},
"document-list": {
"presets": {
"-trashcan-": [
{
"key": "$thumbnail",
"type": "image",
"srTitle": "ADF-DOCUMENT-LIST.LAYOUT.THUMBNAIL",
"sortable": false
},
{
"key": "name",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.NAME",
"cssClass": "full-width ellipsis-cell",
"sortable": true
},
{
"key": "path",
"type": "location",
"title": "ADF-DOCUMENT-LIST.LAYOUT.LOCATION",
"format": "/files",
"sortable": true
},
{
"key": "content.sizeInBytes",
"type": "fileSize",
"title": "ADF-DOCUMENT-LIST.LAYOUT.SIZE",
"sortable": true
},
{
"key": "archivedAt",
"type": "date",
"title": "ADF-DOCUMENT-LIST.LAYOUT.DELETED_ON",
"format": "timeAgo",
"sortable": true
},
{
"key": "archivedByUser.displayName",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.DELETED_BY",
"sortable": true
}
],
"-sites-": [
{
"key": "$thumbnail",
"type": "image",
"srTitle": "ADF-DOCUMENT-LIST.LAYOUT.THUMBNAIL",
"sortable": false
},
{
"key": "title",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.NAME",
"cssClass": "full-width ellipsis-cell",
"sortable": true
},
{
"key": "visibility",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.STATUS",
"sortable": true
}
],
"-favorites-": [
{
"key": "$thumbnail",
"type": "image",
"srTitle": "ADF-DOCUMENT-LIST.LAYOUT.THUMBNAIL",
"sortable": false
},
{
"key": "name",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.NAME",
"cssClass": "full-width ellipsis-cell",
"sortable": true
},
{
"key": "path",
"type": "location",
"title": "ADF-DOCUMENT-LIST.LAYOUT.LOCATION",
"format": "/files",
"sortable": true
},
{
"key": "content.sizeInBytes",
"type": "fileSize",
"title": "ADF-DOCUMENT-LIST.LAYOUT.SIZE",
"sortable": true
},
{
"key": "modifiedAt",
"type": "date",
"title": "ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_ON",
"format": "timeAgo",
"sortable": true
},
{
"key": "modifiedByUser.displayName",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_BY",
"sortable": true
}
],
"-recent-": [
{
"key": "$thumbnail",
"type": "image",
"srTitle": "ADF-DOCUMENT-LIST.LAYOUT.THUMBNAIL",
"sortable": false
},
{
"key": "name",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.NAME",
"cssClass": "full-width ellipsis-cell",
"sortable": true
},
{
"key": "path",
"type": "location",
"title": "ADF-DOCUMENT-LIST.LAYOUT.LOCATION",
"cssClass": "ellipsis-cell",
"format": "/files",
"sortable": true
},
{
"key": "content.sizeInBytes",
"type": "fileSize",
"title": "ADF-DOCUMENT-LIST.LAYOUT.SIZE",
"sortable": true
},
{
"key": "modifiedAt",
"type": "date",
"title": "ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_ON",
"format": "timeAgo",
"sortable": true
}
],
"-sharedlinks-": [
{
"key": "$thumbnail",
"type": "image",
"srTitle": "ADF-DOCUMENT-LIST.LAYOUT.THUMBNAIL",
"sortable": false
},
{
"key": "name",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.NAME",
"cssClass": "full-width ellipsis-cell",
"sortable": true
},
{
"key": "path",
"type": "location",
"title": "ADF-DOCUMENT-LIST.LAYOUT.LOCATION",
"cssClass": "ellipsis-cell",
"format": "/files",
"sortable": true
},
{
"key": "content.sizeInBytes",
"type": "fileSize",
"title": "ADF-DOCUMENT-LIST.LAYOUT.SIZE",
"sortable": true
},
{
"key": "modifiedAt",
"type": "date",
"title": "ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_ON",
"format": "timeAgo",
"sortable": true
},
{
"key": "modifiedByUser.displayName",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_BY",
"sortable": true
},
{
"key": "sharedByUser.displayName",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.SHARED_BY",
"sortable": true
}
],
"default": [
{
"key": "$thumbnail",
"type": "image",
"srTitle": "ADF-DOCUMENT-LIST.LAYOUT.THUMBNAIL",
"sortable": false
},
{
"key": "name",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.NAME",
"cssClass": "full-width ellipsis-cell",
"sortable": true
},
{
"key": "content.sizeInBytes",
"type": "fileSize",
"title": "ADF-DOCUMENT-LIST.LAYOUT.SIZE",
"sortable": true
},
{
"key": "modifiedAt",
"type": "date",
"title": "ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_ON",
"format": "timeAgo",
"sortable": true
},
{
"key": "modifiedByUser.displayName",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_BY",
"sortable": true
}
]
}
} }
} }

View File

@@ -25,5 +25,230 @@
} }
] ]
} }
},
"document-list": {
"presets": {
"-trashcan-": [
{
"key": "$thumbnail",
"type": "image",
"srTitle": "ADF-DOCUMENT-LIST.LAYOUT.THUMBNAIL",
"sortable": false
},
{
"key": "name",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.NAME",
"cssClass": "full-width ellipsis-cell",
"sortable": true
},
{
"key": "path",
"type": "location",
"title": "ADF-DOCUMENT-LIST.LAYOUT.LOCATION",
"format": "/files",
"sortable": true
},
{
"key": "content.sizeInBytes",
"type": "fileSize",
"title": "ADF-DOCUMENT-LIST.LAYOUT.SIZE",
"sortable": true
},
{
"key": "archivedAt",
"type": "date",
"title": "ADF-DOCUMENT-LIST.LAYOUT.DELETED_ON",
"format": "timeAgo",
"sortable": true
},
{
"key": "archivedByUser.displayName",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.DELETED_BY",
"sortable": true
}
],
"-sites-": [
{
"key": "$thumbnail",
"type": "image",
"srTitle": "ADF-DOCUMENT-LIST.LAYOUT.THUMBNAIL",
"sortable": false
},
{
"key": "title",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.NAME",
"cssClass": "full-width ellipsis-cell",
"sortable": true
},
{
"key": "visibility",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.STATUS",
"sortable": true
}
],
"-favorites-": [
{
"key": "$thumbnail",
"type": "image",
"srTitle": "ADF-DOCUMENT-LIST.LAYOUT.THUMBNAIL",
"sortable": false
},
{
"key": "name",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.NAME",
"cssClass": "full-width ellipsis-cell",
"sortable": true
},
{
"key": "path",
"type": "location",
"title": "ADF-DOCUMENT-LIST.LAYOUT.LOCATION",
"format": "/files",
"sortable": true
},
{
"key": "content.sizeInBytes",
"type": "fileSize",
"title": "ADF-DOCUMENT-LIST.LAYOUT.SIZE",
"sortable": true
},
{
"key": "modifiedAt",
"type": "date",
"title": "ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_ON",
"format": "timeAgo",
"sortable": true
},
{
"key": "modifiedByUser.displayName",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_BY",
"sortable": true
}
],
"-recent-": [
{
"key": "$thumbnail",
"type": "image",
"srTitle": "ADF-DOCUMENT-LIST.LAYOUT.THUMBNAIL",
"sortable": false
},
{
"key": "name",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.NAME",
"cssClass": "full-width ellipsis-cell",
"sortable": true
},
{
"key": "path",
"type": "location",
"title": "ADF-DOCUMENT-LIST.LAYOUT.LOCATION",
"cssClass": "ellipsis-cell",
"format": "/files",
"sortable": true
},
{
"key": "content.sizeInBytes",
"type": "fileSize",
"title": "ADF-DOCUMENT-LIST.LAYOUT.SIZE",
"sortable": true
},
{
"key": "modifiedAt",
"type": "date",
"title": "ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_ON",
"format": "timeAgo",
"sortable": true
}
],
"-sharedlinks-": [
{
"key": "$thumbnail",
"type": "image",
"srTitle": "ADF-DOCUMENT-LIST.LAYOUT.THUMBNAIL",
"sortable": false
},
{
"key": "name",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.NAME",
"cssClass": "full-width ellipsis-cell",
"sortable": true
},
{
"key": "path",
"type": "location",
"title": "ADF-DOCUMENT-LIST.LAYOUT.LOCATION",
"cssClass": "ellipsis-cell",
"format": "/files",
"sortable": true
},
{
"key": "content.sizeInBytes",
"type": "fileSize",
"title": "ADF-DOCUMENT-LIST.LAYOUT.SIZE",
"sortable": true
},
{
"key": "modifiedAt",
"type": "date",
"title": "ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_ON",
"format": "timeAgo",
"sortable": true
},
{
"key": "modifiedByUser.displayName",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_BY",
"sortable": true
},
{
"key": "sharedByUser.displayName",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.SHARED_BY",
"sortable": true
}
],
"default": [
{
"key": "$thumbnail",
"type": "image",
"srTitle": "ADF-DOCUMENT-LIST.LAYOUT.THUMBNAIL",
"sortable": false
},
{
"key": "name",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.NAME",
"cssClass": "full-width ellipsis-cell",
"sortable": true
},
{
"key": "content.sizeInBytes",
"type": "fileSize",
"title": "ADF-DOCUMENT-LIST.LAYOUT.SIZE",
"sortable": true
},
{
"key": "modifiedAt",
"type": "date",
"title": "ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_ON",
"format": "timeAgo",
"sortable": true
},
{
"key": "modifiedByUser.displayName",
"type": "text",
"title": "ADF-DOCUMENT-LIST.LAYOUT.MODIFIED_BY",
"sortable": true
}
]
}
} }
} }

View File

@@ -20,7 +20,7 @@ import {
OnChanges, OnInit, Output, SimpleChanges, TemplateRef, ViewChild, ViewEncapsulation OnChanges, OnInit, Output, SimpleChanges, TemplateRef, ViewChild, ViewEncapsulation
} from '@angular/core'; } from '@angular/core';
import { MinimalNodeEntity, MinimalNodeEntryEntity, NodePaging, Pagination, PersonEntry } from 'alfresco-js-api'; import { MinimalNodeEntity, MinimalNodeEntryEntity, NodePaging, Pagination, PersonEntry } from 'alfresco-js-api';
import { AlfrescoApiService, DataColumnListComponent } from 'ng2-alfresco-core'; import { AlfrescoApiService, AppConfigService, DataColumnListComponent } from 'ng2-alfresco-core';
import { DataCellEvent, DataColumn, DataRowActionEvent, DataSorting, DataTableComponent, ObjectDataColumn } from 'ng2-alfresco-datatable'; import { DataCellEvent, DataColumn, DataRowActionEvent, DataSorting, DataTableComponent, ObjectDataColumn } from 'ng2-alfresco-datatable';
import { Observable, Subject } from 'rxjs/Rx'; import { Observable, Subject } from 'rxjs/Rx';
import { ImageResolver, RowFilter, ShareDataRow, ShareDataTableAdapter } from './../data/share-datatable-adapter'; import { ImageResolver, RowFilter, ShareDataRow, ShareDataTableAdapter } from './../data/share-datatable-adapter';
@@ -146,13 +146,15 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
contextActionHandler: Subject<any> = new Subject(); contextActionHandler: Subject<any> = new Subject();
data: ShareDataTableAdapter; data: ShareDataTableAdapter;
private layoutPresets = {};
private currentNodeAllowableOperations: string[] = []; private currentNodeAllowableOperations: string[] = [];
private CREATE_PERMISSION = 'create'; private CREATE_PERMISSION = 'create';
constructor(private documentListService: DocumentListService, constructor(private documentListService: DocumentListService,
private ngZone: NgZone, private ngZone: NgZone,
private elementRef: ElementRef, private elementRef: ElementRef,
private apiService: AlfrescoApiService) { private apiService: AlfrescoApiService,
private appConfig: AppConfigService) {
} }
private get nodesApi() { private get nodesApi() {
@@ -206,6 +208,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
} }
ngOnInit() { ngOnInit() {
this.loadLayoutPresets();
this.data = new ShareDataTableAdapter(this.documentListService, null, this.getDefaultSorting()); this.data = new ShareDataTableAdapter(this.documentListService, null, this.getDefaultSorting());
this.data.thumbnails = this.thumbnails; this.data.thumbnails = this.thumbnails;
this.data.permissionsStyle = this.permissionsStyle; this.data.permissionsStyle = this.permissionsStyle;
@@ -758,8 +761,8 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
return this.hasCurrentNodePermission(this.CREATE_PERMISSION); return this.hasCurrentNodePermission(this.CREATE_PERMISSION);
} }
private getLayoutPreset(name: string = 'default'): DataColumn[] { private loadLayoutPresets(): void {
const presets = { let presets = {
'-trashcan-': [ '-trashcan-': [
{ {
key: '$thumbnail', key: '$thumbnail',
@@ -983,6 +986,15 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
] ]
}; };
return (presets[name] || presets['default']).map(col => new ObjectDataColumn(col)); const externalSettings = this.appConfig.get('document-list.presets', null);
if (externalSettings) {
presets = Object.assign({}, presets, externalSettings);
}
this.layoutPresets = presets;
}
private getLayoutPreset(name: string = 'default'): DataColumn[] {
return (this.layoutPresets[name] || this.layoutPresets['default']).map(col => new ObjectDataColumn(col));
} }
} }