]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-checkbox.component.ts
Docs: merge 3.2 release notes
[working/Evergreen.git] / Open-ILS / src / eg2 / src / app / share / grid / grid-toolbar-checkbox.component.ts
1 import {Component, Input, OnInit, Host, TemplateRef} from '@angular/core';
2 import {GridToolbarCheckbox} from './grid';
3 import {GridComponent} from './grid.component';
4
5 @Component({
6   selector: 'eg-grid-toolbar-checkbox',
7   template: '<ng-template></ng-template>'
8 })
9
10 export class GridToolbarCheckboxComponent implements OnInit {
11
12     // Note most input fields should match class fields for GridColumn
13     @Input() label: string;
14
15     // This is an input instead of an Output because the handler is
16     // passed off to the grid context for maintenance -- events
17     // are not fired directly from this component.
18     @Input() onChange: (checked: boolean) => void;
19
20     // get a reference to our container grid.
21     constructor(@Host() private grid: GridComponent) {}
22
23     ngOnInit() {
24
25         if (!this.grid) {
26             console.warn('GridToolbarCheckboxComponent needs a [grid]');
27             return;
28         }
29
30         const cb = new GridToolbarCheckbox();
31         cb.label = this.label;
32         cb.onChange = this.onChange;
33
34         this.grid.context.toolbarCheckboxes.push(cb);
35     }
36 }
37