[ADF-2859] conditional evaluation of disabled state for content actions (#3450)

* react on [disabled] binding changes

* [disabled] binding updates for context menu items

* evaluating disabled state with a function

* unit test

* restore original description

* remove irrelevant test

* fix tests
This commit is contained in:
Denys Vuika
2018-06-07 23:28:01 +01:00
committed by Eugenio Romano
parent 08fd49c4e3
commit cb88a22a76
10 changed files with 199 additions and 93 deletions

View File

@@ -66,7 +66,7 @@ export class ContentActionComponent implements OnInit, OnChanges, OnDestroy {
/** Is the menu item disabled? */
@Input()
disabled: boolean = false;
disabled: boolean | Function = false;
/** Emitted when the user selects the action from the menu. */
@Output()
@@ -117,6 +117,15 @@ export class ContentActionComponent implements OnInit, OnChanges, OnDestroy {
this.folderActionModel.visible = changes.visible.currentValue;
}
}
if (changes.disabled && !changes.disabled.firstChange) {
if (this.documentActionModel) {
this.documentActionModel.disabled = changes.disabled.currentValue;
}
if (this.folderActionModel) {
this.folderActionModel.disabled = changes.disabled.currentValue;
}
}
}
ngOnDestroy() {