/* eslint-disable @typescript-eslint/no-empty-function */
/*
 * Copyright (C) 2019-2020 Robert Bosch GmbH Copyright (C) 2019-2020 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { Component } from '@angular/core';
import { Widget } from '../models/widget';
import { WidgetContentComponent } from '../models/widget-content-component';

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

@Component({
  selector: 'bci-text-content',
  template: `
    <div *ngIf="getText().length <= 0"></div>
    <div
      id="content"
      *ngIf="getText().length > 0"
      [ngStyle]="{
        'font-weight': widget.getUserSettingValue('bold') ? 'bolder' : 'normal',
        'font-style': widget.getUserSettingValue('italic') ? 'italic' : 'normal'
      }"
    >
      {{ getText() }}
    </div>
  `,
  styles: [
    `
      #content {
        word-break: break-word;
        font-weight: bold;
      }
    `,
  ],
})
/**
 * Displays the TextWidget
 */
export class TestTextContentComponent implements WidgetContentComponent {
  private _widget: Widget<any, any, any>;

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

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

  /**
   * Gets called, when the grid resize event triggers
   */
  public resize(): void {}

  /**
   * Gets called when a setting changed
   */
  public update(): void {}

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