Skip to content

Commit

Permalink
Fix some typo, JS lint, "var" keywords" etc
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Nov 15, 2024
1 parent 5d98d9e commit 8f73385
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 41 deletions.
1 change: 0 additions & 1 deletion assets/src/components/FeaturesTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ export default class FeaturesTable extends HTMLElement {
*
* @param {Event} event Click event on a feature item
* @param {Object} feature WFS feature
* @param {number} lineId Line number of the item in the features table
*/
onItemClick(event, feature) {
if (!this.openPopup) {return true;}
Expand Down
2 changes: 1 addition & 1 deletion assets/src/components/Print.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export default class Print extends HTMLElement {
* @param {string | number} index
*/
set printTemplate(index){
// No print templats defined do nothing
// No print templates defined do nothing
if (this._printTemplates.length == 0) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions assets/src/legacy/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ window.lizMap = function() {
* config
*
* Returns:
* {Integer} the layer's order
* {int} the layer's order
* @param nested
*/
function getLayerOrder(nested) {
Expand Down Expand Up @@ -1570,7 +1570,7 @@ window.lizMap = function() {
GEOMETRYNAME: 'extent'
};

wfsParams['EXP_FILTER'] = '"' + config.relations.pivot[rLayerId][layerId] + '" = ' + "'" + feat.properties[relation.referencedField] + "'";;
wfsParams['EXP_FILTER'] = '"' + config.relations.pivot[rLayerId][layerId] + '" = ' + "'" + feat.properties[relation.referencedField] + "'";
// Calculate bbox
if (config.options?.limitDataToBbox == 'True') {
wfsParams['BBOX'] = lizMap.mainLizmap.map.getView().calculateExtent();
Expand Down
2 changes: 1 addition & 1 deletion assets/src/modules/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ export default class Action {
* @param {object} action - The action configuration object
* @param {string} layerId - The layer ID
* @param {string} featureId - The feature ID
* @param {string} popupItem - The popup item HTML element
* @param {string} popupContainerId - The popup container ID
*/
addPopupActionButton(action, layerId, featureId, popupContainerId) {

Expand Down
8 changes: 4 additions & 4 deletions assets/src/modules/FeaturesTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export default class FeaturesTable {
* @param {string|null} fields List of field names separated by comma
*
* @returns — A Promise that resolves with the result of parsing the response body text as JSON.
* @throws {ResponseError} In case of invalid content type (not application/json or application/vnd.geo+json) or Invalid JSON
* @throws {HttpError} In case of not successful response (status not in the range 200 – 299)
* @throws {NetworkError} In case of catch exceptions
* @throws {ResponseError} In case of invalid content type (not application/json or application/vnd.geo+json) or Invalid JSON
* @throws {HttpError} In case of not successful response (status not in the range 200 – 299)
* @throws {NetworkError} In case of catch exceptions
*/
getFeatures(layerId, filter = null, withGeometry = false, fields = 'null') {

Expand Down Expand Up @@ -83,7 +83,7 @@ export default class FeaturesTable {
* @param {object} feature WFS Feature
* @param {string} uniqueField Field containing unique values (used to set the filter for the WMS request)
* @param {HTMLElement} targetElement Target HTML element to display the popup content for the given feature
* @param {callBack} callBack Callback function
* @param {requestCallback} aCallBack Callback function
*/
openPopup(layerId, feature, uniqueField, targetElement, aCallBack) {

Expand Down
2 changes: 1 addition & 1 deletion assets/src/modules/config/Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export class LayerConfig extends BaseObjectConfig {
}

/**
* The layer layer external access (layer only)
* The layer external access (layer only)
* @type {?object}
*/
get externalAccess() {
Expand Down
2 changes: 1 addition & 1 deletion assets/src/modules/config/LayerTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ function buildLayerTreeGroupConfigItems(wmsCapaLayerGroup, layersCfg, level) {
const groupItems = buildLayerTreeGroupConfigItems(wmsCapaLayer, layersCfg, level+1);
items.push(new LayerTreeGroupConfig(cfg.name, level+1, groupItems, wmsCapaLayer, cfg));
} else {
// avoid to add the baseLayers group to the map if doesn't contains any layer.
// avoid to add the baseLayers group to the map if it doesn't contain any layer.
if(wmsName.toLowerCase() != 'baselayers') {
items.push(new LayerTreeLayerConfig(cfg.name, level+1, wmsCapaLayer, cfg));
}
Expand Down
2 changes: 1 addition & 1 deletion assets/src/modules/utils/Enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* 'Undefined': undefined,
* });
* @param {object} structure - The enum structure
* @throws {TypeError} Will throws an error if the structure is not an oject and the values
* @throws {TypeError} Will throws an error if the structure is not an object and the values
* associated to the structure keys are not 'number', 'string', 'boolean' or 'undefined'.
* @returns {Proxy} The enum based on the structure
*/
Expand Down
16 changes: 8 additions & 8 deletions lizmap/www/assets/js/dataviz/dataviz.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let lizDataviz = function () {
* Get the percentage of an element covering the viewport
*
* @param {HTMLElement} element The element to test
* @return {integer} Percentage
* @return {int} Percentage
*/
function getViewPercentage(element) {
const viewport = {
Expand Down Expand Up @@ -311,7 +311,7 @@ let lizDataviz = function () {
* or in a user-defined plot container if the HTML template
* has been configured inside Lizmap plugin
*
* @param {integer} plot_id The plot id
* @param {int} plot_id The plot id
*/
function addPlotContainer(plot_id) {
let dataviz_plot_id = 'dataviz_plot_' + plot_id;
Expand Down Expand Up @@ -340,7 +340,7 @@ let lizDataviz = function () {
* Get the plot data from the backend
* and draw the plot with the buildPlot method
*
* @param {integer} plot_id The id of the plot.
* @param {int} plot_id The id of the plot.
* @param {string} exp_filter The optional data filter.
* @param {string} target_id The ID of the target dom element.
*
Expand Down Expand Up @@ -465,9 +465,9 @@ let lizDataviz = function () {
* It is responsible for rendering the plot and
* adding it in the document.
*
* @param {integer} targetId The ID of the plot HTML container element.
* @param {int} targetId The ID of the plot HTML container element.
* @param {object} data The plot data as given by the backend
* @param {integer} pid The plot integer ID
* @param {int} pid The plot integer ID
* @param {object} layout The plot layout defined by the user
*
*/
Expand Down Expand Up @@ -567,7 +567,7 @@ let lizDataviz = function () {
* Return the plot integer ID by passing the plot element container ID?
*
* @param {string} id The plot integer ID
* @return {integer} The container HTML element ID
* @return {int} The container HTML element ID
*/
function getPlotIdByContainerId(id) {
let pid = null;
Expand Down Expand Up @@ -599,7 +599,7 @@ let lizDataviz = function () {
*
* @param {string} targetId The ID of the plot HTML container element.
* @param {object} conf The plot configuration with data and layout properties.
* @param {integer} pid The plot integer ID
* @param {int} pid The plot integer ID
*/
function buildPlot(targetId, conf, pid = null) {

Expand Down Expand Up @@ -719,7 +719,7 @@ let lizDataviz = function () {
* based on the source OpenLayers layer visibility
* depending on the parameter display_when_layer_visible
*
* @param {integer} plotId The plot integer ID
* @param {int} plotId The plot integer ID
* @return {boolean} True if the plot must be visible
*/
function setPlotContainerVisibilityFromLayerVisibility(plotId) {
Expand Down
12 changes: 6 additions & 6 deletions tests/end2end/cypress/integration/requests-metadata-ghaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe('Request JSON metadata', function () {
it('As anonymous', function () {
cy.logout();

var metadata = cy.request({
const metadata = cy.request({
url: 'index.php/view/app/metadata',
failOnStatusCode: false,
}).then((response) => {
Expand All @@ -15,7 +15,7 @@ describe('Request JSON metadata', function () {
it('As admin using basic auth', function () {
cy.logout()

var request = cy.request({
const request = cy.request({
url: 'index.php/view/app/metadata',
headers: {
authorization: 'Basic YWRtaW46YWRtaW4=',
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('Request JSON metadata', function () {
it('As admin after login using the UI', function () {
cy.loginAsAdmin()

var request = cy.request({
const request = cy.request({
url: 'index.php/view/app/metadata',
failOnStatusCode: false,
}).then((response) => {
Expand All @@ -124,7 +124,7 @@ describe('Request JSON metadata', function () {
it('As normal user using UI', function () {
cy.loginAsUserA()

var request = cy.request({
const request = cy.request({
url: 'index.php/view/app/metadata',
failOnStatusCode: false,
}).then((response) => {
Expand All @@ -140,7 +140,7 @@ describe('Request JSON metadata', function () {
it('As publisher user using UI', function () {
cy.loginAsPublisher()

var request = cy.request({
const request = cy.request({
url: 'index.php/view/app/metadata',
failOnStatusCode: false,
}).then((response) => {
Expand Down Expand Up @@ -205,7 +205,7 @@ describe('Request JSON metadata', function () {
})

it('As publisher using BASIC Auth with wrong credentials', function () {
var request = cy.request({
const request = cy.request({
url: 'index.php/view/app/metadata',
headers: {
authorization: 'Basic dXNlcl9pbl9ncm91cF9hOm1hdXZhaXM=',
Expand Down
2 changes: 1 addition & 1 deletion tests/end2end/playwright/draw.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ test.describe('Draw', () => {
// Change color
await page.locator('input[type="color"]').evaluate(input => {
input.value = '#000'; // Cast input to HTMLInputElement for TypeScript
var event = new Event('input', {
let event = new Event('input', {
bubbles: true,
cancelable: true,
});
Expand Down
2 changes: 1 addition & 1 deletion tests/end2end/playwright/embed.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { test } from '@playwright/test';
import { gotoMap } from './globals';

test.describe('Embed', () => {
Expand Down
12 changes: 6 additions & 6 deletions tests/end2end/playwright/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function NoErrors(page, checkLayerTreeView = true) {
* CatchErrors function
* Some checks when the map is on error
* @param page The page object
* @param int layersInTreeView The number of layers to find in the treeview.
* @param {int} layersInTreeView The number of layers to find in the treeview.
*/
async function CatchErrors(page, layersInTreeView = 0) {
// Error
Expand All @@ -30,11 +30,11 @@ async function CatchErrors(page, layersInTreeView = 0) {
/**
* gotoMap function
* Helper to load a map and do some basic checks
* @param string url The URL of the map to load
* @param page The page object
* @param boolean mapMustLoad If the loading of the map must be successful or not. Some error might be triggered when loading the map, on purpose.
* @param int layersInTreeView The number of layers to find in the treeview if the map is on error.
* @param boolean waitForGetLegendGraphics
* @param {string} url The URL of the map to load
* @param {page} page The page object
* @param {boolean} mapMustLoad If the loading of the map must be successful or not. Some error might be triggered when loading the map, on purpose.
* @param {int} layersInTreeView The number of layers to find in the treeview if the map is on error.
* @param {boolean} waitForGetLegendGraphics
*/
export async function gotoMap(url, page, mapMustLoad = true, layersInTreeView = 0, waitForGetLegendGraphics = true) {
// TODO keep this function synchronized with the Cypress equivalent
Expand Down
6 changes: 3 additions & 3 deletions tests/end2end/playwright/google-basemap.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import { test, expect } from '@playwright/test';
import { gotoMap } from './globals';;
import { gotoMap } from './globals';

test.describe('Google Maps Baselayers', () => {
test('Load map with no API Key', async ({ page }) => {
Expand All @@ -16,7 +16,7 @@ test.describe('Google Maps Baselayers', () => {
// listen to the requests to intercept failing ones
let initGoogleRequestsCount = 0;
page.on('response', response => {
if(response.url().includes('createSession?key=dummy') && response.status() != 200) {
if(response.url().includes('createSession?key=dummy') && response.status() !== 200) {
initGoogleRequestsCount++;
}
});
Expand All @@ -29,7 +29,7 @@ test.describe('Google Maps Baselayers', () => {
// baselayers group should be visible...
await expect(page.locator('#switcher-baselayer')).toBeVisible();

//.. and should contains the three Google base layers (not loaded)
//.. and should contain the three Google base layers (not loaded)
let options = page.locator('#switcher-baselayer').getByRole('combobox').locator('option');
await expect(options).toHaveCount(3);
expect(await options.nth(0).getAttribute('value')).toBe('Google Streets');
Expand Down
8 changes: 4 additions & 4 deletions tests/end2end/playwright/media.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { gotoMap } from './globals';
test.describe('Media', () => {
test('Tests media are deleted', async ({ page }) => {

var baseUrl = 'index.php/view/media/getMedia?repository=testsrepository&project=form_edition_all_field_type&path=';
const baseUrl = 'index.php/view/media/getMedia?repository=testsrepository&project=form_edition_all_field_type&path=';
// on the feature from the "form_edition_upload" layer
var response = await page.request.get(baseUrl + 'media/upload/form_edition_all_field_type/form_edition_upload/text_file_mandatory/lorem-2.txt');
let response = await page.request.get(baseUrl + 'media/upload/form_edition_all_field_type/form_edition_upload/text_file_mandatory/lorem-2.txt');
await expect(response).toBeOK();

var response = await page.request.get(baseUrl + 'media/upload/form_edition_all_field_type/form_edition_upload/image_file_mandatory/random-2.jpg');
response = await page.request.get(baseUrl + 'media/upload/form_edition_all_field_type/form_edition_upload/image_file_mandatory/random-2.jpg');
await expect(response).toBeOK();

var response = await page.request.get(baseUrl + '../media/specific_media_folder/random-4.jpg');
response = await page.request.get(baseUrl + '../media/specific_media_folder/random-4.jpg');
await expect(response).toBeOK();

// Open the attribute table
Expand Down

0 comments on commit 8f73385

Please sign in to comment.