mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[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:
committed by
Cilibiu Bogdan
parent
933f426759
commit
9dcdacce40
@@ -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,
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user