import * as _ from 'lodash';
+import { Icons } from '../../../shared/enum/icons.enum';
import { CdTableAction } from '../../models/cd-table-action';
import { CdTableSelection } from '../../models/cd-table-selection';
import { Permission } from '../../models/permissions';
selection: CdTableSelection;
@Input()
tableActions: CdTableAction[];
+ @Input()
+ btnColor = 'secondary';
// Use this if you just want to display a drop down button,
// labeled with the given text, with all actions in it.
// This disables the main action button.
@Input()
- onlyDropDown?: string;
+ dropDownOnly?: string;
// Array with all visible actions
dropDownActions: CdTableAction[] = [];
+ icons = Icons;
+
constructor() {}
ngOnInit() {
* @returns {CdTableAction}
*/
getCurrentButton(): CdTableAction {
- if (this.onlyDropDown) {
- return;
+ if (this.dropDownOnly) {
+ return undefined;
}
let buttonAction = this.dropDownActions.find((tableAction) => this.showableAction(tableAction));
if (!buttonAction && this.dropDownActions.length > 0) {
useRouterLink(action: CdTableAction): string {
if (!action.routerLink || this.disableSelectionAction(action)) {
- return;
+ return undefined;
}
return _.isString(action.routerLink) ? action.routerLink : action.routerLink();
}
* @returns {Boolean}
*/
disableSelectionAction(action: CdTableAction): Boolean {
- const permission = action.permission;
const disable = action.disable;
if (disable) {
return Boolean(disable(this.selection));
}
+ const permission = action.permission;
const selected = this.selection.hasSingleSelection && this.selection.first();
return Boolean(
['update', 'delete'].includes(permission) && (!selected || selected.cdExecuting)