Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit line length to 400 in JS #5362

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion assets/src/components/Digitizing.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,25 @@ export default class Digitizing extends HTMLElement {
render(mainTemplate(), this);
}
},
['digitizing.featureDrawn', 'digitizing.visibility', 'digitizing.toolSelected', 'digitizing.editionBegins', 'digitizing.editionEnds', 'digitizing.erasingBegins', 'digitizing.erasingEnds', 'digitizing.erase','digitizing.rotate', 'digitizing.erase.all', 'digitizing.drawColor', 'digitizing.save', 'digitizing.measure', 'digitizing.editedFeatureText', 'digitizing.editedFeatureRotation', 'digitizing.editedFeatureScale', 'digitizing.split']
[
'digitizing.drawColor',
'digitizing.editedFeatureRotation',
'digitizing.editedFeatureScale',
'digitizing.editedFeatureText',
'digitizing.editionBegins',
'digitizing.editionEnds',
'digitizing.erase',
'digitizing.erase.all',
'digitizing.erasingBegins',
'digitizing.erasingEnds',
'digitizing.featureDrawn',
'digitizing.measure',
'digitizing.rotate',
'digitizing.save',
'digitizing.split',
'digitizing.toolSelected',
'digitizing.visibility',
]
);
}

Expand Down
10 changes: 8 additions & 2 deletions assets/src/components/Geolocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ export default class Geolocation extends HTMLElement {
const mainTemplate = () => html`
<div class="menu-content">
<div class="button-bar">
<button class="btn btn-sm ${mainLizmap.geolocation.isTracking ? 'active btn-success' : ''}" @click=${ () => mainLizmap.geolocation.toggleTracking()} ?disabled=${mainLizmap.geolocation.isTracking && mainLizmap.geolocation.firstGeolocation}><span class="icon"></span>${mainLizmap.geolocation.isTracking ? (mainLizmap.geolocation.firstGeolocation ? lizDict['geolocate.toolbar.waiting'] : lizDict['geolocate.toolbar.stop']) : lizDict['geolocate.toolbar.start']}</button>
<button class="btn btn-sm" @click=${ () => mainLizmap.geolocation.center()} ?disabled=${!mainLizmap.geolocation.isTracking | mainLizmap.geolocation.isBind | mainLizmap.geolocation.firstGeolocation}><span class="icon"></span>${lizDict['geolocate.toolbar.center']}</button>
<button class="btn btn-sm ${mainLizmap.geolocation.isTracking ? 'active btn-success' : ''}" @click=${ () => mainLizmap.geolocation.toggleTracking()} ?disabled=${mainLizmap.geolocation.isTracking && mainLizmap.geolocation.firstGeolocation}>
<span class="icon"></span>
${mainLizmap.geolocation.isTracking ? (mainLizmap.geolocation.firstGeolocation ? lizDict['geolocate.toolbar.waiting'] : lizDict['geolocate.toolbar.stop']) : lizDict['geolocate.toolbar.start']}
</button>
<button class="btn btn-sm" @click=${ () => mainLizmap.geolocation.center()} ?disabled=${!mainLizmap.geolocation.isTracking | mainLizmap.geolocation.isBind | mainLizmap.geolocation.firstGeolocation}>
<span class="icon"></span>
${lizDict['geolocate.toolbar.center']}
</button>
<div class="input-prepend input-append">
<button class="btn btn-sm ${mainLizmap.geolocation.isBind ? 'active btn-success' : ''}" @click=${() => mainLizmap.geolocation.toggleBind()} ?disabled=${!mainLizmap.geolocation.isTracking | mainLizmap.geolocation.firstGeolocation}><span class="icon"></span>${lizDict['geolocate.toolbar.bind']}</button>
<input class="input-mini" type="number" min="1" ?disabled=${!mainLizmap.geolocation.isBind || !mainLizmap.geolocation.isTracking} value="${mainLizmap.geolocation.bindIntervalInSecond}" @input=${(event) => mainLizmap.geolocation.bindIntervalInSecond = parseInt(event.target.value)}>
Expand Down
3 changes: 2 additions & 1 deletion assets/src/components/MousePosition.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export default class MousePosition extends HTMLElement {
return html`
<div class="mouse-position">
<div class="editable-position ${['dm', 'dms', 'mgrs'].includes(this._displayUnit) ? 'hide' : ''}">
<input type="number" step="any" placeholder="longitude" @input=${(event) => this._lonInput = parseFloat(event.target.value)} @keydown=${(event) => { if (event.key === 'Enter') { this._centerToCoords(); } }} .value=${isNaN(lon) ? 0 : lon}><input type="number" step="any" placeholder="latitude" @input=${(event) => this._latInput = parseFloat(event.target.value)} @keydown=${(event) => { if (event.key === 'Enter') { this._centerToCoords(); } }} .value=${isNaN(lat) ? 0 : lat}>
<input type="number" step="any" placeholder="longitude" @input=${(event) => this._lonInput = parseFloat(event.target.value)} @keydown=${(event) => { if (event.key === 'Enter') { this._centerToCoords(); } }} .value=${isNaN(lon) ? 0 : lon}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line break between inputs might change the UI but I'm not sure so it has to be visually tested

<input type="number" step="any" placeholder="latitude" @input=${(event) => this._latInput = parseFloat(event.target.value)} @keydown=${(event) => { if (event.key === 'Enter') { this._centerToCoords(); } }} .value=${isNaN(lat) ? 0 : lat}>
</div>
<div class="readonly-position ${['dm', 'dms', 'mgrs'].includes(this._displayUnit) ? '' : 'hide'}">
<span>${lon}</span>
Expand Down
4 changes: 3 additions & 1 deletion assets/src/components/SelectionInvert.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ 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`
<button type="button" class="selectiontool-invert btn btn-sm ${this.getAttribute('feature-type') && mainLizmap.config.layers[mainLizmap.getLayerNameByCleanName(this.getAttribute('feature-type'))]['selectedFeatures'].length === 0 ? 'hide' : ''}" ?disabled=${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)} @click=${() => mainLizmap.selectionTool.invert(mainLizmap.getLayerNameByCleanName(this.getAttribute('feature-type')))} data-bs-toggle="tooltip" data-bs-title="${lizDict['selectiontool.toolbar.action.invert']}">
<button type="button" class="selectiontool-invert btn btn-sm ${isHidden}" ?disabled=${isDisabled} @click=${() => mainLizmap.selectionTool.invert(mainLizmap.getLayerNameByCleanName(this.getAttribute('feature-type')))} data-bs-toggle="tooltip" data-bs-title="${lizDict['selectiontool.toolbar.action.invert']}">
<svg class="icon-">
<use xlink:href="#mActionInvertSelection"></use>
</svg>
Expand Down
3 changes: 2 additions & 1 deletion assets/src/components/SelectionTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class SelectionTool extends HTMLElement {

connectedCallback() {

const isFilterDisabled = mainLizmap.selectionTool.selectedFeaturesCount === 0 && mainLizmap.selectionTool.filteredFeaturesCount === 0;
const mainTemplate = () => html`
<div class="selectiontool">
<h3>
Expand Down Expand Up @@ -78,7 +79,7 @@ export default class SelectionTool extends HTMLElement {
<button type="button" class="selectiontool-unselect btn btn-sm" ?disabled=${mainLizmap.selectionTool.selectedFeaturesCount === 0} @click=${ () => mainLizmap.selectionTool.unselect()} data-bs-toggle="tooltip" data-bs-title="${lizDict['selectiontool.toolbar.action.unselect']}">
<i class="icon-star-empty"></i>
</button>
<button type="button" class="selectiontool-filter btn btn-sm ${mainLizmap.selectionTool.filteredFeaturesCount !== 0 ? 'active' : ''}" ?disabled=${mainLizmap.selectionTool.selectedFeaturesCount === 0 && mainLizmap.selectionTool.filteredFeaturesCount === 0} @click=${ () => mainLizmap.selectionTool.filter()} data-bs-toggle="tooltip" data-bs-title="${lizDict['selectiontool.toolbar.action.filter']}">
<button type="button" class="selectiontool-filter btn btn-sm ${mainLizmap.selectionTool.filteredFeaturesCount !== 0 ? 'active' : ''}" ?disabled=${isFilterDisabled} @click=${ () => mainLizmap.selectionTool.filter()} data-bs-toggle="tooltip" data-bs-title="${lizDict['selectiontool.toolbar.action.filter']}">
<i class="icon-filter"></i>
</button>
<lizmap-selection-invert></lizmap-selection-invert>
Expand Down
5 changes: 4 additions & 1 deletion assets/src/components/Snapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export default class Snapping extends HTMLElement {
<div class="snap-layers-list">
${mainLizmap.snapping?.config?.snap_layers.map((snapLayer) =>
html`<div class="snap-layer">
<input id="${'snap-layer-'+snapLayer}" name="${snapLayer}" @change=${()=> mainLizmap.snapping.snapToggled = snapLayer} .disabled=${!mainLizmap.snapping?.config?.snap_enabled[snapLayer]} .checked=${mainLizmap.snapping?.config?.snap_on_layers[snapLayer]} type="checkbox"/><label data-bs-toggle="tooltip" data-bs-title="${mainLizmap.snapping?.config?.snap_enabled[snapLayer] ? lizDict['snapping.list.toggle'] : lizDict['snapping.list.disabled']}" for="${'snap-layer-'+snapLayer}" class="${mainLizmap.snapping?.config?.snap_enabled[snapLayer] ? '' : 'snap-disabled'}">${mainLizmap.snapping?.getLayerTitle(snapLayer)}</label>
<input id="${'snap-layer-'+snapLayer}" name="${snapLayer}" @change=${()=> mainLizmap.snapping.snapToggled = snapLayer} .disabled=${!mainLizmap.snapping?.config?.snap_enabled[snapLayer]} .checked=${mainLizmap.snapping?.config?.snap_on_layers[snapLayer]} type="checkbox"/>
<label data-bs-toggle="tooltip" data-bs-title="${mainLizmap.snapping?.config?.snap_enabled[snapLayer] ? lizDict['snapping.list.toggle'] : lizDict['snapping.list.disabled']}" for="${'snap-layer-'+snapLayer}" class="${mainLizmap.snapping?.config?.snap_enabled[snapLayer] ? '' : 'snap-disabled'}">
${mainLizmap.snapping?.getLayerTitle(snapLayer)}
</label>
</div>
`
)}
Expand Down
1 change: 1 addition & 0 deletions assets/src/dependencies/mgrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ function LLtoUTM(ll) {
const C = eccPrimeSquared * Math.cos(LatRad) * Math.cos(LatRad);
const A = Math.cos(LatRad) * (LongRad - LongOriginRad);

// eslint-disable-next-line @stylistic/js/max-len
const M = a * ((1 - ECC_SQUARED / 4 - 3 * ECC_SQUARED * ECC_SQUARED / 64 - 5 * ECC_SQUARED * ECC_SQUARED * ECC_SQUARED / 256) * LatRad - (3 * ECC_SQUARED / 8 + 3 * ECC_SQUARED * ECC_SQUARED / 32 + 45 * ECC_SQUARED * ECC_SQUARED * ECC_SQUARED / 1024) * Math.sin(2 * LatRad) + (15 * ECC_SQUARED * ECC_SQUARED / 256 + 45 * ECC_SQUARED * ECC_SQUARED * ECC_SQUARED / 1024) * Math.sin(4 * LatRad) - (35 * ECC_SQUARED * ECC_SQUARED * ECC_SQUARED / 3072) * Math.sin(6 * LatRad));

const UTMEasting = (SCALE_FACTOR * N * (A + (1 - T + C) * A * A * A / 6 + (5 - 18 * T + T * T + 72 * C - 58 * eccPrimeSquared) * A * A * A * A * A / 120) + EASTING_OFFSET);
Expand Down
6 changes: 6 additions & 0 deletions assets/src/modules/state/Symbology.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import EventDispatcher from './../../utils/EventDispatcher.js';
import { applyConfig } from './../config/BaseObject.js';
import { LayerConfig } from './../config/Layer.js';

/* eslint-disable @stylistic/js/max-len --
* Base64 strings are obviously too long
**/

/**
* The started base 64 string for PNG image
* @type {string}
Expand Down Expand Up @@ -55,6 +59,8 @@ export const base64svgRasterLayer = 'PHN2ZyBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA
*/
export const base64svgOlLayer = 'PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj4KPHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxMDAgMTAwIgogIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgPGRlZnM+CiAgICA8ZyBpZD0ibGF5ZXIiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDUwIDUwKSI+CiAgICAgIDxnIHRyYW5zZm9ybT0ic2NhbGUoMC43MDcxIDAuNSkiPgogICAgICAgIDxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKC01MCAtNTApIj4KICAgICAgICAgIDxyZWN0IHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiByeD0iMTUiIHRyYW5zZm9ybT0icm90YXRlKDQ1IDUwIDUwKSIgLz4KICAgICAgICA8L2c+CiAgICAgIDwvZz4KICAgIDwvZz4KICA8L2RlZnM+CiAgPGcgZmlsbD0iI0ZGRkZGRiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMCAxMCkiPgogICAgPHVzZSB4bGluazpocmVmPSIjbGF5ZXIiLz4KICA8L2c+CiAgPGcgZmlsbD0iIzMzMzMzMyI+CiAgICA8dXNlIHhsaW5rOmhyZWY9IiNsYXllciIvPgogIDwvZz4KICA8ZyBmaWxsPSIjMDBBQUZGIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwIC0xMCkiPgogICAgPHVzZSB4bGluazpocmVmPSIjbGF5ZXIiLz4KICA8L2c+Cjwvc3ZnPg=='

/* eslint-enable @stylistic/js/max-len */

/**
* Get the default icon for a layer config
* @param {LayerConfig} layerCfg - The layer config for which getting default icon
Expand Down
17 changes: 13 additions & 4 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import js from "@eslint/js";
import jsdoc from "eslint-plugin-jsdoc";
import stylisticJs from '@stylistic/eslint-plugin-js'

export default [
js.configs.recommended,
Expand All @@ -21,6 +22,10 @@ export default [
"tests/units/vendor/",
],
}, {
plugins: {
jsdoc,
'@stylistic/js': stylisticJs
},
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
Expand Down Expand Up @@ -63,10 +68,14 @@ export default [
},
},
rules: {
"indent": ["error", 4, {
"SwitchCase": 1,
"ignoredNodes": ["TemplateLiteral *"],
}],
"@stylistic/js/indent": [
'error', 4, {
"SwitchCase": 1,
"ignoredNodes": ["TemplateLiteral *"],
}
],
"@stylistic/js/max-len": [
"error", 400, 4], // It's a temporary value, until we fix some.
"no-prototype-builtins": "off",
"no-undef": "off",
'jsdoc/require-description': 'warn',
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"devDependencies": {
"@eslint/js": "^9.19.0",
"@playwright/test": "^1.50.1",
"@stylistic/eslint-plugin-js": "^3.0.1",
"@turf/line-split": "^7.2.0",
"chai": "^5.1.2",
"cypress": "^9.7.0",
Expand Down
30 changes: 26 additions & 4 deletions tests/end2end/playwright/filter-layer-by-user.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,19 @@ test.describe('Filter layer data by user - user in group a', () => {
test('WMS GetFeatureInfo JSON', async ({ page }) => {

const getFeatureInfo = await page.evaluate(async () => {
return await fetch("/index.php/lizmap/service?repository=testsrepository&project=filter_layer_by_user&SERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=1.3.0&CRS=EPSG%3A2154&INFO_FORMAT=application%2Fjson&QUERY_LAYERS=green_filter_layer_by_user_edition_only%2Cblue_filter_layer_by_user%2Cred_layer_with_no_filter&LAYERS=green_filter_layer_by_user_edition_only%2Cblue_filter_layer_by_user%2Cred_layer_with_no_filter&STYLE=default%2Cdefault%2Cdefault&FEATURE_COUNT=10&FILTER=green_filter_layer_by_user_edition_only:\"gid\" > 0")
.then(r => r.ok ? r.json() : Promise.reject(r))
return await fetch(
"/index.php/lizmap/service?repository=testsrepository&project=filter_layer_by_user&" +
"SERVICE=WMS&" +
"REQUEST=GetFeatureInfo&" +
"VERSION=1.3.0&" +
"CRS=EPSG%3A2154&" +
"INFO_FORMAT=application%2Fjson&" +
"QUERY_LAYERS=green_filter_layer_by_user_edition_only%2Cblue_filter_layer_by_user%2Cred_layer_with_no_filter&" +
"LAYERS=green_filter_layer_by_user_edition_only%2Cblue_filter_layer_by_user%2Cred_layer_with_no_filter&" +
"STYLE=default%2Cdefault%2Cdefault&" +
"FEATURE_COUNT=10&" +
"FILTER=green_filter_layer_by_user_edition_only:\"gid\" > 0"
).then(r => r.ok ? r.json() : Promise.reject(r))
})

// check features
Expand Down Expand Up @@ -386,8 +397,19 @@ test.describe('Filter layer data by user - admin', () => {
test('WMS GetFeatureInfo JSON', async ({ page }) => {

const getFeatureInfo = await page.evaluate(async () => {
return await fetch("/index.php/lizmap/service?repository=testsrepository&project=filter_layer_by_user&SERVICE=WMS&REQUEST=GetFeatureInfo&VERSION=1.3.0&CRS=EPSG%3A2154&INFO_FORMAT=application%2Fjson&QUERY_LAYERS=green_filter_layer_by_user_edition_only%2Cblue_filter_layer_by_user%2Cred_layer_with_no_filter&LAYERS=green_filter_layer_by_user_edition_only%2Cblue_filter_layer_by_user%2Cred_layer_with_no_filter&STYLE=default%2Cdefault%2Cdefault&FEATURE_COUNT=10&FILTER=green_filter_layer_by_user_edition_only:\"gid\" > 0")
.then(r => r.ok ? r.json() : Promise.reject(r))
return await fetch(
"/index.php/lizmap/service?repository=testsrepository&project=filter_layer_by_user&" +
"SERVICE=WMS&" +
"REQUEST=GetFeatureInfo&" +
"VERSION=1.3.0&" +
"CRS=EPSG%3A2154&" +
"INFO_FORMAT=application%2Fjson&" +
"QUERY_LAYERS=green_filter_layer_by_user_edition_only%2Cblue_filter_layer_by_user%2Cred_layer_with_no_filter&" +
"LAYERS=green_filter_layer_by_user_edition_only%2Cblue_filter_layer_by_user%2Cred_layer_with_no_filter&" +
"STYLE=default%2Cdefault%2Cdefault&" +
"FEATURE_COUNT=10&" +
"FILTER=green_filter_layer_by_user_edition_only:\"gid\" > 0"
).then(r => r.ok ? r.json() : Promise.reject(r))
})

// check features
Expand Down
Loading
Loading