]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-action.component.ts
Docs: merge 3.2 release notes
[working/Evergreen.git] / Open-ILS / src / eg2 / src / app / share / grid / grid-toolbar-action.component.ts
1 import {Component, Input, OnInit, Host, TemplateRef} from '@angular/core';
2 import {GridToolbarAction} from './grid';
3 import {GridComponent} from './grid.component';
4
5 @Component({
6   selector: 'eg-grid-toolbar-action',
7   template: '<ng-template></ng-template>'
8 })
9
10 export class GridToolbarActionComponent implements OnInit {
11
12     // Note most input fields should match class fields for GridColumn
13     @Input() label: string;
14     @Input() action: (rows: any[]) => any;
15
16     // get a reference to our container grid.
17     constructor(@Host() private grid: GridComponent) {}
18
19     ngOnInit() {
20
21         if (!this.grid) {
22             console.warn('GridToolbarActionComponent needs a [grid]');
23             return;
24         }
25
26         const action = new GridToolbarAction();
27         action.label = this.label;
28         action.action = this.action;
29
30         this.grid.context.toolbarActions.push(action);
31     }
32 }
33