Skip to content

Commit

Permalink
Merge pull request #19 from conterra/bugfix_reset_printpreview
Browse files Browse the repository at this point in the history
Fix printing extent and preview handling
  • Loading branch information
sholtkamp authored Feb 22, 2024
2 parents dda6111 + 05ce16f commit b2f5bfb
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 31 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>de.conterra.mapapps</groupId>
<artifactId>mapapps-maven-plugin</artifactId>
<version>${mapapps.version}</version>
</plugin>
<plugin>
<groupId>de.conterra.jsregistry</groupId>
<artifactId>ct-jsregistry-maven-plugin</artifactId>
Expand Down
11 changes: 0 additions & 11 deletions src/main/js/bundles/dn_printingenhanced/PrintingEnhancedWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,6 @@
}
this.layout = "MAP_ONLY";
}
},
scaleEnabled: function(scaleEnabled) {
if (scaleEnabled === false) {
this.enablePrintPreview = false;
}
if (scaleEnabled && !this.visibleUiElements.printPreviewCheckbox) {
this.enablePrintPreview = this.printPreviewInitallyVisible;
}
}
},
mounted: function () {
Expand All @@ -257,9 +249,6 @@
} else {
this.activeTab = 0;
}
if (!this.visibleUiElements.printPreviewCheckbox) {
this.printPreviewInitallyVisible = this.enablePrintPreview;
}
this.$emit('startup');
},
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -88,9 +88,10 @@ 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;
vm.enablePrintPreview = properties.enablePrintPreview;
// listen to view model methods
vm.$on('print', () => {
esriPrintWidget._handlePrintMap();
Expand All @@ -100,7 +101,20 @@ export default class PrintingEnhancedWidgetFactory {
});

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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) => {
Expand All @@ -112,7 +114,7 @@ export default declare({
return promise;
});

this.watch("enablePrintPreview", (args) => {
this.watch("drawPrintPreview", (args) => {
this._handleDrawTemplateDimensions();
});
},
Expand Down Expand Up @@ -221,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) {
Expand Down Expand Up @@ -251,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];
Expand Down

0 comments on commit b2f5bfb

Please sign in to comment.