/*
 * Copyright (C) 2019 Robert Bosch GmbH Copyright (C) 2019 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { Component, HostListener, Inject, OnInit, TemplateRef } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { BciSharedIntl } from '../../../shared-intl';
import { CommandbarInlinefilterComponent } from '../../inlinefilter/commandbar-inlinefilter.component';

@Component({
  selector: 'bci-optionsmenu-dialog',
  templateUrl: './optionsmenu-dialog.component.html',
  styleUrls: ['./optionsmenu-dialog.component.scss'],
})
export class OptionsmenuDialogComponent implements OnInit {
  title: string;
  template: TemplateRef<any>;

  constructor(
    public intl: BciSharedIntl,
    @Inject(MAT_DIALOG_DATA) private data: CommandbarInlinefilterComponent,
    private dialogRef: MatDialogRef<OptionsmenuDialogComponent>
  ) {}

  @HostListener('window:resize')
  onResize() {
    this.close();
  }

  ngOnInit() {
    this.title = this.data.label;
    this.template = this.data.template;
  }

  close() {
    this.dialogRef.close();
  }
}
