]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/eg2/src/app/share/grid/grid-column-config.component.ts
LP 2061136 follow-up: ng lint --fix
[working/Evergreen.git] / Open-ILS / src / eg2 / src / app / share / grid / grid-column-config.component.ts
1 import {Component, Input, OnInit} from '@angular/core';
2 import {Observable} from 'rxjs';
3 import {DialogComponent} from '@eg/share/dialog/dialog.component';
4 import {GridColumn, GridColumnSet, GridContext} from './grid';
5 import {NgbModal, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap';
6
7 @Component({
8     selector: 'eg-grid-column-config',
9     templateUrl: './grid-column-config.component.html'
10 })
11
12 /**
13  */
14 export class GridColumnConfigComponent extends DialogComponent implements OnInit {
15     @Input() gridContext: GridContext;
16     columnSet: GridColumnSet;
17     changesPending = false;
18
19     open(ops: NgbModalOptions): Observable<any> {
20         this.changesPending = false;
21         this.columnSet = this.gridContext.columnSet;
22         return super.open(ops);
23     }
24
25     toggleVisibility(col: GridColumn) {
26         col.visible = !col.visible;
27         this.changesPending = true;
28     }
29
30     // Avoid reloading on each column change and instead reload the
31     // data if needed after all changes are complete.
32     // Override close() so we can reload data if needed.
33     // NOTE: ng-bootstrap v 8.0.0 has a 'closed' emitter, but
34     // we're not there yet.
35     close(value?: any) {
36         if (this.modalRef) { this.modalRef.close(); }
37         this.finalize();
38
39         if (this.changesPending && this.gridContext.reloadOnColumnChange) {
40             this.gridContext.reloadWithoutPagerReset();
41         }
42     }
43 }
44
45