From 1f3024c5aa5fa7f07f452c2ec0c871d7fa8708e6 Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Thu, 16 Jun 2022 16:36:32 +0200 Subject: [PATCH] Fix lint issues --- src/controls/legend/overlays.js | 8 ++-- src/controls/print/print-component.js | 59 +++++++++++++-------------- src/loading.js | 4 +- src/map.js | 4 +- src/viewer.js | 2 +- 5 files changed, 37 insertions(+), 40 deletions(-) diff --git a/src/controls/legend/overlays.js b/src/controls/legend/overlays.js index 1550f736a..c8ddaa639 100644 --- a/src/controls/legend/overlays.js +++ b/src/controls/legend/overlays.js @@ -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); } diff --git a/src/controls/print/print-component.js b/src/controls/print/print-component.js index 2d981e93c..9c1bcf3d0 100644 --- a/src/controls/print/print-component.js +++ b/src/controls/print/print-component.js @@ -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; @@ -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)); @@ -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(); }, @@ -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 @@ -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(); diff --git a/src/loading.js b/src/loading.js index 147f8ffcd..5ce0ebd14 100644 --- a/src/loading.js +++ b/src/loading.js @@ -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'); } /** diff --git a/src/map.js b/src/map.js index 05ba68c59..84cdeeb6e 100644 --- a/src/map.js +++ b/src/map.js @@ -9,6 +9,6 @@ export default class Map extends OlMap { delete mapOptions.layers; const view = new OlView(options); - super({...mapOptions, view }); + super({ ...mapOptions, view }); } -} \ No newline at end of file +} diff --git a/src/viewer.js b/src/viewer.js index 2e20b61bf..4aa3dd9dd 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -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); };