[ACA-1552] extensibility support for document lists (#714)

* dynamic column component

* dynamic columns for files

* support conditional rendering

* libraries preset

* shared files preset

* recent files preset

* favorites preset

* trashcan preset

* load presets from the extension config

* code fixes
This commit is contained in:
Denys Vuika 2018-10-14 08:21:58 +01:00 committed by Cilibiu Bogdan
parent 933f426759
commit 9dcdacce40
19 changed files with 785 additions and 239 deletions

View File

@ -308,7 +308,7 @@
}
},
"content-metadata-aspect": {
"description": "Content metadata's aspect definition",
"description": "Content metadata aspect definition",
"type": "object",
"required": ["id"],
"properties": {
@ -472,6 +472,49 @@
}
}
]
},
"documentListPresetRef": {
"type": "object",
"required": ["id", "key", "type"],
"properties": {
"id": {
"description": "Unique identifier.",
"type": "string"
},
"key": {
"description": "Property key",
"type": "string"
},
"type": {
"description": "Column type",
"type": "string",
"enum": ["text", "image", "date", "fileSize"]
},
"title": {
"description": "Column title",
"type": "string"
},
"format": {
"description": "Column format",
"type": "string"
},
"class": {
"description": "CSS class name",
"type": "string"
},
"sortable": {
"description": "Toggles sortable state of the column",
"type": "boolean"
},
"template": {
"description": "Column template id",
"type": "string"
},
"desktopOnly": {
"description": "Display column only for large screens",
"type": "boolean"
}
}
}
},
@ -612,6 +655,48 @@
}
}
}
},
"documentList": {
"description": "Document list extensions",
"type": "object",
"properties": {
"files": {
"description": "Files document list preset",
"type": "array",
"items": { "$ref": "#/definitions/documentListPresetRef" },
"minItems": 1
},
"libraries": {
"description": "Libraries document list preset",
"type": "array",
"items": { "$ref": "#/definitions/documentListPresetRef" },
"minItems": 1
},
"shared": {
"description": "Shared Files document list preset",
"type": "array",
"items": { "$ref": "#/definitions/documentListPresetRef" },
"minItems": 1
},
"recent": {
"description": "Recent Files document list preset",
"type": "array",
"items": { "$ref": "#/definitions/documentListPresetRef" },
"minItems": 1
},
"favorites": {
"description": "Favorites document list preset",
"type": "array",
"items": { "$ref": "#/definitions/documentListPresetRef" },
"minItems": 1
},
"trashcan": {
"description": "Trashcan document list preset",
"type": "array",
"items": { "$ref": "#/definitions/documentListPresetRef" },
"minItems": 1
}
}
}
}
}

View File

