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

import { Directive, Input, OnInit } from '@angular/core';
import { CommandbarButtonComponent } from './button/commandbar-button.component';

@Directive({
  selector: `[bciCommandbarActionAdd],[bciCommandbarActionEdit],[bciCommandbarActionDelete]`,
})
export class CommandbarButtonsDirective implements OnInit {
  private icon: string;

  constructor(private host: CommandbarButtonComponent) {}

  @Input('bciCommandbarActionAdd')
  set buttonAdd(_) {
    this.setIcon('bosch-ic-add');
  }

  @Input('bciCommandbarActionEdit')
  set buttonEdit(_) {
    this.setIcon('bosch-ic-edit');
  }

  @Input('bciCommandbarActionDelete')
  set buttonDelete(_) {
    this.setIcon('bosch-ic-delete');
  }

  ngOnInit(): void {
    this.host.icon = this.icon;
  }

  private setIcon(icon: string) {
    this.icon = icon;
  }
}
