import { GridHeaderBar } from './../../resources/elements/grid-header-bar';
import { AuthService } from './../../security/auth-service';
import { autoinject } from 'aurelia-framework';
import { AgGridView } from '../../model/common-model';
import { FloatingBoxViewModel } from './floating-box';
import { Config } from '../../config';
import { AgGridViewList } from './../../resources/elements/ag-grid/ag-grid-views/ag-grid-view-list';

@autoinject
export class AgGridViewBox extends FloatingBoxViewModel {
  private agGridViewList: AgGridViewList;
  private agGridSearch: string;

  constructor(private containerInstance: GridHeaderBar, private authService: AuthService, private config: Config) {
    super('./ag-grid-view-box.html');
  }

  public getTitle(): string {
    return this.containerInstance.i18n.tr('common:grid.savedViews');
  }

  public async activate(config: any): Promise<void> {
    super.activate(config);
  }

  public selectAgGridView(agGridView: AgGridView) {
    this.containerInstance.setAgGridView(agGridView);
    this.close();
  }

  public async addNewView() {
    await this.containerInstance.addAgGridView();
    this.agGridViewList?.viewsConstruct();
  }
}
