From 4e06e0f9db14ded2c64404ff1bff8a201bc6f02e Mon Sep 17 00:00:00 2001 From: Sebastian Holtkamp Date: Mon, 19 Feb 2024 14:18:39 +0100 Subject: [PATCH 1/4] Fix printing extent and preview handling --- .../dn_printingenhanced/PrintingEnhancedWidget.vue | 9 +++++---- .../dn_printingenhanced/PrintingEnhancedWidgetFactory.js | 4 ++++ .../dn_printingenhanced/PrintingPreviewController.js | 5 +++++ src/main/js/bundles/dn_printingenhanced/manifest.json | 8 ++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidget.vue b/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidget.vue index c990c31..bf1eff2 100644 --- a/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidget.vue +++ b/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidget.vue @@ -244,10 +244,14 @@ }, scaleEnabled: function(scaleEnabled) { if (scaleEnabled === false) { + this.printPreviewInitallyVisible = this.enablePrintPreview; this.enablePrintPreview = false; + this.$emit('resetPrintGeometry'); } if (scaleEnabled && !this.visibleUiElements.printPreviewCheckbox) { - this.enablePrintPreview = this.printPreviewInitallyVisible; + if (this.printPreviewInitallyVisible === true) { + this.enablePrintPreview = this.printPreviewInitallyVisible; + } } } }, @@ -257,9 +261,6 @@ } else { this.activeTab = 0; } - if (!this.visibleUiElements.printPreviewCheckbox) { - this.printPreviewInitallyVisible = this.enablePrintPreview; - } this.$emit('startup'); }, methods: { diff --git a/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidgetFactory.js b/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidgetFactory.js index a848800..5e9889b 100644 --- a/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidgetFactory.js +++ b/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidgetFactory.js @@ -98,6 +98,10 @@ export default class PrintingEnhancedWidgetFactory { vm.$on('resetScale', () => { esriPrintWidget._resetToCurrentScale(); }); + vm.$on('resetPrintGeometry', () => { + esriPrintWidget._resetToCurrentScale(); + this._eventService.postEvent("dn_printingenhanced/RESETPRINTGEOMETRY"); + }); Binding.for(vm, printingPreviewController) .syncAll("enablePrintPreview") diff --git a/src/main/js/bundles/dn_printingenhanced/PrintingPreviewController.js b/src/main/js/bundles/dn_printingenhanced/PrintingPreviewController.js index f443cf5..ec85e44 100644 --- a/src/main/js/bundles/dn_printingenhanced/PrintingPreviewController.js +++ b/src/main/js/bundles/dn_printingenhanced/PrintingPreviewController.js @@ -142,6 +142,11 @@ export default declare({ this._printRotation = this._computeAngle(geometry.rings[0][0], geometry.rings[0][1]); }, + resetPrintGeometry() { + this._printExtent = null; + this._printRotation = null; + }, + setPrintingToggleTool(tool) { this._printingToggleTool = tool; const connect = this[_connect] = new Connect(); diff --git a/src/main/js/bundles/dn_printingenhanced/manifest.json b/src/main/js/bundles/dn_printingenhanced/manifest.json index 8d8baa3..957668f 100644 --- a/src/main/js/bundles/dn_printingenhanced/manifest.json +++ b/src/main/js/bundles/dn_printingenhanced/manifest.json @@ -112,6 +112,10 @@ { "topic": "dn_printingenhanced/PRINTSETTINGS", "method": "setPrintSettings" + }, + { + "topic": "dn_printingenhanced/RESETPRINTGEOMETRY", + "method": "resetPrintGeometry" } ] }, @@ -329,6 +333,10 @@ { "name": "_printingEnhancedProperties", "providing": "dn_printingenhanced.PrintingEnhancedProperties" + }, + { + "name": "_eventService", + "providing": "ct.framework.api.EventService" } ] }, From 820f03df6f8d301a5346027161b627ebd68f0c64 Mon Sep 17 00:00:00 2001 From: Sebastian Holtkamp Date: Mon, 19 Feb 2024 14:32:26 +0100 Subject: [PATCH 2/4] Add mapapps-maven-plugin to plugins --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 64217ac..f5f42c4 100644 --- a/pom.xml +++ b/pom.xml @@ -86,6 +86,11 @@ + + de.conterra.mapapps + mapapps-maven-plugin + ${mapapps.version} + de.conterra.jsregistry ct-jsregistry-maven-plugin From e0d79370a7e8f3dbb2ad645ca89336aca46d6fc7 Mon Sep 17 00:00:00 2001 From: Matthias Stein Date: Wed, 21 Feb 2024 17:53:15 +0100 Subject: [PATCH 3/4] Reformat scaleEnabled watcher code --- .../PrintingEnhancedWidget.vue | 12 ------ .../PrintingEnhancedWidgetFactory.js | 23 +++++++---- .../PrintingPreviewController.js | 41 +++++++++---------- .../bundles/dn_printingenhanced/manifest.json | 8 ---- 4 files changed, 35 insertions(+), 49 deletions(-) diff --git a/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidget.vue b/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidget.vue index bf1eff2..fddb193 100644 --- a/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidget.vue +++ b/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidget.vue @@ -241,18 +241,6 @@ } this.layout = "MAP_ONLY"; } - }, - scaleEnabled: function(scaleEnabled) { - if (scaleEnabled === false) { - this.printPreviewInitallyVisible = this.enablePrintPreview; - this.enablePrintPreview = false; - this.$emit('resetPrintGeometry'); - } - if (scaleEnabled && !this.visibleUiElements.printPreviewCheckbox) { - if (this.printPreviewInitallyVisible === true) { - this.enablePrintPreview = this.printPreviewInitallyVisible; - } - } } }, mounted: function () { diff --git a/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidgetFactory.js b/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidgetFactory.js index 5e9889b..3ebe3a3 100644 --- a/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidgetFactory.js +++ b/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidgetFactory.js @@ -26,7 +26,7 @@ export default class PrintingEnhancedWidgetFactory { } createInstance() { - return new VueDijit(this.vm, {class: "printing-enhanced-widget"}); + return new VueDijit(this.vm, { class: "printing-enhanced-widget" }); } _initComponent() { @@ -88,7 +88,7 @@ export default class PrintingEnhancedWidgetFactory { "legendEnabled": false, "attributionEnabled": false }; - vm.visibleUiElements = {...defaultVisibleUiElements, ...properties.visibleUiElements}; + vm.visibleUiElements = { ...defaultVisibleUiElements, ...properties.visibleUiElements }; vm.dpiValues = properties.dpiValues; vm.scaleValues = properties.scaleValues; // listen to view model methods @@ -98,13 +98,22 @@ export default class PrintingEnhancedWidgetFactory { vm.$on('resetScale', () => { esriPrintWidget._resetToCurrentScale(); }); - vm.$on('resetPrintGeometry', () => { - esriPrintWidget._resetToCurrentScale(); - this._eventService.postEvent("dn_printingenhanced/RESETPRINTGEOMETRY"); - }); Binding.for(vm, printingPreviewController) - .syncAll("enablePrintPreview") + .syncToRight("enablePrintPreview", "drawPrintPreview", (enablePrintPreview) => { + if (enablePrintPreview && vm.scaleEnabled) { + return true; + } else { + return false; + } + }) + .syncToRight("scaleEnabled", "drawPrintPreview", (scaleEnabled) => { + if (scaleEnabled && vm.enablePrintPreview) { + return true; + } else { + return false; + } + }) .enable() .syncToLeftNow(); diff --git a/src/main/js/bundles/dn_printingenhanced/PrintingPreviewController.js b/src/main/js/bundles/dn_printingenhanced/PrintingPreviewController.js index ec85e44..0615b0f 100644 --- a/src/main/js/bundles/dn_printingenhanced/PrintingPreviewController.js +++ b/src/main/js/bundles/dn_printingenhanced/PrintingPreviewController.js @@ -32,14 +32,14 @@ const _view = Symbol("_view"); export default declare({ - enablePrintPreview: false, + drawPrintPreview: false, activate() { const printWidget = this._printingWidget; const esriPrintWidget = printWidget._esriWidget; const printViewModel = esriPrintWidget.viewModel; const properties = this._printingEnhancedProperties._properties; - this.enablePrintPreview = properties.enablePrintPreview; + this.drawPrintPreview = properties.enablePrintPreview && properties.scaleEnabled; // get print infos const url = this[_printServiceUrl] = esriPrintWidget.printServiceUrl; @@ -81,20 +81,22 @@ export default declare({ } } // set sketching properties to view - const view = printViewModel.view; - this._oldRotation = null; - this._oldScale = view.scale; - if (properties.enablePrintPreviewMovement) { - if (this._printExtent) { - view.extent = this._printExtent; - this._oldRotation = view.rotation; - view.rotation = this._printRotation; - } else { - this._oldRotation = view.rotation; - view.rotation = 0; + if(printTemplate.scalePreserved) { + const view = printViewModel.view; + this._oldRotation = null; + this._oldScale = view.scale; + if (properties.enablePrintPreviewMovement) { + if (this._printExtent) { + view.extent = this._printExtent; + this._oldRotation = view.rotation; + view.rotation = this._printRotation; + } else { + this._oldRotation = view.rotation; + view.rotation = 0; + } } + view.scale = printTemplate.outScale; } - view.scale = printTemplate.outScale; }); d_aspect.after(printViewModel, "print", (promise) => { @@ -112,7 +114,7 @@ export default declare({ return promise; }); - this.watch("enablePrintPreview", (args) => { + this.watch("drawPrintPreview", (args) => { this._handleDrawTemplateDimensions(); }); }, @@ -142,11 +144,6 @@ export default declare({ this._printRotation = this._computeAngle(geometry.rings[0][0], geometry.rings[0][1]); }, - resetPrintGeometry() { - this._printExtent = null; - this._printRotation = null; - }, - setPrintingToggleTool(tool) { this._printingToggleTool = tool; const connect = this[_connect] = new Connect(); @@ -226,7 +223,7 @@ export default declare({ const properties = this._printingEnhancedProperties._properties; async(() => { if (((this._printingToggleTool && this._printingToggleTool.active) || - this._printingEnhancedToggleTool.active) && this.enablePrintPreview) { + this._printingEnhancedToggleTool.active) && this.drawPrintPreview) { const geometry = this._printingPreviewDrawer .drawTemplateDimensions(this[_printInfos], this[_templateOptions], properties.defaultPageUnit); if (geometry && zoomTo && this[_templateOptions].scaleEnabled) { @@ -256,7 +253,7 @@ export default declare({ _disablePopups() { const properties = this._printingEnhancedProperties._properties; - if (!this[_view] || !properties.enablePrintPreview) { + if (!this[_view] || !properties.drawPrintPreview) { return; } const view = this[_view]; diff --git a/src/main/js/bundles/dn_printingenhanced/manifest.json b/src/main/js/bundles/dn_printingenhanced/manifest.json index 957668f..8d8baa3 100644 --- a/src/main/js/bundles/dn_printingenhanced/manifest.json +++ b/src/main/js/bundles/dn_printingenhanced/manifest.json @@ -112,10 +112,6 @@ { "topic": "dn_printingenhanced/PRINTSETTINGS", "method": "setPrintSettings" - }, - { - "topic": "dn_printingenhanced/RESETPRINTGEOMETRY", - "method": "resetPrintGeometry" } ] }, @@ -333,10 +329,6 @@ { "name": "_printingEnhancedProperties", "providing": "dn_printingenhanced.PrintingEnhancedProperties" - }, - { - "name": "_eventService", - "providing": "ct.framework.api.EventService" } ] }, From 05ce16f4868b4ab1a596833b69a49bae14cddeeb Mon Sep 17 00:00:00 2001 From: Matthias Stein Date: Wed, 21 Feb 2024 18:14:22 +0100 Subject: [PATCH 4/4] Fix initial enablePrintPreview value --- .../bundles/dn_printingenhanced/PrintingEnhancedWidgetFactory.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidgetFactory.js b/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidgetFactory.js index 3ebe3a3..c3f08ab 100644 --- a/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidgetFactory.js +++ b/src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidgetFactory.js @@ -91,6 +91,7 @@ export default class PrintingEnhancedWidgetFactory { vm.visibleUiElements = { ...defaultVisibleUiElements, ...properties.visibleUiElements }; vm.dpiValues = properties.dpiValues; vm.scaleValues = properties.scaleValues; + vm.enablePrintPreview = properties.enablePrintPreview; // listen to view model methods vm.$on('print', () => { esriPrintWidget._handlePrintMap();