]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-actions-menu.component.ts
LP1803787 Grid toolbar actions menu component; cleanup
[working/Evergreen.git] / Open-ILS / src / eg2 / src / app / share / grid / grid-toolbar-actions-menu.component.ts
1 import {Component, Input, OnInit, Host} from '@angular/core';
2 import {GridToolbarAction, GridContext} from '@eg/share/grid/grid';
3
4 /** Models a list of toolbar action menu entries */
5
6 @Component({
7   selector: 'eg-grid-toolbar-actions-menu',
8   templateUrl: 'grid-toolbar-actions-menu.component.html'
9 })
10
11 export class GridToolbarActionsMenuComponent {
12
13     @Input() gridContext: GridContext;
14
15     performAction(action: GridToolbarAction) {
16         if (action.isGroup || action.isSeparator) {
17             return; // These don't perform actions
18         }
19         const rows = this.gridContext.getSelectedRows();
20         action.onClick.emit(rows);
21         if (action.action) { action.action(rows); }
22     }
23
24     shouldDisable(action: GridToolbarAction): boolean {
25         if (action.disableOnRows) {
26             return action.disableOnRows(this.gridContext.getSelectedRows());
27         }
28         return false;
29     }
30 }
31