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

import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
import { BciSelectChange } from '@bci-web-core/core';
import { ScrollIntoViewService } from '../../shared/scroll-into-view.service';

@Component({
  selector: 'bci-dropdown-beta-demo',
  templateUrl: 'dropdown-beta-demo.html',
  styleUrls: ['dropdown-beta-demo.scss'],
})
export class DropdownBetaDemoComponent {
  inputWidth = '300px';
  notificationTypesRequired = false;
  pokemonRequired = false;
  notificationTypesDisabled = false;
  pokemonDisabled = false;
  currentOption: string;
  currentScrollingOption: string;
  currentScrollingTriggerOption: string;
  currentOptionCustomWidth: string;
  currentNotificationType: string;
  currentPokemon: string[];
  currentPokemonDisabled: string[] = ['Disabled'];
  currentPokemonFromGroup: string;
  currentPokemonFromGroupMultiple: string[];
  currentPokemonFromGroupMultipleScrollAll: string[];
  currentPokemonFromGroupDisabled: string[] = ['Disabled Option'];
  currentDigimon: string;
  digimonRequired = false;
  latestChangeEvent: BciSelectChange;
  floatPlaceholder = 'auto';
  foodControl = new FormControl('pizza-1');
  pokemonTheme = 'primary';

  constructor(public scrollIntoViewService: ScrollIntoViewService) { }

  foods = [
    { value: null, viewValue: 'None' },
    { value: 'steak-0', viewValue: 'Steak' },
    { value: 'pizza-1', viewValue: 'Pizza' },
    { value: 'tacos-2', viewValue: 'Tacos' },
  ];

  notificationTypes = [
    { value: 'info', viewValue: 'Information Type' },
    { value: 'warning', viewValue: 'Warning Type' },
    { value: 'error', viewValue: 'Error Type' },
    { value: 'success', viewValue: 'Success Type' },
  ];

  pokemon = [
    { value: 'bulbasaur-0', viewValue: 'Bulbasaur' },
    { value: 'charizard-1', viewValue: 'Charizard' },
    { value: 'squirtle-2', viewValue: 'Squirtle' },
    { value: 'pikachu-3', viewValue: 'Pikachu' },
    { value: 'eevee-4', viewValue: 'Eevee' },
    { value: 'ditto-5', viewValue: 'Ditto' },
    { value: 'psyduck-6', viewValue: 'Psyduck' },
  ];

  pokemonGroups = [
    {
      name: 'Grass',
      pokemon: [
        { value: 'bulbasaur-0', viewValue: 'Bulbasaur' },
        { value: 'oddish-1', viewValue: 'Oddish' },
        { value: 'bellsprout-2', viewValue: 'Bellsprout' },
      ],
    },
    {
      name: 'Water',
      pokemon: [
        { value: 'squirtle-3', viewValue: 'Squirtle' },
        { value: 'psyduck-4', viewValue: 'Psyduck' },
        { value: 'horsea-5', viewValue: 'Horsea' },
      ],
    },
    {
      name: 'Fire',
      disabled: true,
      pokemon: [
        { value: 'charmander-6', viewValue: 'Charmander' },
        { value: 'vulpix-7', viewValue: 'Vulpix' },
        { value: 'flareon-8', viewValue: 'Flareon' },
      ],
    },
    {
      name: 'Psychic',
      pokemon: [
        { value: 'mew-9', viewValue: 'Mew' },
        { value: 'mewtwo-10', viewValue: 'Mewtwo' },
      ],
    },
  ];

  digimon = [
    { value: 'mihiramon-0', viewValue: 'Mihiramon' },
    { value: 'sandiramon-1', viewValue: 'Sandiramon' },
    { value: 'sinduramon-2', viewValue: 'Sinduramon' },
    { value: 'pajiramon-3', viewValue: 'Pajiramon' },
    { value: 'vajiramon-4', viewValue: 'Vajiramon' },
    { value: 'indramon-5', viewValue: 'Indramon' },
  ];

  switchRequiredNotificationType() {
    this.notificationTypesRequired = !this.notificationTypesRequired;
  }

  switchDisableNotificationType() {
    this.notificationTypesDisabled = !this.notificationTypesDisabled;
  }

  capitalizeFirstLetterOfNotificationType(): string {
    return this.currentNotificationType.charAt(0).toUpperCase() + this.currentNotificationType.slice(1);
  }

  switchRequiredPokemon() {
    this.pokemonRequired = !this.pokemonRequired;
  }

  switchPokemonDisabled() {
    this.pokemonDisabled = !this.pokemonDisabled;
  }

  switchDigimonRequired() {
    this.digimonRequired = !this.digimonRequired;
  }

  toggleDisabled() {
    this.foodControl.enabled ? this.foodControl.disable() : this.foodControl.enable();
  }

  setPokemonValue() {
    this.currentPokemon = ['eevee-4', 'psyduck-6'];
  }
}
