import {Component, Input, SimpleChanges} from '@angular/core';
import {PluginSearchDepositLink} from "./plugin-search-deposit-link.component";
import {PluginBaseFormComponent, PluginEditEvent} from "../../utils/base-plugin.form.component";
@Component({
selector: 'plugin-search-deposit-link-form',
template: `
`,
})
export class PluginSearchDepositLinkFormComponent extends PluginBaseFormComponent /*implements OnChanges*/ {
selectedIndex = -1;
@Input() editSubmenuOpen;
constructor() {
super()
}
ngOnChanges(changes: SimpleChanges) {
if (this.editSubmenuOpen == false && this.selectedIndex > -1) {
this.close();
}
}
cardShowChanged(i, $event: PluginEditEvent) {
if (this.editTemplate) {
this.pluginTemplate.object.cardInfoArray[i].show = $event.value;
$event.value = this.pluginTemplate.object.cardInfoArray;
} else {
this.plugin.object.cardInfoArray[i].show = $event.value;
$event.value = this.plugin.object.cardInfoArray;
}
this.valuesChanged.emit({field: $event.field, value: $event.value, type: 'parent'})
}
cardValueChanged(i, $event: PluginEditEvent) {
if (this.editTemplate) {
this.pluginTemplate.object.cardInfoArray[i][$event.field] = $event.value;
$event.value = this.pluginTemplate.object.cardInfoArray;
} else {
this.plugin.object.cardInfoArray[i][$event.field] = $event.value;
$event.value = this.plugin.object.cardInfoArray;
}
this.valuesChanged.emit({field: "cardInfoArray", value: $event.value, type: 'parent'})
}
edit(i) {
this.selectedIndex = i;
this.toggleSubMenu(true);
}
close() {
this.selectedIndex = -1;
this.toggleSubMenu(false);
}
}