export enum IActionsButtonType {
  SELECT = 'select',
  CHECKBOX = 'checkbox',
  ROTATE = 'rotate',
  CHAT = 'chat',
  BUTTON = 'button',
  DATE = 'date'
}

export interface IActionsButton {
  name: string;
  range: string;
  defaultValue: string;
  type: IActionsButtonType;
  options: string[];
  users: IActionsButtonUser[];
  checkboxTrueValue: any;
  checkboxFalseValue: any;
  checkboxToggle: string;
  componentPlugin: string;
  parse(data: any): void;
  [key: string]: any;
}

export interface IActionsButtonUser {
  name: string;
  id: string;
}

export class Button implements IActionsButton {
  public name: string = '';
  public range: string = '';
  public defaultValue: string = '';
  public type: IActionsButtonType = IActionsButtonType.BUTTON;
  public options: string[] = [];
  public users: IActionsButtonUser[] = [];
  public checkboxTrueValue: any = '';
  public checkboxFalseValue: any = '';
  public checkboxToggle: string = '';
  public dateValueFormat: string = 'YYYY-MM-DD';
  public dateDisplayFormat: string = 'YYYY-MM-DD';
  public componentPlugin: string = '';
  constructor(data?: any) {
    this.parse(data || {});
  }
  public parse(data: any): void {
    [
      'type',
      'name',
      'defaultValue',
      'range',
      'options',
      'users',
      'checkboxTrueValue',
      'checkboxFalseValue',
      'checkboxToggle',
      'dateValueFormat',
      'dateDisplayFormat',
      'componentPlugin'
    ].forEach(key => {
      if (!data[key]) return;
      (<IActionsButton>this)[key] = data[key];
    });
  }
}
