add presets document list in an external model (#2420)

This commit is contained in:
Eugenio Romano 2017-10-04 12:21:57 +01:00 committed by Denys Vuika
parent 07c0c1c593
commit ea29213178
2 changed files with 245 additions and 226 deletions

View File

@ -23,6 +23,7 @@ import { MinimalNodeEntity, MinimalNodeEntryEntity, NodePaging, Pagination, Pers
import { AlfrescoApiService, AppConfigService, DataColumnListComponent } from 'ng2-alfresco-core';
import { DataCellEvent, DataColumn, DataRowActionEvent, DataSorting, DataTableComponent, ObjectDataColumn } from 'ng2-alfresco-datatable';
import { Observable, Subject } from 'rxjs/Rx';
import { presetsDefaultModel } from '../models/preset.model';
import { ImageResolver, RowFilter, ShareDataRow, ShareDataTableAdapter } from './../data/share-datatable-adapter';
import { ContentActionModel } from './../models/content-action.model';
import { PermissionStyleModel } from './../models/permissions-style.model';
@ -802,236 +803,14 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
}
private loadLayoutPresets(): void {
let 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: this.locationFormat,
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: this.locationFormat,
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: this.locationFormat,
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: this.locationFormat,
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
}
]
};
const externalSettings = this.appConfig.get('document-list.presets', null);
if (externalSettings) {
presets = Object.assign({}, presets, externalSettings);
this.layoutPresets = Object.assign({}, presetsDefaultModel, externalSettings);
} else {
this.layoutPresets = presetsDefaultModel;
}
this.layoutPresets = presets;
}
private getLayoutPreset(name: string = 'default'): DataColumn[] {

View File

@ -0,0 +1,240 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export let presetsDefaultModel = {
'-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: this.locationFormat,
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: this.locationFormat,
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: this.locationFormat,
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: this.locationFormat,
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
}
]
};