changeset 3841:8e47d6f12998 sld-colors

Merged default into sld-colors branch.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 08 Jul 2019 14:34:42 +0200
parents eb3896cca80a (current diff) 387f239018c7 (diff)
children 40b28a8c0aaa
files
diffstat 2 files changed, 20 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/Pdftool.vue	Fri Jul 05 15:15:59 2019 +0200
+++ b/client/src/components/Pdftool.vue	Mon Jul 08 14:34:42 2019 +0200
@@ -108,12 +108,14 @@
 import { displayError } from "@/lib/errors";
 import { pdfgen, templateLoader } from "@/lib/mixins";
 
-var paperSizes = {
+const paperSizes = {
   // in millimeter, landscape [width, height]
   a3: [420, 297],
   a4: [297, 210]
 };
 
+const DEFAULT_TEMPLATE = "Default";
+
 export default {
   mixins: [pdfgen, templateLoader],
   name: "pdftool",
@@ -128,7 +130,7 @@
       },
       templates: [
         {
-          name: "Default",
+          name: DEFAULT_TEMPLATE,
           properties: {
             format: "landscape",
             paperSize: "a4",
@@ -150,7 +152,7 @@
             },
             {
               type: "northarrow",
-              position: "topright",
+              position: "topleft",
               offset: { x: 6, y: 4 },
               size: 2
             }
@@ -210,20 +212,17 @@
     // When a template is chosen from the dropdown, its propoerties are
     // applied to the rest of the form.
     applyTemplateToForm() {
-      if (this.form.template) {
+      if (this.form.template && this.form.template.name !== DEFAULT_TEMPLATE) {
         this.loadTemplates(
           `/templates/${this.form.template.type}/${this.form.template.name}`
         )
           .then(response => {
             this.prepareImages(response.data.template_data.elements).then(
               values => {
-                this.templateData = response.data.template_data;
                 values.forEach(v => {
                   response.data.template_data.elements[v.index].url = v.url;
                 });
-                this.form.format = this.templateData.properties.format;
-                this.form.paperSize = this.templateData.properties.paperSize;
-                this.form.resolution = this.templateData.properties.resolution;
+                this.setTemplate(response.data.template_data);
               }
             );
           })
@@ -234,8 +233,16 @@
               message: `${status}: ${data.message || data}`
             });
           });
+      } else {
+        this.setTemplate(this.templates[0]);
       }
     },
+    setTemplate(template) {
+      this.templateData = template;
+      this.form.format = this.templateData.properties.format;
+      this.form.paperSize = this.templateData.properties.paperSize;
+      this.form.resolution = this.templateData.properties.resolution;
+    },
     download() {
       // disable button while working on it
       this.readyToGenerate = false;
@@ -803,8 +810,8 @@
     })
       .then(response => {
         if (response.data.length) {
-          this.templates = response.data;
-          this.form.template = this.templates[0];
+          this.templates = [...this.templates, ...response.data];
+          this.form.template = this.templates[1];
           this.applyTemplateToForm();
         } else {
           this.form.template = this.templates[0];
--- a/client/src/components/importconfiguration/ScheduledImports.vue	Fri Jul 05 15:15:59 2019 +0200
+++ b/client/src/components/importconfiguration/ScheduledImports.vue	Mon Jul 08 14:34:42 2019 +0200
@@ -763,7 +763,9 @@
       this.retry =
         this.currentSchedule.trys === null ||
         this.currentSchedule.trys === undefined ||
-        this.currentSchedule === 0 ? false : true;
+        this.currentSchedule === 0
+          ? false
+          : true;
     },
     isWeekly(cron) {
       return /0 \d{1,2} \d{1,2} \* \* \d{1}/.test(cron);