Skip to content

Commit

Permalink
#9823: Fix - [Annotations] Disabled annotations are printed (#9837)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuren1 authored Jan 8, 2024
1 parent f617413 commit 1518651
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
5 changes: 4 additions & 1 deletion web/client/plugins/Print.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -544,14 +544,17 @@ export default {
.filter(layer => layer.group === "background" && layer.visibility && this.isAllowed(layer, projection)));
return !background;
};
filterAnnotationFeaturesByVisibility = (layer) => {
return {...layer, ...(!isNil(layer.features) ? {features: layer.features?.filter(ft => ft?.properties?.visibility)} : {})};
}
filterLayers = (layers, zoom, projection) => {
const resolution = this.getPreviewResolution(zoom, projection);

const filtered = layers.filter((layer) =>
layer.visibility &&
isInsideResolutionsLimits(layer, resolution) &&
this.isAllowed(layer, projection)
);
).map(this.filterAnnotationFeaturesByVisibility);
if (this.isBackgroundIgnored(layers, projection) && this.props.defaultBackground && this.props.printSpec.defaultBackground) {
const defaultBackground = this.getAlternativeBackground(layers, this.props.defaultBackground);
if (defaultBackground) {
Expand Down
37 changes: 37 additions & 0 deletions web/client/plugins/__tests__/Print-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -483,4 +483,41 @@ describe('Print Plugin', () => {
}
});
});
it("print only annotation features that are visible", (done) => {
const layers = [{
features: [
{type: "FeatureCollection", properties: {id: "1", visibility: true}},
{type: "FeatureCollection", properties: {id: "2", visibility: false}}
],
disableResolutionLimits: true,
visibility: true,
type: "vector"
}];
const printingService = {
print() {},
getMapConfiguration() {
return {
layers
};
},
validate() { return {};}
};
const spy = expect.spyOn(printingService, "print");
getPrintPlugin().then(({ Plugin }) => {
try {
ReactDOM.render(<Plugin printingService={printingService}/>, document.getElementById("container"));
const submit = document.getElementsByClassName("print-submit").item(0);
expect(submit).toExist();
submit.click();
setTimeout(() => {
expect(spy.calls.length).toBe(1);
expect(spy.calls[0].arguments[0].layers.length).toBe(1);
expect(spy.calls[0].arguments[0].layers[0].features.length).toBe(1);
done();
}, 0);
} catch (ex) {
done(ex);
}
});
});
});

0 comments on commit 1518651

Please sign in to comment.