@ -32,6 +32,7 @@ import { NameColumnComponent } from './name-column/name-column.component';
import { LibraryNameColumnComponent } from './library-name-column/library-name-column.component';
import { LibraryStatusColumnComponent } from './library-status-column/library-status-column.component';
import { TrashcanNameColumnComponent } from './trashcan-name-column/trashcan-name-column.component';
import { DynamicColumnComponent } from './dynamic-column/dynamic-column.component';
@NgModule({
imports: [CommonModule, CoreModule.forChild()],
@ -41,10 +42,19 @@ import { TrashcanNameColumnComponent } from './trashcan-name-column/trashcan-nam
NameColumnComponent,
LibraryNameColumnComponent,
LibraryStatusColumnComponent,
TrashcanNameColumnComponent
TrashcanNameColumnComponent,
DynamicColumnComponent
],
exports: [
GenericErrorComponent,
LocationLinkComponent,
NameColumnComponent,
LibraryNameColumnComponent,
LibraryStatusColumnComponent,
TrashcanNameColumnComponent,
DynamicColumnComponent
],
entryComponents: [
LocationLinkComponent,
NameColumnComponent,
LibraryNameColumnComponent,

View File

@ -0,0 +1,106 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import {
Component,
Input,
OnInit,
OnDestroy,
ViewChild,
ViewContainerRef,
ComponentRef,
ComponentFactoryResolver,
OnChanges,
SimpleChanges,
ViewEncapsulation,
ChangeDetectionStrategy
} from '@angular/core';
import { ExtensionService } from '@alfresco/adf-extensions';
@Component({
selector: 'app-dynamic-column',
template: `<ng-container #content></ng-container>`,
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: 'app-dynamic-column' },
styles: [
`
.app-dynamic-column {
display: flex;
align-items: center;
}
`
]
})
export class DynamicColumnComponent implements OnInit, OnChanges, OnDestroy {
@ViewChild('content', { read: ViewContainerRef })
content: ViewContainerRef;
@Input()
id: string;
@Input()
context: any;
private componentRef: ComponentRef<any>;
constructor(
private extensions: ExtensionService,
private componentFactoryResolver: ComponentFactoryResolver
) {}
ngOnInit() {
const componentType = this.extensions.getComponentById(this.id);
if (componentType) {
const factory = this.componentFactoryResolver.resolveComponentFactory(
componentType
);
if (factory) {
this.content.clear();
this.componentRef = this.content.createComponent(factory, 0);
this.updateInstance();
}
}
}
ngOnChanges(changes: SimpleChanges) {
if (changes.node) {
this.updateInstance();
}
}
ngOnDestroy() {
if (this.componentRef) {
this.componentRef.destroy();
this.componentRef = null;
}
}
private updateInstance() {
if (this.componentRef && this.componentRef.instance) {
this.componentRef.instance.context = this.context;
}
}
}

View File

@ -25,64 +25,47 @@
(name-click)="onNodeDoubleClick($event.detail?.node)">
<empty-folder-content>
<ng-template>
<adf-empty-content
icon="star_rate"
[title]="'APP.BROWSE.FAVORITES.EMPTY_STATE.TITLE'"
subtitle="APP.BROWSE.FAVORITES.EMPTY_STATE.TEXT">
</adf-empty-content>
</ng-template>
<ng-template>
<adf-empty-content
icon="star_rate"
[title]="'APP.BROWSE.FAVORITES.EMPTY_STATE.TITLE'"
subtitle="APP.BROWSE.FAVORITES.EMPTY_STATE.TEXT">
</adf-empty-content>
</ng-template>
</empty-folder-content>
<data-columns>
<ng-container *ngFor="let column of columns">
<data-column
key="$thumbnail"
type="image"
[sortable]="false"
class="image-table-cell">
</data-column>
<data-column
class="adf-data-table-cell--ellipsis__name"
key="name"
title="APP.DOCUMENT_LIST.COLUMNS.NAME">
<ng-container *ngIf="column.template && !(column.desktopOnly && isSmallScreen)">
<data-column
[key]="column.key"
[title]="column.title"
[type]="column.type"
[format]="column.format"
[class]="column.class"
[sortable]="column.sortable">
<ng-template let-context>
<app-name-column [context]="context"></app-name-column>
<app-dynamic-column
[id]="column.template"
[context]="context">
</app-dynamic-column>
</ng-template>
</data-column>
</data-column>
</ng-container>
<data-column
*ngIf="!isSmallScreen"
key="path.name"
title="APP.DOCUMENT_LIST.COLUMNS.LOCATION">
<ng-template let-context>
<aca-location-link [context]="context"></aca-location-link>
</ng-template>
</data-column>
<data-column
*ngIf="!isSmallScreen"
key="sizeInBytes"
title="APP.DOCUMENT_LIST.COLUMNS.SIZE"
type="fileSize">
</data-column>
<data-column
*ngIf="!isSmallScreen"
key="modifiedAt"
title="APP.DOCUMENT_LIST.COLUMNS.MODIFIED_ON"
type="date"
format="timeAgo">
</data-column>
<data-column
*ngIf="!isSmallScreen"
class="adf-data-table-cell--ellipsis"
key="modifiedByUser.displayName"
title="APP.DOCUMENT_LIST.COLUMNS.MODIFIED_BY">
</data-column>
<ng-container *ngIf="!column.template && !(column.desktopOnly && isSmallScreen)">
<data-column
[key]="column.key"
[title]="column.title"
[type]="column.type"
[format]="column.format"
[class]="column.class"
[sortable]="column.sortable">
</data-column>
</ng-container>
</ng-container>
</data-columns>
</adf-document-list>

View File

@ -46,6 +46,8 @@ import { map } from 'rxjs/operators';
export class FavoritesComponent extends PageComponent implements OnInit {
isSmallScreen = false;
columns: any[] = [];
constructor(
private router: Router,
store: Store<AppStore>,
@ -74,6 +76,8 @@ export class FavoritesComponent extends PageComponent implements OnInit {
this.isSmallScreen = result.matches;
})
]);
this.columns = this.extensions.documentListPresets.favorites;
}
navigate(favorite: MinimalNodeEntryEntity) {

View File

@ -38,43 +38,37 @@
(name-click)="navigateTo($event.detail?.node)">
<data-columns>
<data-column
key="$thumbnail"
type="image"
[sortable]="false"
class="image-table-cell">
</data-column>
<ng-container *ngFor="let column of columns">
<data-column
class="adf-data-table-cell--ellipsis__name"
key="name"
title="APP.DOCUMENT_LIST.COLUMNS.NAME">
<ng-container *ngIf="column.template && !(column.desktopOnly && isSmallScreen)">
<data-column
[key]="column.key"
[title]="column.title"
[type]="column.type"
[format]="column.format"
[class]="column.class"
[sortable]="column.sortable">
<ng-template let-context>
<app-name-column [context]="context"></app-name-column>
<app-dynamic-column
[id]="column.template"
[context]="context">
</app-dynamic-column>
</ng-template>
</data-column>
</data-column>
</ng-container>
<data-column
*ngIf="!isSmallScreen"
key="content.sizeInBytes"
title="APP.DOCUMENT_LIST.COLUMNS.SIZE"
type="fileSize">
</data-column>
<ng-container *ngIf="!column.template && !(column.desktopOnly && isSmallScreen)">
<data-column
[key]="column.key"
[title]="column.title"
[type]="column.type"
[format]="column.format"
[class]="column.class"
[sortable]="column.sortable">
</data-column>
</ng-container>
<data-column
*ngIf="!isSmallScreen"
key="modifiedAt"
title="APP.DOCUMENT_LIST.COLUMNS.MODIFIED_ON"
type="date"
format="timeAgo">
</data-column>
<data-column
*ngIf="!isSmallScreen"
class="adf-data-table-cell--ellipsis"
key="modifiedByUser.displayName"
title="APP.DOCUMENT_LIST.COLUMNS.MODIFIED_BY">
</data-column>
</ng-container>
</data-columns>
</adf-document-list>

View File

@ -52,6 +52,8 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
private nodePath: PathElement[];
columns: any[] = [];
constructor(
private router: Router,
private route: ActivatedRoute,
@ -115,6 +117,8 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
this.isSmallScreen = result.matches;
})
]);
this.columns = this.extensions.documentListPresets.files || [];
}
ngOnDestroy() {

View File

@ -38,30 +38,37 @@
</empty-folder-content>
<data-columns>
<data-column
key="$thumbnail"
type="image"
[sortable]="false"
class="image-table-cell">
</data-column>
<ng-container *ngFor="let column of columns">
<data-column
class="adf-data-table-cell--ellipsis__name"
key="title"
title="APP.DOCUMENT_LIST.COLUMNS.TITLE">
<ng-container *ngIf="column.template && !(column.desktopOnly && isSmallScreen)">
<data-column
[key]="column.key"
[title]="column.title"
[type]="column.type"
[format]="column.format"
[class]="column.class"
[sortable]="column.sortable">
<ng-template let-context>
<app-library-name-column [context]="context"></app-library-name-column>
<app-dynamic-column
[id]="column.template"
[context]="context">
</app-dynamic-column>
</ng-template>
</data-column>
</data-column>
</ng-container>
<data-column
*ngIf="!isSmallScreen"
key="visibility"
title="APP.DOCUMENT_LIST.COLUMNS.STATUS">
<ng-template let-context>
<app-library-status-column [context]="context"></app-library-status-column>
</ng-template>
</data-column>
<ng-container *ngIf="!column.template && !(column.desktopOnly && isSmallScreen)">
<data-column
[key]="column.key"
[title]="column.title"
[type]="column.type"
[format]="column.format"
[class]="column.class"
[sortable]="column.sortable">
</data-column>
</ng-container>
</ng-container>
</data-columns>
</adf-document-list>

View File

@ -39,6 +39,8 @@ import { NavigateLibraryAction } from 'src/app/store/actions';
export class LibrariesComponent extends PageComponent implements OnInit {
isSmallScreen = false;
columns: any[] = [];
constructor(
content: ContentManagementService,
store: Store<AppStore>,
@ -60,6 +62,8 @@ export class LibrariesComponent extends PageComponent implements OnInit {
this.isSmallScreen = result.matches;
})
);
this.columns = this.extensions.documentListPresets.libraries || [];
}
navigateTo(node: SiteEntry) {

View File

@ -37,45 +37,37 @@
</empty-folder-content>
<data-columns>
<data-column
key="$thumbnail"
type="image"
[sortable]="false"
class="image-table-cell">
</data-column>
<ng-container *ngFor="let column of columns">
<data-column
class="adf-data-table-cell--ellipsis__name"
key="name"
title="APP.DOCUMENT_LIST.COLUMNS.NAME">
<ng-container *ngIf="column.template && !(column.desktopOnly && isSmallScreen)">
<data-column
[key]="column.key"
[title]="column.title"
[type]="column.type"
[format]="column.format"
[class]="column.class"
[sortable]="column.sortable">
<ng-template let-context>
<app-name-column [context]="context"></app-name-column>
<app-dynamic-column
[id]="column.template"
[context]="context">
</app-dynamic-column>
</ng-template>
</data-column>
</data-column>
</ng-container>
<data-column
*ngIf="!isSmallScreen"
key="path.name"
title="APP.DOCUMENT_LIST.COLUMNS.LOCATION">
<ng-template let-context>
<aca-location-link [context]="context"></aca-location-link>
</ng-template>
</data-column>
<ng-container *ngIf="!column.template && !(column.desktopOnly && isSmallScreen)">
<data-column
[key]="column.key"
[title]="column.title"
[type]="column.type"
[format]="column.format"
[class]="column.class"
[sortable]="column.sortable">
</data-column>
</ng-container>
<data-column
*ngIf="!isSmallScreen"
key="content.sizeInBytes"
type="fileSize"
title="APP.DOCUMENT_LIST.COLUMNS.SIZE">
</data-column>
<data-column
*ngIf="!isSmallScreen"
key="modifiedAt"
title="APP.DOCUMENT_LIST.COLUMNS.MODIFIED_ON"
type="date"
format="timeAgo">
</data-column>
</ng-container>
</data-columns>
</adf-document-list>

View File

@ -38,6 +38,8 @@ import { AppExtensionService } from '../../extensions/extension.service';
export class RecentFilesComponent extends PageComponent implements OnInit {
isSmallScreen = false;
columns: any[] = [];
constructor(
store: Store<AppStore>,
extensions: AppExtensionService,
@ -61,6 +63,8 @@ export class RecentFilesComponent extends PageComponent implements OnInit {
this.isSmallScreen = result.matches;
})
]);
this.columns = this.extensions.documentListPresets.recent || [];
}
onNodeDoubleClick(node: MinimalNodeEntity) {

View File

@ -25,70 +25,47 @@
(name-click)="showPreview($event.detail?.node)">
<empty-folder-content>
<ng-template>
<adf-empty-content
icon="people"
[title]="'APP.BROWSE.SHARED.EMPTY_STATE.TITLE'"
subtitle="APP.BROWSE.SHARED.EMPTY_STATE.TEXT">
</adf-empty-content>
</ng-template>
<ng-template>
<adf-empty-content
icon="people"
[title]="'APP.BROWSE.SHARED.EMPTY_STATE.TITLE'"
subtitle="APP.BROWSE.SHARED.EMPTY_STATE.TEXT">
</adf-empty-content>
</ng-template>
</empty-folder-content>
<data-columns>
<data-column
key="$thumbnail"
type="image"
[sortable]="false"
class="image-table-cell">
</data-column>
<ng-container *ngFor="let column of columns">
<data-column
class="adf-data-table-cell--ellipsis__name"
key="name"
title="APP.DOCUMENT_LIST.COLUMNS.NAME">
<ng-container *ngIf="column.template && !(column.desktopOnly && isSmallScreen)">
<data-column
[key]="column.key"
[title]="column.title"
[type]="column.type"
[format]="column.format"
[class]="column.class"
[sortable]="column.sortable">
<ng-template let-context>
<app-name-column [context]="context"></app-name-column>
<app-dynamic-column
[id]="column.template"
[context]="context">
</app-dynamic-column>
</ng-template>
</data-column>
</data-column>
</ng-container>
<data-column
*ngIf="!isSmallScreen"
key="path.name"
title="APP.DOCUMENT_LIST.COLUMNS.LOCATION">
<ng-template let-context>
<aca-location-link [context]="context"></aca-location-link>
</ng-template>
</data-column>
<data-column
*ngIf="!isSmallScreen"
key="content.sizeInBytes"
title="APP.DOCUMENT_LIST.COLUMNS.SIZE"
type="fileSize">
</data-column>
<data-column
*ngIf="!isSmallScreen"
key="modifiedAt"
title="APP.DOCUMENT_LIST.COLUMNS.MODIFIED_ON"
type="date"
format="timeAgo">
</data-column>
<data-column
*ngIf="!isSmallScreen"
class="adf-data-table-cell--ellipsis"
key="modifiedByUser.displayName"
title="APP.DOCUMENT_LIST.COLUMNS.MODIFIED_BY">
</data-column>
<data-column
*ngIf="!isSmallScreen"
class="adf-data-table-cell--ellipsis"
key="sharedByUser.displayName"
title="APP.DOCUMENT_LIST.COLUMNS.SHARED_BY">
</data-column>
<ng-container *ngIf="!column.template && !(column.desktopOnly && isSmallScreen)">
<data-column
[key]="column.key"
[title]="column.title"
[type]="column.type"
[format]="column.format"
[class]="column.class"
[sortable]="column.sortable">
</data-column>
</ng-container>
</ng-container>
</data-columns>
</adf-document-list>

View File

@ -38,6 +38,8 @@ import { debounceTime } from 'rxjs/operators';
export class SharedFilesComponent extends PageComponent implements OnInit {
isSmallScreen = false;
columns: any[] = [];
constructor(
store: Store<AppStore>,
extensions: AppExtensionService,
@ -64,5 +66,7 @@ export class SharedFilesComponent extends PageComponent implements OnInit {
this.isSmallScreen = result.matches;
})
]);
this.columns = this.extensions.documentListPresets.shared || [];
}
}

