/*
 * Copyright (C) 2023 Robert Bosch GmbH Copyright (C) 2023 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { fruits, Fruit } from '../bci-core-picklist-demo-model';
@Component({
  selector: 'bci-custom-picklist-dialog',
  templateUrl: './custom-picklist-dialog.component.html',
  styleUrls: ['./custom-picklist-dialog.component.scss'],
})
export class CustomPicklistDialogComponent {
  fruits = fruits;
  /**
   * Display property name of objects in list of fruits. Note that the display property will be ignored if a custom item template is set.
   * However, setting the source item template will not set the target item template because the item lists do not share templates.
   */
  displayProperty = 'name';

  selectedFruits: Fruit[];
  constructor(
    private _matDialogRef: MatDialogRef<CustomPicklistDialogComponent>,
    @Inject(MAT_DIALOG_DATA) public data: any
  ) {}
  public closeDialog() {
    this._matDialogRef.close(this.selectedFruits);
  }

  saveChanges(event) {
    this.selectedFruits = event;
  }
}