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';
8 selector: 'eg-grid-column-config',
9 templateUrl: './grid-column-config.component.html'
14 export class GridColumnConfigComponent extends DialogComponent implements OnInit {
15 @Input() gridContext: GridContext;
16 columnSet: GridColumnSet;
17 changesPending = false;
19 open(ops: NgbModalOptions): Observable<any> {
20 this.changesPending = false;
21 this.columnSet = this.gridContext.columnSet;
22 return super.open(ops);
25 toggleVisibility(col: GridColumn) {
26 col.visible = !col.visible;
27 this.changesPending = true;
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.
36 if (this.modalRef) { this.modalRef.close(); }
39 if (this.changesPending && this.gridContext.reloadOnColumnChange) {
40 this.gridContext.reloadWithoutPagerReset();