131 lines
5.0 KiB
TypeScript
131 lines
5.0 KiB
TypeScript
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: `
|
|
<div *ngIf="pluginObject" class="uk-padding-xsmall">
|
|
<ng-container *ngIf="selectedIndex == -1">
|
|
<plugin-field-edit [value]=" pluginObject.title"
|
|
type="text" field="title" (changed)="valueChanged($event)"></plugin-field-edit>
|
|
|
|
<div class="uk-margin-top uk-text-muted">
|
|
Cards:
|
|
</div>
|
|
|
|
<ng-container *ngFor="let card of pluginObject.cardInfoArray; let i = index">
|
|
<div class="uk-grid uk-grid-small uk-margin-xsmall-top">
|
|
<div *ngIf="selectedIndex != i" class="uk-text-small uk-width-expand">
|
|
<plugin-field-edit [value]=" pluginObject.cardInfoArray[i].show" type="checkbox" field="cardInfoArray"
|
|
(editClicked)="pluginEditEvent = $event"
|
|
(changed)="cardShowChanged(i,$event)"></plugin-field-edit>
|
|
{{card.title}}
|
|
</div>
|
|
|
|
<div class="uk-padding-remove-left uk-margin-medium-right">
|
|
<button
|
|
class="uk-button uk-button-link uk-flex uk-flex-middle" (click)="edit(i)">
|
|
<icon name="edit" [flex]="true"></icon>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
</ng-container>
|
|
</ng-container>
|
|
<ng-container *ngIf="selectedIndex > -1">
|
|
<div *ngIf="editTemplate" class="back uk-margin-bottom">
|
|
<a (click)="close()" class="uk-flex uk-flex-middle uk-flex-center">
|
|
<div class="uk-width-auto">
|
|
<icon name="west" ratio="1.3"
|
|
[flex]="true"></icon>
|
|
</div>
|
|
<span class="uk-text-small">Plugin Options</span>
|
|
</a>
|
|
|
|
</div>
|
|
<!--<div class="uk-text-small">
|
|
Enable
|
|
<plugin-field-edit [value]=" pluginObject.cardInfoArray[selectedIndex].show"
|
|
type="boolean" field="cardInfoArray" (editClicked)="pluginEditEvent = $event"
|
|
(changed)="cardShowChanged(selectedIndex,$event)">
|
|
|
|
</plugin-field-edit>
|
|
</div>-->
|
|
<div class="uk-margin-top">
|
|
<plugin-field-edit [value]="pluginObject.cardInfoArray[selectedIndex].title"
|
|
type="text" field="title"
|
|
(changed)="cardValueChanged(selectedIndex, $event)"></plugin-field-edit>
|
|
</div>
|
|
<div class="uk-margin-top">
|
|
<plugin-field-edit [value]=" pluginObject.cardInfoArray[selectedIndex].description"
|
|
type="text" field="description"
|
|
(changed)="cardValueChanged(selectedIndex, $event)"></plugin-field-edit>
|
|
</div>
|
|
<div class="uk-margin-top">
|
|
<plugin-field-edit [value]=" pluginObject.cardInfoArray[selectedIndex].url"
|
|
type="text" field="url"
|
|
(changed)="cardValueChanged(selectedIndex, $event)"></plugin-field-edit>
|
|
</div>
|
|
<div class="uk-margin-top">
|
|
<plugin-field-edit [value]=" pluginObject.cardInfoArray[selectedIndex].linkText"
|
|
type="text" field="linkText" placeholder="Link text"
|
|
(changed)="cardValueChanged(selectedIndex, $event)"></plugin-field-edit>
|
|
</div>
|
|
</ng-container>
|
|
</div>
|
|
|
|
`,
|
|
|
|
|
|
})
|
|
export class PluginSearchDepositLinkFormComponent extends PluginBaseFormComponent<PluginSearchDepositLink> /*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);
|
|
}
|
|
}
|