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

import { Component } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { CustomFormComponent, UserSetting, Widget } from '@bci-web-core/pinboard';

@Component({
  selector: 'bci-my-own-form',
  templateUrl: './my-own-form.component.html',
  styleUrls: ['./my-own-form.component.scss'],
})
/**
 * If you have special requirements for the settings menu, you can create your own forms
 * The formGroup member is the formGroup which contains the general & userSettings
 */
export class MyOwnFormComponent implements CustomFormComponent {
  private _formGroup: FormGroup;
  private _widget: Widget = { isLinkedToFilter: false } as Widget;
  public addChangeEmitter: (ctrl: FormControl, setting: UserSetting | string) => void;

  get formGroup(): FormGroup {
    return this._formGroup;
  }

  set formGroup(frmGroup: FormGroup) {
    this._formGroup = frmGroup;
    console.log('My custom form got this formGroup:', this._formGroup);
  }

  get widget(): Widget {
    return this._widget;
  }

  set widget(widget: Widget) {
    this._widget = widget;
    console.log('My custom form got this widget:', this._widget);
  }
}
