Mercurial > gemma
comparison client/src/components/Pdftool.vue @ 2221:74c7d84f93d7 pdf-export
PDF generation: Don't change template on form changes.
Selecting a template also changes the other form fields to the according values of the template.
The bahavior was the same in the other direction. If you change something in the form, a matching
template was automatically selected. When there is no matching template, no template is selected
which leads to problems in the PDF generation. To make overriding template values possible
without unselecting the current template, this behavior was removed.
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Mon, 11 Feb 2019 10:26:03 +0100 |
parents | d926292d81b6 |
children | 318da99d406a |
comparison
equal
deleted
inserted
replaced
2220:d926292d81b6 | 2221:74c7d84f93d7 |
---|---|
28 > | 28 > |
29 <translate>{{ template.name }}</translate> | 29 <translate>{{ template.name }}</translate> |
30 </option> | 30 </option> |
31 </select> | 31 </select> |
32 <select | 32 <select |
33 @change="compareFormWithTemplates" | |
34 v-model="form.format" | 33 v-model="form.format" |
35 class="form-control form-control-sm d-block mb-2 w-100" | 34 class="form-control form-control-sm d-block mb-2 w-100" |
36 > | 35 > |
37 <option value="landscape"><translate>landscape</translate></option> | 36 <option value="landscape"><translate>landscape</translate></option> |
38 <option value="portrait"><translate>portrait</translate></option> | 37 <option value="portrait"><translate>portrait</translate></option> |
39 </select> | 38 </select> |
40 <div class="d-flex"> | 39 <div class="d-flex"> |
41 <div class="flex-fill mr-2"> | 40 <div class="flex-fill mr-2"> |
42 <select | 41 <select |
43 @change="compareFormWithTemplates" | |
44 v-model="form.resolution" | 42 v-model="form.resolution" |
45 class="form-control form-control-sm mb-2 d-block w-100" | 43 class="form-control form-control-sm mb-2 d-block w-100" |
46 > | 44 > |
47 <option value="80"> | 45 <option value="80"> |
48 <translate>low resolution (80 dpi)</translate> | 46 <translate>low resolution (80 dpi)</translate> |
55 </option> | 53 </option> |
56 </select> | 54 </select> |
57 </div> | 55 </div> |
58 <div class="flex-fill ml-2"> | 56 <div class="flex-fill ml-2"> |
59 <select | 57 <select |
60 @change="compareFormWithTemplates" | |
61 v-model="form.paperSize" | 58 v-model="form.paperSize" |
62 class="form-control form-control-sm mb-2 d-block w-100" | 59 class="form-control form-control-sm mb-2 d-block w-100" |
63 > | 60 > |
64 <option value="a4"><translate>A4</translate></option> | 61 <option value="a4"><translate>A4</translate></option> |
65 <option value="a3"><translate>A3</translate></option> | 62 <option value="a3"><translate>A3</translate></option> |
163 if (this.form.template) { | 160 if (this.form.template) { |
164 this.form.format = this.form.template.properties.format; | 161 this.form.format = this.form.template.properties.format; |
165 this.form.paperSize = this.form.template.properties.paperSize; | 162 this.form.paperSize = this.form.template.properties.paperSize; |
166 this.form.resolution = this.form.template.properties.resolution; | 163 this.form.resolution = this.form.template.properties.resolution; |
167 } | 164 } |
168 }, | |
169 // If there's a template that matches all the form values, this template | |
170 // will be set in the dropdown. | |
171 compareFormWithTemplates() { | |
172 this.form.template = null; | |
173 this.pdfTemplates.forEach(t => { | |
174 if ( | |
175 this.form.format === t.properties.format && | |
176 this.form.paperSize === t.properties.paperSize && | |
177 this.form.resolution === t.properties.resolution | |
178 ) { | |
179 this.form.template = t; | |
180 } | |
181 }); | |
182 }, | 165 }, |
183 download() { | 166 download() { |
184 let template = this.form.template; | 167 let template = this.form.template; |
185 | 168 |
186 // disable button while working on it | 169 // disable button while working on it |