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

import { Highlightable } from '@angular/cdk/a11y';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { BciSharedIntl } from '../../shared-intl';

@Component({
  selector: 'bci-filter-entry',
  templateUrl: './filter-entry.component.html',
  styleUrls: ['./filter-entry.component.scss'],
})
export class FilterEntryComponent implements Highlightable {
  /**
   * The title of the filter entry.
   */
  @Input()
  public filterTitle: string;

  /**
   * The subtitle of the filter entry, e.g. to display the current filter value.
   */
  @Input()
  public filterSubTitle: string;

  /**
   * Whether the filter entry is selected or not.
   */
  @Input()
  public isSelected: boolean;

  /**
   * Whether the filter entry is activated or not.
   */
  @Input()
  public isActive: boolean;

  /**
   * Whether the filter entry has a submenu, which should be indicated visually.
   * **/
  @Input()
  public hasSubmenu = false;

  /**
   * Event emitter for when the filter entry is selected.
   */
  @Output()
  // eslint-disable-next-line @angular-eslint/no-output-native
  public select: EventEmitter<string> = new EventEmitter<string>();

  /**
   * Event emitter for when the filter entry is deactivated.
   */
  @Output()
  public deactivate: EventEmitter<string> = new EventEmitter<string>();

  constructor(public intl: BciSharedIntl) {}

  setActiveStyles() {
    this.select.emit(this.filterTitle);
  }

  setInactiveStyles() {
    this.isSelected = false;
  }

  getLabel() {
    return this.filterTitle;
  }

  showFilterDetails() {
    this.select.emit(this.filterTitle);
  }

  deactivateFilter() {
    this.deactivate.emit(this.filterTitle);
  }
}