View File

@ -35,54 +35,44 @@
</empty-folder-content>
<data-columns>
<ng-container *ngFor="let column of columns">
<data-column
key="$thumbnail"
type="image"
[sortable]="false"
class="image-table-cell">
</data-column>
<data-column
class="adf-data-table-cell--ellipsis__name"
key="name"
title="APP.DOCUMENT_LIST.COLUMNS.NAME">
<ng-container *ngIf="column.template && !(column.desktopOnly && isSmallScreen)">
<data-column
[key]="column.key"
[title]="column.title"
[type]="column.type"
[format]="column.format"
[class]="column.class"
[sortable]="column.sortable">
<ng-template let-context>
<app-trashcan-name-column [context]="context"></app-trashcan-name-column>
<app-dynamic-column
[id]="column.template"
[context]="context">
</app-dynamic-column>
</ng-template>
</data-column>
</data-column>
</ng-container>
<data-column
*ngIf="!isSmallScreen"
key="path.name"
title="APP.DOCUMENT_LIST.COLUMNS.LOCATION">
<ng-template let-context>
<aca-location-link [context]="context"></aca-location-link>
</ng-template>
</data-column>
<ng-container *ngIf="!column.template && !(column.desktopOnly && isSmallScreen)">
<data-column
[key]="column.key"
[title]="column.title"
[type]="column.type"
[format]="column.format"
[class]="column.class"
[sortable]="column.sortable">
</data-column>
</ng-container>
<data-column
*ngIf="!isSmallScreen"
key="content.sizeInBytes"
title="APP.DOCUMENT_LIST.COLUMNS.SIZE"
type="fileSize">
</data-column>
<data-column
*ngIf="!isSmallScreen"
key="archivedAt"
title="APP.DOCUMENT_LIST.COLUMNS.DELETED_ON"
type="date"
format="timeAgo">
</data-column>
<data-column
*ngIf="!isSmallScreen && (user$ | async)?.isAdmin"
class="adf-data-table-cell--ellipsis"
key="archivedByUser.displayName"
title="APP.DOCUMENT_LIST.COLUMNS.DELETED_BY">
</data-column>
</ng-container>
<data-column
*ngIf="!isSmallScreen && (user$ | async)?.isAdmin"
class="adf-data-table-cell--ellipsis"
key="archivedByUser.displayName"
title="APP.DOCUMENT_LIST.COLUMNS.DELETED_BY">
</data-column>
</data-columns>
</adf-document-list>

