mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2859] fixes for the conditional visibility and disabled states (#3465)
* fixes for the conditional visibility and disabled states * update docs * cleanup code * remove unused code
This commit is contained in:
committed by
Eugenio Romano
parent
1d69f5c407
commit
6f2cbdf697
@@ -29,13 +29,15 @@ import { ContextMenuService } from './context-menu.service';
|
||||
template: `
|
||||
<button mat-button [matMenuTriggerFor]="contextMenu"></button>
|
||||
<mat-menu #contextMenu="matMenu" class="context-menu">
|
||||
<button *ngFor="let link of links"
|
||||
mat-menu-item
|
||||
[disabled]="link.model?.disabled"
|
||||
(click)="onMenuItemClick($event, link)">
|
||||
<mat-icon *ngIf="showIcons && link.model?.icon">{{ link.model.icon }}</mat-icon>
|
||||
{{ (link.title || link.model?.title) | translate }}
|
||||
</button>
|
||||
<ng-container *ngFor="let link of links">
|
||||
<button *ngIf="link.model?.visible"
|
||||
mat-menu-item
|
||||
[disabled]="link.model?.disabled"
|
||||
(click)="onMenuItemClick($event, link)">
|
||||
<mat-icon *ngIf="showIcons && link.model?.icon">{{ link.model.icon }}</mat-icon>
|
||||
{{ (link.title || link.model?.title) | translate }}
|
||||
</button>
|
||||
</ng-container>
|
||||
</mat-menu>
|
||||
`
|
||||
})
|
||||
|
@@ -155,6 +155,9 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
||||
@Input()
|
||||
noPermission: boolean = false;
|
||||
|
||||
@Input()
|
||||
rowMenuCacheEnabled = true;
|
||||
|
||||
noContentTemplate: TemplateRef<any>;
|
||||
noPermissionTemplate: TemplateRef<any>;
|
||||
loadingTemplate: TemplateRef<any>;
|
||||
@@ -166,6 +169,8 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
||||
private click$: Observable<DataRowEvent>;
|
||||
|
||||
private differ: any;
|
||||
private rowMenuCache: object = {};
|
||||
|
||||
private subscriptions: Subscription[] = [];
|
||||
private singleClickStreamSub: Subscription;
|
||||
private multiClickStreamSub: Subscription;
|
||||
@@ -297,6 +302,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
||||
private initTable() {
|
||||
this.data = new ObjectDataTableAdapter(this.rows, this.columns);
|
||||
this.setupData(this.data);
|
||||
this.rowMenuCache = {};
|
||||
}
|
||||
|
||||
private setupData(adapter: DataTableAdapter) {
|
||||
@@ -553,9 +559,18 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
|
||||
}
|
||||
|
||||
getRowActions(row: DataRow, col: DataColumn): any[] {
|
||||
let event = new DataCellEvent(row, col, []);
|
||||
this.showRowActionsMenu.emit(event);
|
||||
return event.value.actions;
|
||||
const id = row.getValue('id');
|
||||
|
||||
if (!this.rowMenuCache[id]) {
|
||||
let event = new DataCellEvent(row, col, []);
|
||||
this.showRowActionsMenu.emit(event);
|
||||
if (!this.rowMenuCacheEnabled) {
|
||||
return event.value.actions;
|
||||
}
|
||||
this.rowMenuCache[id] = event.value.actions;
|
||||
}
|
||||
|
||||
return this.rowMenuCache[id];
|
||||
}
|
||||
|
||||
onExecuteRowAction(row: DataRow, action: any) {
|
||||
|
Reference in New Issue
Block a user