2023-09-25 10:36:05 +02:00
|
|
|
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
|
|
|
import {ActivatedRoute, Router} from "@angular/router";
|
|
|
|
import {HelpContentService} from "../../../services/help-content.service";
|
2024-02-22 10:09:20 +01:00
|
|
|
import {FormArray, FormGroup, UntypedFormBuilder, UntypedFormGroup, ValidatorFn, Validators} from "@angular/forms";
|
2023-09-25 10:36:05 +02:00
|
|
|
import {Page} from "../../../utils/entities/adminTool/page";
|
|
|
|
import {EnvProperties} from '../../../utils/properties/env-properties';
|
|
|
|
import {HelperFunctions} from "../../../utils/HelperFunctions.class";
|
|
|
|
import {Subscriber} from "rxjs";
|
|
|
|
import {properties} from "../../../../../environments/environment";
|
|
|
|
import {PortalUtils} from "../../portal/portalHelper";
|
|
|
|
import {AlertModal} from "../../../utils/modal/alert";
|
|
|
|
import {Option} from "../../../sharedComponents/input/input.component";
|
|
|
|
import {Title} from "@angular/platform-browser";
|
|
|
|
import {ClearCacheService} from "../../../services/clear-cache.service";
|
|
|
|
import {NotificationHandler} from "../../../utils/notification-handler";
|
|
|
|
import {PluginsService} from "../../../services/plugins.service";
|
|
|
|
import {PluginTemplate} from "../../../utils/entities/adminTool/pluginTemplate";
|
|
|
|
import {StringUtils} from "../../../utils/string-utils.class";
|
2024-02-02 08:33:01 +01:00
|
|
|
import {PluginUtils} from "../utils/pluginUtils";
|
2024-02-28 12:07:31 +01:00
|
|
|
import {PluginEditEvent} from "../utils/base-plugin.form.component";
|
2023-09-25 10:36:05 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'plugin-templates',
|
|
|
|
templateUrl: './pluginTemplates.component.html',
|
|
|
|
})
|
|
|
|
export class PluginTemplatesComponent implements OnInit {
|
|
|
|
@ViewChild('editModal') editModal: AlertModal;
|
|
|
|
@ViewChild('deleteModal') deleteModal: AlertModal;
|
2024-02-02 08:33:01 +01:00
|
|
|
public templatesByPlacement: Map<string,PluginTemplate[]> = new Map();
|
2023-09-25 10:36:05 +02:00
|
|
|
public templateForm: UntypedFormGroup;
|
|
|
|
urlValidator: ValidatorFn = StringUtils.urlValidator;
|
|
|
|
private searchText: RegExp = new RegExp('');
|
|
|
|
public keyword: string = "";
|
|
|
|
public properties: EnvProperties = properties;
|
|
|
|
public formPages: Page[] = [];
|
|
|
|
public showLoading: boolean = true;
|
|
|
|
public filterForm: UntypedFormGroup;
|
|
|
|
private subscriptions: any[] = [];
|
|
|
|
public allPages: Option[] = [];
|
2024-02-02 08:33:01 +01:00
|
|
|
public allPagesByPortal: Map<string, Option[]> = new Map();
|
|
|
|
public pluginUtils = new PluginUtils();
|
2023-09-25 10:36:05 +02:00
|
|
|
public portalUtils: PortalUtils = new PortalUtils();
|
2024-02-02 08:33:01 +01:00
|
|
|
private selectedTemplate: PluginTemplate;
|
|
|
|
public selectedPageId: string;
|
|
|
|
public selectedPortalPid: string;
|
|
|
|
public page: Page;
|
2024-02-28 12:07:31 +01:00
|
|
|
editSubmenuOpen = false;
|
2023-09-25 10:36:05 +02:00
|
|
|
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router,
|
2024-02-02 08:33:01 +01:00
|
|
|
private title: Title, private _helpContentService: HelpContentService,
|
2023-09-25 10:36:05 +02:00
|
|
|
private _pluginsService: PluginsService, private _fb: UntypedFormBuilder,
|
|
|
|
private _clearCacheService: ClearCacheService) {
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
ngOnInit() {
|
|
|
|
this.title.setTitle('Administrator Dashboard | Classes');
|
|
|
|
this.filterForm = this._fb.group({
|
|
|
|
keyword: [''],
|
2024-02-02 08:33:01 +01:00
|
|
|
position: ['all', Validators.required]
|
2023-09-25 10:36:05 +02:00
|
|
|
});
|
|
|
|
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
|
|
|
|
this.searchText = new RegExp(value, 'i');
|
|
|
|
}));
|
2023-10-17 08:20:16 +02:00
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
|
|
|
HelperFunctions.scroll();
|
2024-02-02 08:33:01 +01:00
|
|
|
this.selectedPageId = params['pageId'];
|
|
|
|
this.selectedPortalPid = params['portalPid'];
|
|
|
|
if (this.selectedPageId) {
|
|
|
|
this.getPage(this.selectedPageId);
|
|
|
|
this.getTemplates(this.selectedPageId);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
this.getPages();
|
|
|
|
this.getTemplates();
|
|
|
|
|
|
|
|
}
|
2023-09-25 10:36:05 +02:00
|
|
|
}));
|
2024-02-02 08:33:01 +01:00
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
ngOnDestroy(): void {
|
|
|
|
this.subscriptions.forEach(value => {
|
|
|
|
if (value instanceof Subscriber) {
|
|
|
|
value.unsubscribe();
|
|
|
|
} else if (value instanceof Function) {
|
|
|
|
value();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
|
|
|
getPage(pageId: string) {
|
2023-09-25 10:36:05 +02:00
|
|
|
this.showLoading = true;
|
2024-02-02 08:33:01 +01:00
|
|
|
this.subscriptions.push(this._helpContentService.getPageById(pageId, this.properties.adminToolsAPIURL).subscribe(
|
|
|
|
page => {
|
|
|
|
this.page = page;
|
|
|
|
this.allPages = [];
|
|
|
|
this.allPagesByPortal = new Map();
|
|
|
|
let option = {
|
|
|
|
label: page.name + " [" + page.portalType + "]",
|
|
|
|
value: page
|
|
|
|
};
|
|
|
|
this.allPages.push(option);
|
|
|
|
this.allPagesByPortal.set(page.portalType, [])
|
|
|
|
this.allPagesByPortal.get(page.portalType).push(option)
|
|
|
|
},
|
|
|
|
error => this.handleError('System error retrieving page', error)));
|
|
|
|
}
|
|
|
|
|
|
|
|
getTemplates(pageId = null) {
|
|
|
|
this.showLoading = true;
|
|
|
|
this.subscriptions.push(this._pluginsService.getPluginTemplates(this.properties.adminToolsAPIURL, pageId).subscribe(
|
2023-09-25 10:36:05 +02:00
|
|
|
templates => {
|
2024-02-02 08:33:01 +01:00
|
|
|
for(let pos of this.pluginUtils.placementsOptions){
|
|
|
|
this.templatesByPlacement.set(pos.value,[]);
|
|
|
|
}
|
|
|
|
for(let template of templates){
|
2024-02-28 12:07:31 +01:00
|
|
|
template.object = PluginUtils.initializeObjectAndCompare(template.code,template.object)
|
2024-02-02 08:33:01 +01:00
|
|
|
this.templatesByPlacement.get(template.placement).push(template);
|
|
|
|
}
|
2023-09-25 10:36:05 +02:00
|
|
|
let self = this;
|
|
|
|
this.showLoading = false;
|
|
|
|
},
|
|
|
|
error => this.handleError('System error retrieving classes', error)));
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
|
|
|
private deleteFromArray(template:PluginTemplate): void {
|
2023-09-25 10:36:05 +02:00
|
|
|
|
2024-02-02 08:33:01 +01:00
|
|
|
let i = this.templatesByPlacement.get(template.placement).findIndex(_ => _._id == template._id);
|
|
|
|
this.templatesByPlacement.get(template.placement).splice(i, 1);
|
2023-09-25 10:36:05 +02:00
|
|
|
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
|
|
|
public confirmDelete(template:PluginTemplate) {
|
|
|
|
this.selectedTemplate = template;
|
2023-09-25 10:36:05 +02:00
|
|
|
this.confirmModalOpen();
|
|
|
|
}
|
|
|
|
|
2024-02-02 08:33:01 +01:00
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
private confirmModalOpen() {
|
|
|
|
this.deleteModal.alertTitle = "Delete Confirmation";
|
|
|
|
this.deleteModal.message = "Are you sure you want to delete the selected template(s)?";
|
|
|
|
this.deleteModal.okButtonText = "Yes";
|
|
|
|
this.deleteModal.open();
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
public confirmedDelete() {
|
|
|
|
this.showLoading = true;
|
2024-02-02 08:33:01 +01:00
|
|
|
this.subscriptions.push(this._pluginsService.deletePluginTemplate(this.selectedTemplate._id, this.properties.adminToolsAPIURL).subscribe(
|
2023-09-25 10:36:05 +02:00
|
|
|
_ => {
|
2024-02-02 08:33:01 +01:00
|
|
|
this.deleteFromArray(this.selectedTemplate);
|
2023-09-25 10:36:05 +02:00
|
|
|
NotificationHandler.rise('Template have been <b>successfully deleted</b>');
|
|
|
|
this.showLoading = false;
|
|
|
|
this._clearCacheService.clearCache("Template id deleted");
|
|
|
|
},
|
|
|
|
error => this.handleUpdateError('System error deleting the selected Template', error)
|
|
|
|
));
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
|
|
|
public edit(pluginTemplate) {
|
2024-02-28 12:07:31 +01:00
|
|
|
this.selectedTemplate = JSON.parse(JSON.stringify(pluginTemplate)); // deep copy object with nested objects
|
2023-09-25 10:36:05 +02:00
|
|
|
this.templateForm = this._fb.group({
|
|
|
|
_id: this._fb.control(pluginTemplate._id),
|
2024-02-02 08:33:01 +01:00
|
|
|
name: this._fb.control(pluginTemplate.name),
|
|
|
|
page: this._fb.control(this.getPageById(pluginTemplate.page)),
|
2023-09-25 10:36:05 +02:00
|
|
|
portalType: this._fb.control(pluginTemplate.portalType, Validators.required),
|
|
|
|
|
|
|
|
code: this._fb.control(pluginTemplate.code, Validators.required),
|
|
|
|
description: this._fb.control(pluginTemplate.description),
|
2024-01-22 11:37:48 +01:00
|
|
|
plan: this._fb.control(pluginTemplate.plan, Validators.required),
|
2024-02-22 10:09:20 +01:00
|
|
|
placement: this._fb.control(pluginTemplate.placement, Validators.required),
|
2024-02-02 08:33:01 +01:00
|
|
|
order: this._fb.control(pluginTemplate.order),
|
2024-02-22 10:09:20 +01:00
|
|
|
portalSpecific: this._fb.control(pluginTemplate.portalSpecific?pluginTemplate.portalSpecific.join(','):''),
|
|
|
|
defaultIsActive: this._fb.control(pluginTemplate.defaultIsActive),
|
2024-02-02 08:33:01 +01:00
|
|
|
settings: this._fb.array([]),
|
2023-09-25 10:36:05 +02:00
|
|
|
});
|
|
|
|
this.templateForm.get('portalType').disable();
|
2024-02-02 08:33:01 +01:00
|
|
|
if (pluginTemplate.settings) {
|
2024-01-19 09:53:17 +01:00
|
|
|
for (let attrKey of Object.keys(pluginTemplate.settings)) {
|
|
|
|
(this.templateForm.get("settings") as FormArray).push(this._fb.group({
|
2023-09-25 10:36:05 +02:00
|
|
|
key: this._fb.control(attrKey, Validators.required),
|
2024-01-19 09:53:17 +01:00
|
|
|
name: this._fb.control(pluginTemplate.settings[attrKey].name, Validators.required),
|
|
|
|
type: this._fb.control(pluginTemplate.settings[attrKey].type, Validators.required),
|
|
|
|
value: this._fb.control(pluginTemplate.settings[attrKey].value)
|
2023-09-25 10:36:05 +02:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.modalOpen("Edit Template", "Save Changes");
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
public newPlugin() {
|
2024-02-02 08:33:01 +01:00
|
|
|
this.selectedTemplate = null;
|
2023-09-25 10:36:05 +02:00
|
|
|
if (this.templateForm) {
|
|
|
|
this.templateForm.get('portalType').enable();
|
|
|
|
}
|
|
|
|
this.templateForm = this._fb.group({
|
|
|
|
_id: this._fb.control(null),
|
2024-02-02 08:33:01 +01:00
|
|
|
name: this._fb.control(''),
|
2023-09-26 16:32:27 +02:00
|
|
|
code: this._fb.control('', Validators.required),
|
2024-01-22 11:37:48 +01:00
|
|
|
plan: this._fb.control('starter', Validators.required),
|
2023-09-26 16:32:27 +02:00
|
|
|
description: this._fb.control(''),
|
2024-02-02 08:33:01 +01:00
|
|
|
page: this._fb.control(this.page?this.getPageById(this.page):'', Validators.required),
|
2023-09-25 10:36:05 +02:00
|
|
|
portalType: this._fb.control('community', Validators.required),
|
2024-02-28 12:07:31 +01:00
|
|
|
placement: this._fb.control('top', Validators.required),
|
2024-02-02 08:33:01 +01:00
|
|
|
order: this._fb.control(''),
|
2024-02-22 10:09:20 +01:00
|
|
|
portalSpecific: this._fb.control(''),
|
|
|
|
defaultIsActive: this._fb.control(false),
|
2024-02-02 08:33:01 +01:00
|
|
|
settings: this._fb.array([]),
|
2024-01-22 11:37:48 +01:00
|
|
|
object: this._fb.control({})
|
2023-09-25 10:36:05 +02:00
|
|
|
});
|
2024-02-02 08:33:01 +01:00
|
|
|
// this.addNewAttr();
|
2023-09-25 10:36:05 +02:00
|
|
|
this.modalOpen("Create template", "Create");
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
private modalOpen(title: string, yesBtn: string) {
|
|
|
|
this.editModal.okButtonLeft = false;
|
|
|
|
this.editModal.alertTitle = title;
|
|
|
|
this.editModal.okButtonText = yesBtn;
|
|
|
|
this.editModal.open();
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
|
|
|
public swap(templateToMoveUp, templateToMoveDown, placement) {
|
|
|
|
|
|
|
|
this.move(this.templatesByPlacement.get(placement)[templateToMoveUp], true);
|
|
|
|
this.move(this.templatesByPlacement.get(placement)[templateToMoveDown], false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public move(template: PluginTemplate, up: boolean) {
|
|
|
|
this.showLoading = true;
|
|
|
|
this.subscriptions.push(this._pluginsService.updatePluginTemplateOrder(template, this.properties.adminToolsAPIURL, up ? -1 : 1).subscribe(
|
|
|
|
saved => {
|
|
|
|
this.savedSuccessfully(saved, true);
|
|
|
|
|
|
|
|
this._clearCacheService.clearCache("Template updates");
|
|
|
|
},
|
|
|
|
error => this.handleUpdateError("System error creating template", error)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
public saveConfirmed(data: any) {
|
|
|
|
this.showLoading = true;
|
2024-02-02 08:33:01 +01:00
|
|
|
let template: PluginTemplate = <PluginTemplate>this.templateForm.getRawValue();
|
|
|
|
template.page = this.templateForm.getRawValue().page._id
|
2024-02-22 10:09:20 +01:00
|
|
|
template.portalSpecific = this.templateForm.getRawValue().portalSpecific.length > 0? this.templateForm.getRawValue().portalSpecific.split(','):[];
|
2024-02-28 12:07:31 +01:00
|
|
|
template.object = this.selectedTemplate?this.selectedTemplate.object:PluginUtils.initializeObjectAndCompare(template.code);
|
2024-02-02 08:33:01 +01:00
|
|
|
template.settings = new Map<string, { name: string; type: string; value: string }>();
|
2024-02-28 12:07:31 +01:00
|
|
|
this.editSubmenuOpen = false;
|
2024-02-02 08:33:01 +01:00
|
|
|
if(!template._id){
|
|
|
|
template.order = this.templatesByPlacement.get(template.placement).length > 0 ? this.templatesByPlacement.get(template.placement).length:0;
|
|
|
|
}
|
2024-01-19 09:53:17 +01:00
|
|
|
for (let attr of this.templateForm.getRawValue().settings) {
|
2024-02-02 08:33:01 +01:00
|
|
|
template.settings[attr.key] = {name: attr.name, type: attr.type, value: attr.value};
|
2023-09-25 10:36:05 +02:00
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
let update = template._id ? true : false;
|
|
|
|
this.subscriptions.push(this._pluginsService.savePluginTemplate(template, this.properties.adminToolsAPIURL).subscribe(
|
|
|
|
saved => {
|
|
|
|
this.selectedTemplate = saved;
|
|
|
|
this.savedSuccessfully(saved, update);
|
|
|
|
NotificationHandler.rise('Template <b>' + saved.name + '</b> has been <b>successfully' + (update ? ' updated ' : ' created ') + '</b>');
|
|
|
|
this._clearCacheService.clearCache("Template id saved");
|
|
|
|
},
|
|
|
|
error => this.handleUpdateError("System error creating template", error)
|
|
|
|
));
|
2023-09-25 10:36:05 +02:00
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
|
|
|
public savedSuccessfully(template: PluginTemplate, update: boolean) {
|
|
|
|
if (update) {
|
|
|
|
let index = this.templatesByPlacement.get(this.selectedTemplate.placement).findIndex(value => value._id === template._id);
|
|
|
|
this.templatesByPlacement.get(this.selectedTemplate.placement)[index] = template;
|
|
|
|
// TODO sort
|
|
|
|
// this.templatesByPlacement.get(this.selectedTemplate.placement) = this.templatesByPlacement.get(this.selectedTemplate.placement).sort()
|
|
|
|
} else {
|
2024-02-28 12:07:31 +01:00
|
|
|
template.object = PluginUtils.initializeObjectAndCompare(template.code, template.object)
|
2024-02-02 08:33:01 +01:00
|
|
|
this.templatesByPlacement.get(this.selectedTemplate.placement).push(template);
|
2023-09-25 10:36:05 +02:00
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
this.showLoading = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public filter(plugin: PluginTemplate): boolean {
|
|
|
|
return this.searchText.toString() == '' || (plugin.name + ' ' + plugin.portalType).match(this.searchText) != null;
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
handleUpdateError(message: string, error = null) {
|
|
|
|
if (error) {
|
|
|
|
console.log('Server responded: ' + error);
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
NotificationHandler.rise(message, 'danger');
|
2023-09-25 10:36:05 +02:00
|
|
|
this.showLoading = false;
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
handleError(message: string, error = null) {
|
|
|
|
if (error) {
|
|
|
|
console.log('Server responded: ' + error);
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
NotificationHandler.rise(message, 'danger');
|
2023-09-25 10:36:05 +02:00
|
|
|
this.showLoading = false;
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
getPages() {
|
|
|
|
this.showLoading = true;
|
|
|
|
this.subscriptions.push(this._helpContentService.getAllPages(this.properties.adminToolsAPIURL).subscribe(
|
|
|
|
pages => {
|
|
|
|
this.allPages = [];
|
2024-02-02 08:33:01 +01:00
|
|
|
this.allPagesByPortal = new Map();
|
2023-09-25 10:36:05 +02:00
|
|
|
pages.forEach(page => {
|
2024-02-02 08:33:01 +01:00
|
|
|
let option = {
|
2023-09-25 10:36:05 +02:00
|
|
|
label: page.name + " [" + page.portalType + "]",
|
|
|
|
value: page
|
2024-02-02 08:33:01 +01:00
|
|
|
};
|
|
|
|
this.allPages.push(option);
|
|
|
|
if (!this.allPagesByPortal.has(page.portalType)) {
|
|
|
|
this.allPagesByPortal.set(page.portalType, [])
|
|
|
|
}
|
|
|
|
this.allPagesByPortal.get(page.portalType).push(option)
|
2023-09-25 10:36:05 +02:00
|
|
|
});
|
|
|
|
this.showLoading = false;
|
|
|
|
},
|
|
|
|
error => this.handleError('System error retrieving pages', error)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2024-02-02 08:33:01 +01:00
|
|
|
addNewAttr() {
|
2024-01-19 09:53:17 +01:00
|
|
|
(this.templateForm.get("settings") as FormArray).push(this._fb.group({
|
2024-02-02 08:33:01 +01:00
|
|
|
key: this._fb.control("", Validators.required),
|
2023-09-25 10:36:05 +02:00
|
|
|
name: this._fb.control("", Validators.required),
|
|
|
|
type: this._fb.control("text", Validators.required),
|
|
|
|
value: this._fb.control("")
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2024-02-02 08:33:01 +01:00
|
|
|
removeAttr(index) {
|
2023-09-25 10:36:05 +02:00
|
|
|
this.attrFormArray.removeAt(index);
|
|
|
|
this.attrFormArray.markAsDirty();
|
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
|
|
|
get attrFormArray() {
|
2023-09-25 10:36:05 +02:00
|
|
|
|
2024-01-19 09:53:17 +01:00
|
|
|
return this.templateForm.get("settings") as FormArray;
|
2023-09-25 10:36:05 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-02-02 08:33:01 +01:00
|
|
|
attributeTypeChanged(form) {
|
2023-09-25 10:36:05 +02:00
|
|
|
let type = form.get("value").get("type");
|
|
|
|
form.get("value").setValue("");
|
2024-02-02 08:33:01 +01:00
|
|
|
if (type == "boolean") {
|
2023-09-25 10:36:05 +02:00
|
|
|
form.get("value").setValue(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-02 08:33:01 +01:00
|
|
|
public getPageAsString(pageId): string {
|
|
|
|
return this.allPages.filter(option => option.value._id == pageId).map((option => option.value.name + " [" + option.value.portalType + "]")).join(",");
|
2023-09-25 10:36:05 +02:00
|
|
|
}
|
2024-02-02 08:33:01 +01:00
|
|
|
|
2023-09-25 10:36:05 +02:00
|
|
|
public getPageById(pageId) {
|
2024-02-02 08:33:01 +01:00
|
|
|
for (let option of this.allPages) {
|
|
|
|
if (option.value._id == pageId) {
|
2023-09-25 10:36:05 +02:00
|
|
|
return option.value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pageId;
|
|
|
|
}
|
2024-01-19 09:53:17 +01:00
|
|
|
|
2024-02-22 10:09:20 +01:00
|
|
|
|
|
|
|
pluginFieldChanged($event:PluginEditEvent){
|
2024-02-28 12:07:31 +01:00
|
|
|
if($event.type == "open-submenu"){
|
|
|
|
this.editSubmenuOpen = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if($event.type == "close-submenu"){
|
2024-02-22 10:09:20 +01:00
|
|
|
|
2024-02-28 12:07:31 +01:00
|
|
|
this.editSubmenuOpen = false;
|
|
|
|
return;
|
2024-02-22 10:09:20 +01:00
|
|
|
}
|
2024-02-28 12:07:31 +01:00
|
|
|
this.selectedTemplate.object[$event.field]=$event.value;
|
2024-01-19 09:53:17 +01:00
|
|
|
this.templateForm.markAsDirty();
|
|
|
|
}
|
2024-01-22 11:37:48 +01:00
|
|
|
public getPagesByPortal(portal) {
|
2024-02-02 08:33:01 +01:00
|
|
|
return this.allPages.filter(option => option.value.portalType == portal);
|
2024-01-22 11:37:48 +01:00
|
|
|
}
|
2023-09-25 10:36:05 +02:00
|
|
|
}
|