From a373357ccf1743db511732539b873b10ff39c3c9 Mon Sep 17 00:00:00 2001 From: argirok Date: Mon, 22 Jan 2024 12:37:48 +0200 Subject: [PATCH] [plugin-functionalities | WIP] : improvements in template forms (options for plugin code, filter pages based on portaltype, prefill plan option, initialize properly object --- .../plugin-openaire-products.component.ts | 2 +- .../components/test/plugin-test.component.ts | 2 +- dashboard/plugins/plugins.component.ts | 4 ++-- .../templates/pluginTemplates.component.html | 6 +++--- .../templates/pluginTemplates.component.ts | 17 +++++++++++++---- utils/entities/adminTool/pluginTemplate.ts | 1 + 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/dashboard/plugins/components/openaireProducts/plugin-openaire-products.component.ts b/dashboard/plugins/components/openaireProducts/plugin-openaire-products.component.ts index df6d312b..a8c5601b 100644 --- a/dashboard/plugins/components/openaireProducts/plugin-openaire-products.component.ts +++ b/dashboard/plugins/components/openaireProducts/plugin-openaire-products.component.ts @@ -81,7 +81,7 @@ export class PluginOpenaireProductsComponent extends PluginBaseComponent{ } ngOnInit(): void { - if(this.pluginTemplate && !this.pluginDefaultObject){ + if(this.pluginTemplate && (!this.pluginDefaultObject || !this.pluginDefaultObject.title)){ this.pluginTemplate.object = new PluginOpenAIREProducts(); } } diff --git a/dashboard/plugins/components/test/plugin-test.component.ts b/dashboard/plugins/components/test/plugin-test.component.ts index 80664fb8..46c3c757 100644 --- a/dashboard/plugins/components/test/plugin-test.component.ts +++ b/dashboard/plugins/components/test/plugin-test.component.ts @@ -63,7 +63,7 @@ export class PluginTestComponent extends PluginBaseComponent{ } ngOnInit(): void { - if(this.pluginTemplate && !this.pluginDefaultObject){ + if(this.pluginTemplate && (!this.pluginDefaultObject || !this.pluginDefaultObject.title)){ this.pluginTemplate.object = new PluginTest(); } } diff --git a/dashboard/plugins/plugins.component.ts b/dashboard/plugins/plugins.component.ts index 8c79435c..698a8b93 100644 --- a/dashboard/plugins/plugins.component.ts +++ b/dashboard/plugins/plugins.component.ts @@ -274,7 +274,7 @@ export class PluginsComponent implements OnInit { active: this._fb.control(plugin.active), isPriorTo: this._fb.control(plugin.priorTo), values: this._fb.array([]), - object: this._fb.group(plugin.object?plugin.object:this.selectedTemplate.object) + object: this._fb.group(plugin.object?plugin.object:(this.selectedTemplate.object?this.selectedTemplate.object:{})) }); if (template.settings) { for (let attrKey of Object.keys(template.settings)) { @@ -310,7 +310,7 @@ export class PluginsComponent implements OnInit { active: this._fb.control(false), isPriorTo: this._fb.control(false), values: this._fb.array([]), - object: this._fb.control(null) + object: this._fb.control({}) }); for (let attrKey of Object.keys(this.selectedTemplate.settings)) { (this.templateForm.get("values") as FormArray).push(this._fb.group({ diff --git a/dashboard/plugins/templates/pluginTemplates.component.html b/dashboard/plugins/templates/pluginTemplates.component.html index 2c7b62b2..28437b1c 100644 --- a/dashboard/plugins/templates/pluginTemplates.component.html +++ b/dashboard/plugins/templates/pluginTemplates.component.html @@ -111,13 +111,13 @@ [okDisabled]="templateForm && (templateForm.invalid || !templateForm.dirty)" classTitle="uk-background-primary uk-light">
-
+
-
+
-
+