import { Component, OnInit, Output, EventEmitter, Input, Host } from '@angular/core';
import { AccordionComponent } from '../accordion.component';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';

@Component({
  selector: 'accordion-tab',
  templateUrl: './accordion-tab.component.html',
  styleUrls: ['./accordion-tab.component.scss'],
})
export class AccordionTabComponent implements OnInit {

  private id: number;
  public show = false;
  public direction = 'ltr';
  @Input() header: string;
  @Input() subHeader: string;
  @Input() cache = true;
  @Input() color = 'primary';
  @Output() selected = new EventEmitter();

  // will be initialized by parent using @ContentChildren
  private accordion: AccordionComponent;
  constructor(
    public ts: TranslatorService
  ) {
  }

  ngOnInit() {
    this.direction = TranslatorService.getCurrentDirection();
  }

  public setVisibility(show: boolean) {
    this.show = show;
  }

  public setAccordion(accordion: AccordionComponent) {
    this.accordion = accordion;
  }

  public onClick() {
    this.setVisibility(!this.show);
    if (this.show) {
      if (this.accordion) {
        this.accordion.tabClicked(this);
      }
    }

  }

}
