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

import { Component } from '@angular/core';
import { Widget, WidgetContentComponent } from '@bci-web-core/pinboard';

export class TextWidgetUserSetting {
  public bold: boolean;
  public italic: boolean;
  public text: string;
}

@Component({
  selector: 'bci-text-content',
  templateUrl: './text-content.component.html',
  styleUrls: ['./text-content.component.scss'],
})
/**
 * Displays the TextWidget
 */
export class TextContentComponent implements WidgetContentComponent {
  private _widget: Widget<TextContentComponent, TextWidgetUserSetting, any>;

  get widget(): Widget<TextContentComponent, TextWidgetUserSetting, any> {
    return this._widget;
  }

  set widget(widget: Widget<TextContentComponent, TextWidgetUserSetting, any>) {
    this._widget = widget;
  }

  /**
   * Gets called, when the grid resize event triggers
   */
  // eslint-disable-next-line no-empty-function
  public resize(): void {}

  /**
   * Gets called when a setting changed
   */
  // eslint-disable-next-line no-empty-function
  public update(): void {}

  public getText(): string {
    let str: string;
    str = this.widget.getUserSettingValue('text');
    if (!str) {
      str = '';
    }
    return str;
  }
}