View File

@ -41,6 +41,8 @@ export class TrashcanComponent extends PageComponent implements OnInit {
isSmallScreen = false;
user$: Observable<ProfileState>;
columns: any[] = [];
constructor(
content: ContentManagementService,
extensions: AppExtensionService,
@ -65,5 +67,7 @@ export class TrashcanComponent extends PageComponent implements OnInit {
this.isSmallScreen = result.matches;
})
);
this.columns = this.extensions.documentListPresets.trashcan || [];
}
}

View File

@ -39,6 +39,11 @@ import { CommentsTabComponent } from '../components/info-drawer/comments-tab/com
import { VersionsTabComponent } from '../components/info-drawer/versions-tab/versions-tab.component';
import { ExtensionsModule, ExtensionService } from '@alfresco/adf-extensions';
import { AppAuthGuard } from '../guards/auth.guard';
import { NameColumnComponent } from '../components/common/name-column/name-column.component';
import { LibraryNameColumnComponent } from '../components/common/library-name-column/library-name-column.component';
import { LibraryStatusColumnComponent } from '../components/common/library-status-column/library-status-column.component';
import { TrashcanNameColumnComponent } from '../components/common/trashcan-name-column/trashcan-name-column.component';
import { LocationLinkComponent } from '../components/common/location-link/location-link.component';
export function setupExtensions(service: AppExtensionService): Function {
return () => service.load();
@ -52,7 +57,6 @@ export class CoreExtensionsModule {
return {
ngModule: CoreExtensionsModule,
providers: [
// AppExtensionService,
{
provide: APP_INITIALIZER,
useFactory: setupExtensions,
@ -77,7 +81,12 @@ export class CoreExtensionsModule {
'app.components.tabs.versions': VersionsTabComponent,
'app.toolbar.toggleInfoDrawer': ToggleInfoDrawerComponent,
'app.toolbar.toggleFavorite': ToggleFavoriteComponent,
'app.shared-link.toggleSharedLink': ToggleSharedComponent
'app.shared-link.toggleSharedLink': ToggleSharedComponent,
'app.columns.name': NameColumnComponent,
'app.columns.libraryName': LibraryNameColumnComponent,
'app.columns.libraryStatus': LibraryStatusColumnComponent,
'app.columns.trashcanName': TrashcanNameColumnComponent,
'app.columns.location': LocationLinkComponent
});
extensions.setAuthGuards({

View File

@ -0,0 +1,37 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ExtensionElement } from '@alfresco/adf-extensions';
export interface DocumentListPresetRef extends ExtensionElement {
key: string;
type: string; // text|image|date
title?: string;
format?: string;
class?: string;
sortable: boolean;
template: string;
desktopOnly: boolean;
}

View File

@ -49,6 +49,7 @@ import {
mergeObjects
} from '@alfresco/adf-extensions';
import { AppConfigService } from '@alfresco/adf-core';
import { DocumentListPresetRef } from './document-list.extensions';
@Injectable({
providedIn: 'root'
@ -71,6 +72,22 @@ export class AppExtensionService implements RuleContext {
sidebar: Array<SidebarTabRef> = [];
contentMetadata: any;
documentListPresets: {
files: Array<DocumentListPresetRef>;
libraries: Array<DocumentListPresetRef>;
shared: Array<DocumentListPresetRef>;
recent: Array<DocumentListPresetRef>;
favorites: Array<DocumentListPresetRef>;
trashcan: Array<DocumentListPresetRef>;
} = {
files: [],
libraries: [],
shared: [],
recent: [],
favorites: [],
trashcan: []
};
selection: SelectionState;
navigation: NavigationState;
profile: ProfileState;
@ -139,6 +156,33 @@ export class AppExtensionService implements RuleContext {
'features.sidebar'
);
this.contentMetadata = this.loadContentMetadata(config);
this.documentListPresets = {
files: this.loader.getElements<DocumentListPresetRef>(
config,
'features.documentList.files'
),
libraries: this.loader.getElements<DocumentListPresetRef>(
config,
'features.documentList.libraries'
),
shared: this.loader.getElements<DocumentListPresetRef>(
config,
'features.documentList.shared'
),
recent: this.loader.getElements<DocumentListPresetRef>(
config,
'features.documentList.recent'
),
favorites: this.loader.getElements<DocumentListPresetRef>(
config,
'features.documentList.favorites'
),
trashcan: this.loader.getElements<DocumentListPresetRef>(
config,
'features.documentList.trashcan'
)
};
}
protected loadNavBar(config: ExtensionConfig): Array<NavBarGroupRef> {

View File

@ -865,6 +865,294 @@
}
]
}
]
],
"documentList": {
"files": [
{
"id": "app.files.thumbnail",
"key": "$thumbnail",
"type": "image",
"class": "image-table-cell",
"sortable": false,
"desktopOnly": false
},
{
"id": "app.files.name",
"key": "name",
"title": "APP.DOCUMENT_LIST.COLUMNS.NAME",
"type": "text",
"class": "adf-data-table-cell--ellipsis__name",
"sortable": true,
"template": "app.columns.name",
"desktopOnly": false
},
{
"id": "app.files.size",
"key": "content.sizeInBytes",
"title": "APP.DOCUMENT_LIST.COLUMNS.SIZE",
"type": "fileSize",
"sortable": true,
"desktopOnly": true
},
{
"id": "app.files.modifiedOn",
"key": "modifiedAt",
"title": "APP.DOCUMENT_LIST.COLUMNS.MODIFIED_ON",
"type": "date",
"format": "timeAgo",
"sortable": true,
"desktopOnly": true
},
{
"id": "app.files.modifiedBy",
"key": "modifiedByUser.displayName",
"title": "APP.DOCUMENT_LIST.COLUMNS.MODIFIED_BY",
"type": "text",
"class": "adf-data-table-cell--ellipsis",
"sortable": true,
"desktopOnly": true
}
],
"libraries": [
{
"id": "app.libraries.thumbnail",
"key": "$thumbnail",
"type": "image",
"class": "image-table-cell",
"sortable": false,
"desktopOnly": false
},
{
"id": "app.libraries.name",
"key": "title",
"title": "APP.DOCUMENT_LIST.COLUMNS.TITLE",
"type": "text",
"class": "adf-data-table-cell--ellipsis__name",
"sortable": true,
"template": "app.columns.libraryName",
"desktopOnly": false
},
{
"id": "app.libraries.visibility",
"key": "visibility",
"title": "APP.DOCUMENT_LIST.COLUMNS.STATUS",
"type": "text",
"sortable": true,
"template": "app.columns.libraryStatus",
"desktopOnly": true
}
],
"shared": [
{
"id": "app.shared.thumbnail",
"key": "$thumbnail",
"type": "image",
"class": "image-table-cell",
"sortable": false,
"desktopOnly": false
},
{
"id": "app.shared.name",
"key": "name",
"title": "APP.DOCUMENT_LIST.COLUMNS.NAME",
"type": "text",
"class": "adf-data-table-cell--ellipsis__name",
"sortable": true,
"template": "app.columns.name",
"desktopOnly": false
},
{
"id": "app.shared.location",
"key": "path.name",
"title": "APP.DOCUMENT_LIST.COLUMNS.LOCATION",
"type": "text",
"sortable": true,
"template": "app.columns.location",
"desktopOnly": true
},
{
"id": "app.shared.size",
"key": "content.sizeInBytes",
"title": "APP.DOCUMENT_LIST.COLUMNS.SIZE",
"type": "fileSize",
"sortable": true,
"desktopOnly": true
},
{
"id": "app.shared.modifiedOn",
"key": "modifiedAt",
"title": "APP.DOCUMENT_LIST.COLUMNS.MODIFIED_ON",
"type": "date",
"format": "timeAgo",
"sortable": true,
"desktopOnly": true
},
{
"id": "app.shared.modifiedBy",
"key": "modifiedByUser.displayName",
"title": "APP.DOCUMENT_LIST.COLUMNS.MODIFIED_BY",
"type": "text",
"class": "adf-data-table-cell--ellipsis",
"sortable": true,
"desktopOnly": true
},
{
"id": "app.shared.sharedBy",
"key": "sharedByUser.displayName",
"title": "APP.DOCUMENT_LIST.COLUMNS.SHARED_BY",
"type": "text",
"class": "adf-data-table-cell--ellipsis",
"sortable": true,
"desktopOnly": true
}
],
"recent": [
{
"id": "app.recent.thumbnail",
"key": "$thumbnail",
"type": "image",
"class": "image-table-cell",
"sortable": false,
"desktopOnly": false
},
{
"id": "app.recent.name",
"key": "name",
"title": "APP.DOCUMENT_LIST.COLUMNS.NAME",
"type": "text",
"class": "adf-data-table-cell--ellipsis__name",
"sortable": true,
"template": "app.columns.name",
"desktopOnly": false
},
{
"id": "app.recent.location",
"key": "path.name",
"title": "APP.DOCUMENT_LIST.COLUMNS.LOCATION",
"type": "text",
"sortable": true,
"template": "app.columns.location",
"desktopOnly": true
},
{
"id": "app.recent.size",
"key": "content.sizeInBytes",
"title": "APP.DOCUMENT_LIST.COLUMNS.SIZE",
"type": "fileSize",
"sortable": true,
"desktopOnly": true
},
{
"id": "app.recent.modifiedOn",
"key": "modifiedAt",
"title": "APP.DOCUMENT_LIST.COLUMNS.MODIFIED_ON",
"type": "date",
"format": "timeAgo",
"sortable": true,
"desktopOnly": true
}
],
"favorites": [
{
"id": "app.favorites.thumbnail",
"key": "$thumbnail",
"type": "image",
"class": "image-table-cell",
"sortable": false,
"desktopOnly": false
},
{
"id": "app.favorites.name",
"key": "name",
"title": "APP.DOCUMENT_LIST.COLUMNS.NAME",
"type": "text",
"class": "adf-data-table-cell--ellipsis__name",
"sortable": true,
"template": "app.columns.name",
"desktopOnly": false
},
{
"id": "app.favorites.location",
"key": "path.name",
"title": "APP.DOCUMENT_LIST.COLUMNS.LOCATION",
"type": "text",
"sortable": true,
"template": "app.columns.location",
"desktopOnly": true
},
{
"id": "app.favorites.size",
"key": "sizeInBytes",
"title": "APP.DOCUMENT_LIST.COLUMNS.SIZE",
"type": "fileSize",
"sortable": true,
"desktopOnly": true
},
{
"id": "app.favorites.modifiedOn",
"key": "modifiedAt",
"title": "APP.DOCUMENT_LIST.COLUMNS.MODIFIED_ON",
"type": "date",
"format": "timeAgo",
"sortable": true,
"desktopOnly": true
},
{
"id": "app.favorites.modifiedBy",
"key": "modifiedByUser.displayName",
"title": "APP.DOCUMENT_LIST.COLUMNS.MODIFIED_BY",
"type": "text",
"class": "adf-data-table-cell--ellipsis",
"sortable": true,
"desktopOnly": true
}
],
"trashcan": [
{
"id": "app.trashcan.thumbnail",
"key": "$thumbnail",
"type": "image",
"class": "image-table-cell",
"sortable": false,
"desktopOnly": false
},
{
"id": "app.trashcan.name",
"key": "name",
"title": "APP.DOCUMENT_LIST.COLUMNS.NAME",
"type": "text",
"class": "adf-data-table-cell--ellipsis__name",
"sortable": true,
"template": "app.columns.trashcanName",
"desktopOnly": false
},
{
"id": "app.trashcan.location",
"key": "path.name",
"title": "APP.DOCUMENT_LIST.COLUMNS.LOCATION",
"type": "text",
"sortable": true,
"template": "app.columns.location",
"desktopOnly": true
},
{
"id": "app.trashcan.size",
"key": "content.sizeInBytes",
"title": "APP.DOCUMENT_LIST.COLUMNS.SIZE",
"type": "fileSize",
"sortable": true,
"desktopOnly": true
},
{
"id": "app.trashcan.deletedOn",
"key": "archivedAt",
"title": "APP.DOCUMENT_LIST.COLUMNS.DELETED_ON",
"type": "date",
"format": "timeAgo",
"sortable": true,
"desktopOnly": true
}
]
}
}
}