#340 Empty content template and context menu for datatable

This commit is contained in:
Denys Vuika
2016-07-05 12:37:07 +01:00
parent e3924fdaa3
commit 236926c1ca
9 changed files with 132 additions and 19 deletions

View File

@@ -22,10 +22,12 @@ import {
Output,
EventEmitter,
AfterContentInit,
AfterViewInit,
AfterViewChecked,
OnChanges,
TemplateRef,
NgZone
NgZone,
ViewChild
} from '@angular/core';
import { DatePipe } from '@angular/common';
import { Subject } from 'rxjs/Rx';
@@ -34,7 +36,8 @@ import { CONTEXT_MENU_DIRECTIVES } from 'ng2-alfresco-core';
import {
ALFRESCO_DATATABLE_DIRECTIVES,
DataSorting,
DataRowEvent
DataRowEvent,
DataTableComponent
} from 'ng2-alfresco-datatable';
import { AlfrescoService } from './../services/alfresco.service';
@@ -58,7 +61,7 @@ declare let __moduleName: string;
'(contextmenu)': 'onShowContextMenu($event)'
}
})
export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit, OnChanges {
export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, AfterContentInit, OnChanges {
static SINGLE_CLICK_NAVIGATION: string = 'click';
static DOUBLE_CLICK_NAVIGATION: string = 'dblclick';
@@ -88,6 +91,9 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit,
@Output()
preview: EventEmitter<any> = new EventEmitter();
@ViewChild(DataTableComponent)
dataTable: DataTableComponent;
private _path = this.DEFAULT_ROOT_FOLDER;
get currentFolderPath(): string {
@@ -137,7 +143,8 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit,
constructor(
private alfrescoService: AlfrescoService,
private ngZone: NgZone) {
this.setupTable();
this.setupData();
}
getContextActions(node: MinimalNodeEntity) {
@@ -189,6 +196,15 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit,
}
}
ngAfterViewInit() {
if (this.dataTable) {
// this.dataTable.contextActionResolver = this.resolveContextAction;
if (this.emptyFolderTemplate) {
this.dataTable.noContentTemplate = this.emptyFolderTemplate;
}
}
}
ngAfterViewChecked() {
// workaround for MDL issues with dynamic components
if (componentHandler) {
@@ -518,7 +534,7 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit,
return column && column.source && !column.source.startsWith('$');
}
private setupTable() {
private setupData() {
this.data = new ShareDataTableAdapter(
this.alfrescoService,
this.baseComponentPath,
@@ -532,4 +548,12 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit,
this.data.setSorting(new DataSorting('id', 'asc'));
}
onRowContextMenu(event) {
let args = event.args;
let node = (<ShareDataRow> args.row).node;
if (node) {
args.actions = this.getContextActions(node) || [];
}
};
}