From 2450d75f704fa2fbbdc47ec54202097a86a98b1d Mon Sep 17 00:00:00 2001 From: Etienne Trimaille Date: Thu, 6 Feb 2025 15:54:41 +0100 Subject: [PATCH] ESLint - Limit lines to 350 --- assets/src/components/SelectionInvert.js | 18 +-- assets/src/components/SelectionTool.js | 157 +++++++++++++++-------- assets/src/modules/Digitizing.js | 4 + eslint.config.mjs | 2 +- tests/end2end/playwright/print.spec.js | 11 +- 5 files changed, 126 insertions(+), 66 deletions(-) diff --git a/assets/src/components/SelectionInvert.js b/assets/src/components/SelectionInvert.js index 17103cf03e..7212c5ab7a 100644 --- a/assets/src/components/SelectionInvert.js +++ b/assets/src/components/SelectionInvert.js @@ -24,14 +24,16 @@ export default class SelectionInvert extends HTMLElement { connectedCallback() { - const isHidden = this.getAttribute('feature-type') && mainLizmap.config.layers[mainLizmap.getLayerNameByCleanName(this.getAttribute('feature-type'))]['selectedFeatures'].length === 0 ? 'hide' : ''; - const isDisabled = this.getAttribute('feature-type') ? mainLizmap.config.layers[mainLizmap.getLayerNameByCleanName(this.getAttribute('feature-type'))]['selectedFeatures'].length === 0 : (mainLizmap.selectionTool.selectedFeaturesCount === 0 || mainLizmap.selectionTool.allFeatureTypeSelected.length > 1); - const mainTemplate = () => html` - `; + const mainTemplate = () => { + const isHidden = this.getAttribute('feature-type') && mainLizmap.config.layers[mainLizmap.getLayerNameByCleanName(this.getAttribute('feature-type'))]['selectedFeatures'].length === 0 ? 'hide' : ''; + const isDisabled = this.getAttribute('feature-type') ? mainLizmap.config.layers[mainLizmap.getLayerNameByCleanName(this.getAttribute('feature-type'))]['selectedFeatures'].length === 0 : (mainLizmap.selectionTool.selectedFeaturesCount === 0 || mainLizmap.selectionTool.allFeatureTypeSelected.length > 1); + return html` + `; + } render(mainTemplate(), this); diff --git a/assets/src/components/SelectionTool.js b/assets/src/components/SelectionTool.js index 8f1a296a22..3d3f3fe76a 100644 --- a/assets/src/components/SelectionTool.js +++ b/assets/src/components/SelectionTool.js @@ -20,85 +20,134 @@ export default class SelectionTool extends HTMLElement { } connectedCallback() { + /** + * @typedef lizDict + */ - const isFilterDisabled = mainLizmap.selectionTool.selectedFeaturesCount === 0 && mainLizmap.selectionTool.filteredFeaturesCount === 0; - const mainTemplate = () => html` -
-

- - - -  ${lizDict['selectiontool.toolbar.title']}  - -

- -
`; + ` + } + + const mainTemplate = () => { + let selectionResult; + if (mainLizmap.selectionTool.selectedFeaturesCount > 1){ + selectionResult = lizDict['selectiontool.results.more'].replace('%s', mainLizmap.selectionTool.selectedFeaturesCount); + } else if (mainLizmap.selectionTool.selectedFeaturesCount === 1) { + selectionResult = lizDict['selectiontool.results.one']; + } else { + selectionResult = lizDict['selectiontool.results.none']; + } + + return html` +
+

+ + + +  ${lizDict['selectiontool.toolbar.title']}  + +

+ +
`; + } render(mainTemplate(), this); diff --git a/assets/src/modules/Digitizing.js b/assets/src/modules/Digitizing.js index 8f8c4c16a7..c5f68ac075 100644 --- a/assets/src/modules/Digitizing.js +++ b/assets/src/modules/Digitizing.js @@ -1182,6 +1182,9 @@ export class Digitizing { `; } + /* eslint-disable @stylistic/js/max-len -- + * Block of XML + **/ const sld = ` @@ -1193,6 +1196,7 @@ export class Digitizing { `; + /* eslint-enable @stylistic/js/max-len */ // Remove indentation to avoid big queries full of unecessary spaces return sld.replace(' ', ''); diff --git a/eslint.config.mjs b/eslint.config.mjs index 97b058ae2f..b6da4a1bbe 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -75,7 +75,7 @@ export default [ } ], "@stylistic/js/max-len": [ - "error", 400, 4], // It's a temporary value, until we fix some. + "error", 350, 4], // It's a temporary value, until we fix some. "no-prototype-builtins": "off", "no-undef": "off", 'jsdoc/require-description': 'warn', diff --git a/tests/end2end/playwright/print.spec.js b/tests/end2end/playwright/print.spec.js index 58bee8edf2..6ad1245505 100644 --- a/tests/end2end/playwright/print.spec.js +++ b/tests/end2end/playwright/print.spec.js @@ -160,8 +160,10 @@ test.describe('Print', () => { // check request getPrintRequest = await getPrintPromise; + /* eslint-disable no-useless-escape, @stylistic/js/max-len -- + * Block of SLD + **/ // Extend and update GetPrint parameters - /* eslint-disable no-useless-escape */ const expectedParameters4 = Object.assign({}, expectedParameters, { 'TEMPLATE': 'print_labels', 'map0:EXTENT': /759249.\d+,6271892.\d+,781949.\d+,6286892.\d+/, @@ -195,6 +197,7 @@ test.describe('Print', () => { // 'multiline_label': 'Multiline label', }) /* eslint-enable no-useless-escape */ + /* eslint-enable @stylistic/js/max-len */ getPrintParams = await expectParametersToContain('Print requests 4', getPrintRequest.postData() ?? '', expectedParameters4) await expect(getPrintParams.size).toBe(17) }); @@ -584,8 +587,10 @@ test.describe('Print 3857', () => { // check request getPrintRequest = await getPrintPromise; + /* eslint-disable no-useless-escape, @stylistic/js/max-len -- + * Block of SLD + **/ // Extend and update GetPrint parameters - /* eslint-disable no-useless-escape */ const expectedParameters3 = Object.assign({}, expectedParameters, { 'map0:EXTENT': /423093.\d+,5399873.\d+,439487.\d+,5410707.\d+/, 'map0:SCALE': '72224', @@ -617,7 +622,7 @@ test.describe('Print 3857', () => { // Disabled because of the migration when project is saved with QGIS >= 3.32 // 'multiline_label': 'Multiline label', }) - /* eslint-enable no-useless-escape */ + /* eslint-enable no-useless-escape, @stylistic/js/max-len */ getPrintParams = await expectParametersToContain('Print requests 3', getPrintRequest.postData() ?? '', expectedParameters3) await expect(getPrintParams.size).toBe(17) });