Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sweco-sedalh committed Jun 20, 2022
1 parent ce6c91c commit 1f3024c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 40 deletions.
8 changes: 4 additions & 4 deletions src/controls/legend/overlays.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ const Overlays = function Overlays(options) {
const groupName = layer.get('group');
const groupCmp = groupCmps.find((cmp) => cmp.name === groupName);
if (groupName && groupCmp) {
groupCmp.removeOverlay(layerName);
if (emptyGroupCheck(groupName)) {
document.getElementById(groupCmp.getId()).classList.add('hidden');
}
groupCmp.removeOverlay(layerName);
if (emptyGroupCheck(groupName)) {
document.getElementById(groupCmp.getId()).classList.add('hidden');
}
} else {
rootGroup.removeOverlay(layerName);
}
Expand Down
59 changes: 28 additions & 31 deletions src/controls/print/print-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import { downloadPNG, downloadPDF, printToScalePDF } from '../../utils/download'
import { afterRender, beforeRender } from './download-callback';
import maputils from '../../maputils';
import PrintResize from './print-resize';
import { withLoading } from "../../loading";
import { withLoading } from '../../loading';

/** Backup of original OL function */
const original = PluggableMap.prototype.getEventPixel;

Expand Down Expand Up @@ -334,7 +335,7 @@ const PrintComponent = function PrintComponent(options = {}) {
const printToolbar = PrintToolbar();
map.getAllLayers().forEach((l) => {
// if we begin loading any data we want to disable the print buttons...
l.getSource().on(["tileloadstart", "imageloadstart"], () => printToolbar.setDisabled(true));
l.getSource().on(['tileloadstart', 'imageloadstart'], () => printToolbar.setDisabled(true));
});
// ...they then get re-enabled when the map has finished rendering
map.on('rendercomplete', () => printToolbar.setDisabled(false));
Expand Down Expand Up @@ -496,13 +497,11 @@ const PrintComponent = function PrintComponent(options = {}) {
this.getEl().remove();

// GH-1537: remove layers temporarily added for print and unhide layers hidden for print
for (const layer of viewer.getLayersByProperty("added-for-print", true)) {
viewer.removeLayer(layer);
}
for (const layer of viewer.getLayersByProperty("hidden-for-print", true)) {
layer.setVisible(true);
layer.unset("hidden-for-print");
}
viewer.getLayersByProperty('added-for-print', true).forEach((l) => viewer.removeLayer(l));
viewer.getLayersByProperty('hidden-for-print', true).forEach((l) => {
l.setVisible(true);
l.unset('hidden-for-print');
});
// FIXME: attempt to fix rendering after exiting print; doesn't work
viewer.getMap().renderSync();
},
Expand Down Expand Up @@ -551,19 +550,17 @@ const PrintComponent = function PrintComponent(options = {}) {
}
widthImage = orientation === 'portrait' ? Math.round((sizes[size][1] * resolution) / 25.4) : Math.round((sizes[size][0] * resolution) / 25.4);
heightImage = orientation === 'portrait' ? Math.round((sizes[size][0] * resolution) / 25.4) : Math.round((sizes[size][1] * resolution) / 25.4);
await withLoading(() =>
printToScalePDF({
el: pageElement,
filename,
height,
orientation: pdfOrientation,
size,
width,
printScale,
widthImage,
heightImage
})
);
await withLoading(() => printToScalePDF({
el: pageElement,
filename,
height,
orientation: pdfOrientation,
size,
width,
printScale,
widthImage,
heightImage
}));
},
async onRender() {
// Monkey patch OL
Expand All @@ -580,25 +577,25 @@ const PrintComponent = function PrintComponent(options = {}) {
await printMapComponent.addPrintControls();

// GH-1537: temporarily add layers for print and hide their original versions
for (const layer of viewer.getLayersByProperty("printRenderMode", "image")) {
if (layer.getVisible() && !layer.get("added-for-print") && !layer.get("hidden-for-print")) {
viewer.getLayersByProperty('printRenderMode', 'image').forEach((layer) => {
if (layer.getVisible() && !layer.get('added-for-print') && !layer.get('hidden-for-print')) {
// hide the original, tiled, layer
layer.setVisible(false);
layer.set("hidden-for-print", true);
layer.set('hidden-for-print', true);

// create a duplicate of the layer with a different renderMode
const { map, type, name, sourceName, ...properties } = layer.getProperties();
const { map: _, type, name, sourceName, ...properties } = layer.getProperties();
const newLayer = viewer.addLayer({
...properties,
source: sourceName,
renderMode: "image",
type: type === "AGS_TILE" ? "AGS_MAP" : type,
name: name + "-forPrint",
renderMode: 'image',
type: type === 'AGS_TILE' ? 'AGS_MAP' : type,
name: `${name}-forPrint`,
visible: true
}, layer);
newLayer.set("added-for-print", true);
newLayer.set('added-for-print', true);
}
}
});

if (!supressResolutionsRecalculation) {
updateResolutions();
Expand Down
4 changes: 2 additions & 2 deletions src/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
* Show the global loading indicator
*/
export function showLoading() {
document.getElementById("loading").classList.remove("hide");
document.getElementById('loading').classList.remove('hide');
}

/**
* Hide the global loading indicator
*/
export function hideLoading() {
document.getElementById("loading").classList.add("hide");
document.getElementById('loading').classList.add('hide');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export default class Map extends OlMap {
delete mapOptions.layers;

const view = new OlView(options);
super({...mapOptions, view });
super({ ...mapOptions, view });
}
}
}
2 changes: 1 addition & 1 deletion src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ const Viewer = function Viewer(targetOption, options = {}) {
};

const removeLayer = function removeLayer(layer) {
this.dispatch("remove:layer", { layerName: layer.get("name") });
this.dispatch('remove:layer', { layerName: layer.get('name') });
map.removeLayer(layer);
};

Expand Down

0 comments on commit 1f3024c

Please sign in to comment.