import { Component, Input, Output, EventEmitter } from '@angular/core'; @Component({ selector: 'esp-detailed-accordian', templateUrl: './detailed.accordian.component.html', styleUrls: ['./detailed.accordian.component.scss'], }) export class DetailedAccordianComponent { @Input() config = null; @Output() updatedAccordianConfig: EventEmitter = new EventEmitter(); dropdownSelection(event, additionalArg) { this.handleDropdownEvent(event, additionalArg); } handleDropdownEvent(event, additionalArg) { switch (event.name) { case 'runAsSceanrioRetensionDropdown': { this.config = { ...this.config, settings: this.config.settings.map(setting => setting.name === additionalArg.name ? { ...setting, retention: { ...setting.retention, dropdownValues: setting.retention.dropdownValues.map(dropdown => dropdown.name === event.singleSelectOptions.name ? { ...dropdown, selected: true } : { ...dropdown, selected: false } ), }, } : { ...setting } ), }; this.updatedAccordianConfig.emit(this.config); break; } } } toggleSettingsView() { this.config = { ...this.config, show: !this.config.show, }; this.updatedAccordianConfig.emit(this.config); } toggleCheckboxSelection(setting) { this.config = { ...this.config, settings: this.config.settings.map(oldSetting => oldSetting.name === setting.name ? { ...oldSetting, retention: { ...oldSetting.retention, selected: !oldSetting.retention.selected } } : oldSetting ), }; this.updatedAccordianConfig.emit(this.config); } }