1 import {Component, Input, OnInit, Host} from '@angular/core';
2 import {GridToolbarAction, GridContext} from '@eg/share/grid/grid';
3 import {DialogComponent} from '@eg/share/dialog/dialog.component';
5 /** Allows users to show/hide toolbar action entries */
8 selector: 'eg-grid-toolbar-actions-editor',
9 templateUrl: 'grid-toolbar-actions-editor.component.html'
12 export class GridToolbarActionsEditorComponent extends DialogComponent {
14 @Input() gridContext: GridContext;
16 showHideClicked(action: GridToolbarAction) {
17 action.hidden = !action.hidden;
19 if (!action.group) { return; }
21 // When hiding the last entry in a group, hide the group as well.
23 const group = this.gridContext.toolbarActions
24 .filter(entry => entry.isGroup && entry.label === action.group)[0];
26 const visibles = this.gridContext.toolbarActions
27 .filter(a => a.group === action.group && !a.hidden);
29 group.hidden = visibles.length === 0;