diff --git a/ng2-components/ng2-alfresco-core/src/components/context-menu.directive.ts b/ng2-components/ng2-alfresco-core/src/components/context-menu.directive.ts
index ae816ce374..be498b8069 100644
--- a/ng2-components/ng2-alfresco-core/src/components/context-menu.directive.ts
+++ b/ng2-components/ng2-alfresco-core/src/components/context-menu.directive.ts
@@ -26,17 +26,20 @@ import { ContextMenuService } from './../services/context-menu.service';
})
export class ContextMenuDirective {
@Input('context-menu')
- links;
+ links: any[];
constructor(
private _contextMenuService: ContextMenuService) {}
onShowContextMenu(event?: MouseEvent) {
- if (this._contextMenuService) {
- this._contextMenuService.show.next({event: event, obj: this.links});
- }
if (event) {
event.preventDefault();
}
+
+ if (this.links && this.links.length > 0) {
+ if (this._contextMenuService) {
+ this._contextMenuService.show.next({event: event, obj: this.links});
+ }
+ }
}
}
diff --git a/ng2-components/ng2-alfresco-datatable/index.ts b/ng2-components/ng2-alfresco-datatable/index.ts
index e1791a1457..2c4b5b3e3d 100644
--- a/ng2-components/ng2-alfresco-datatable/index.ts
+++ b/ng2-components/ng2-alfresco-datatable/index.ts
@@ -16,14 +16,17 @@
*/
import { DataTableComponent } from './src/components/datatable.component';
+import { NoContentTemplateComponent } from './src/components/no-content-template.component';
// components
export * from './src/components/datatable.component';
+export * from './src/components/no-content-template.component';
// data
export * from './src/data/datatable-adapter';
export * from './src/data/object-datatable-adapter';
export const ALFRESCO_DATATABLE_DIRECTIVES: [any] = [
- DataTableComponent
+ DataTableComponent,
+ NoContentTemplateComponent
];
diff --git a/ng2-components/ng2-alfresco-datatable/package.json b/ng2-components/ng2-alfresco-datatable/package.json
index 69fed501e8..6abec62e8c 100644
--- a/ng2-components/ng2-alfresco-datatable/package.json
+++ b/ng2-components/ng2-alfresco-datatable/package.json
@@ -66,7 +66,8 @@
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "0.6.12",
- "rimraf": "2.5.2"
+ "rimraf": "2.5.2",
+ "ng2-alfresco-core": "^0.1.35"
},
"peerDependencies": {
"material-design-icons": "^2.2.3",
diff --git a/ng2-components/ng2-alfresco-datatable/src/components/datatable.component.html b/ng2-components/ng2-alfresco-datatable/src/components/datatable.component.html
index 7554a3e7e0..896e5816b5 100644
--- a/ng2-components/ng2-alfresco-datatable/src/components/datatable.component.html
+++ b/ng2-components/ng2-alfresco-datatable/src/components/datatable.component.html
@@ -42,7 +42,8 @@
+ (dblclick)="onRowDblClick(row, $event)"
+ [context-menu]="getContextActions(row, col)">
{{asIconValue(row, col)}}
}})
@@ -62,5 +63,14 @@
|
+
+
+
+
+ |
+
diff --git a/ng2-components/ng2-alfresco-datatable/src/components/datatable.component.ts b/ng2-components/ng2-alfresco-datatable/src/components/datatable.component.ts
index 7e9c38a56d..a8e66c039f 100644
--- a/ng2-components/ng2-alfresco-datatable/src/components/datatable.component.ts
+++ b/ng2-components/ng2-alfresco-datatable/src/components/datatable.component.ts
@@ -22,9 +22,13 @@ import {
Input,
Output,
EventEmitter,
- AfterViewChecked
+ AfterViewChecked,
+ TemplateRef
} from '@angular/core';
+// import { Subject } from 'rxjs/Rx';
+import { CONTEXT_MENU_DIRECTIVES } from 'ng2-alfresco-core';
+
import {
DataTableAdapter,
DataRow,
@@ -41,7 +45,8 @@ declare let __moduleName: string;
moduleId: __moduleName,
selector: 'alfresco-datatable',
styleUrls: ['./datatable.component.css'],
- templateUrl: './datatable.component.html'
+ templateUrl: './datatable.component.html',
+ directives: [CONTEXT_MENU_DIRECTIVES]
})
export class DataTableComponent implements OnInit, AfterViewChecked {
@@ -55,13 +60,18 @@ export class DataTableComponent implements OnInit, AfterViewChecked {
actions: boolean = false;
@Output()
- rowClick: EventEmitter = new EventEmitter();
+ rowClick: EventEmitter = new EventEmitter();
@Output()
- rowDblClick: EventEmitter = new EventEmitter();
+ rowDblClick: EventEmitter = new EventEmitter();
+
+ noContentTemplate: TemplateRef;
isSelectAllChecked: boolean = false;
+ @Output()
+ showContextMenu: EventEmitter = new EventEmitter();
+
// TODO: left for reference, will be removed during future revisions
constructor(/*private _ngZone?: NgZone*/) {
}
@@ -158,4 +168,10 @@ export class DataTableComponent implements OnInit, AfterViewChecked {
}
return false;
}
+
+ getContextActions(row: DataRow, col: DataColumn) {
+ let args = { row: row, col: col, actions: [] };
+ this.showContextMenu.emit({ args: args });
+ return args.actions;
+ }
}
diff --git a/ng2-components/ng2-alfresco-datatable/src/components/no-content-template.component.ts b/ng2-components/ng2-alfresco-datatable/src/components/no-content-template.component.ts
new file mode 100644
index 0000000000..081d31b733
--- /dev/null
+++ b/ng2-components/ng2-alfresco-datatable/src/components/no-content-template.component.ts
@@ -0,0 +1,41 @@
+/*!
+ * @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.
+ */
+
+import {
+ Directive,
+ ContentChild,
+ TemplateRef,
+ AfterContentInit
+} from '@angular/core';
+import { DataTableComponent } from './datatable.component';
+
+@Directive({
+ selector: 'no-content-template'
+})
+export class NoContentTemplateComponent implements AfterContentInit {
+
+ @ContentChild(TemplateRef)
+ template: any;
+
+ constructor(
+ private dataTable: DataTableComponent) {
+ }
+
+ ngAfterContentInit() {
+ this.dataTable.noContentTemplate = this.template;
+ }
+}
diff --git a/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts b/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts
index 8b84975ca5..1e6eb2ad4a 100644
--- a/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts
+++ b/ng2-components/ng2-alfresco-documentlist/demo/src/main.ts
@@ -56,7 +56,13 @@ import {
#documentList
[currentFolderPath]="currentPath"
(folderChange)="onFolderChanged($event)">
-
+
+
+
+
+
+
+
diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts
index d70a1f43a5..fe0a0144c0 100644
--- a/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts
+++ b/ng2-components/ng2-alfresco-documentlist/src/components/document-list.ts
@@ -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 = 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 = ( args.row).node;
+ if (node) {
+ args.actions = this.getContextActions(node) || [];
+ }
+ };
}
|