From 31b075ea8c6af7a52cb3e5403bc749753cc7fcb0 Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Tue, 25 Oct 2022 15:54:05 +0200 Subject: [PATCH] Fix label preview double refresh and unit issues [SCI-7396] --- .../vue/label_template/components/label_preview.vue | 11 ++++++----- .../vue/repository_print_modal/container.vue | 10 +++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/javascript/vue/label_template/components/label_preview.vue b/app/javascript/vue/label_template/components/label_preview.vue index 4d6112380..4e51c41d3 100644 --- a/app/javascript/vue/label_template/components/label_preview.vue +++ b/app/javascript/vue/label_template/components/label_preview.vue @@ -101,7 +101,7 @@ DPMM_RESOLUTION_OPTIONS, DPI_RESOLUTION_OPTIONS, optionsOpen: false, - width: this.template.attributes.unit == 'in' ? this.template.attributes.width_mm / 25.4 : this.template.attributes.width_mm , + width: this.template.attributes.unit == 'in' ? this.template.attributes.width_mm / 25.4 : this.template.attributes.width_mm, height: this.template.attributes.unit == 'in' ? this.template.attributes.height_mm / 25.4 : this.template.attributes.height_mm, unit: this.template.attributes.unit, density: this.template.attributes.density, @@ -125,19 +125,16 @@ }, watch: { unit() { - this.recalculateUnits(); this.setDefaults(); }, zpl() { this.refreshPreview(); }, template() { + this.unit = this.template.attributes.unit this.width = this.template.attributes.unit == 'in' ? this.template.attributes.width_mm / 25.4 : this.template.attributes.width_mm this.height = this.template.attributes.unit == 'in' ? this.template.attributes.height_mm / 25.4 : this.template.attributes.height_mm - this.unit = this.template.attributes.unit this.density = this.template.attributes.density - - this.refreshPreview() } }, methods: { @@ -159,6 +156,8 @@ refreshPreview() { if (this.zpl.length === 0) return; + this.base64Image = null; + $.ajax({ url: this.previewUrl, type: 'GET', @@ -184,7 +183,9 @@ }); }, updateUnit(unit) { + if (this.unit === unit) return; this.unit = unit; + this.recalculateUnits(); this.$emit('unit:update', this.unit); }, updateDensity(density) { diff --git a/app/javascript/vue/repository_print_modal/container.vue b/app/javascript/vue/repository_print_modal/container.vue index 47d273b85..57dfb279d 100644 --- a/app/javascript/vue/repository_print_modal/container.vue +++ b/app/javascript/vue/repository_print_modal/container.vue @@ -2,7 +2,7 @@