From 22df26f6277198e539743481cabbd633a8f284dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Wed, 5 Feb 2025 17:50:57 +0100 Subject: [PATCH] Store the tools panel size --- src/canvas/DesktopElement.ts | 10 ++++++++-- src/query/MapQuerent.js | 6 +++--- src/query/Querent.js | 18 +++++++++--------- src/query/component.js | 6 +++--- src/query/gridComponent.html.js | 7 +++++-- src/query/gridComponent.js | 9 +++++++-- 6 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/canvas/DesktopElement.ts b/src/canvas/DesktopElement.ts index 332d398c71ea..51c29fa8b930 100644 --- a/src/canvas/DesktopElement.ts +++ b/src/canvas/DesktopElement.ts @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2022-2024 Camptocamp SA +// Copyright (c) 2022-2025 Camptocamp SA // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -100,6 +100,8 @@ export default class GmfDesktopCanvas extends BaseElement { private minDatapanelWidth_ = 320; // Minimum tool panel width in px private minToolpanelWidth_ = 280; + // Store the tools panel size + private toolsPanelWidth_: {[id: string]: string} = {}; static styles = [ ...BaseElement.styles, @@ -402,7 +404,10 @@ export default class GmfDesktopCanvas extends BaseElement { panels.getActiveToolPanel().subscribe({ next: (panel: string) => { const styles = getComputedStyle(document.documentElement); - let width = styles.getPropertyValue(`--right-panel-width-${panel}`); + let width = this.toolsPanelWidth_[panel]; + if (!width) { + width = styles.getPropertyValue(`--right-panel-width-${panel}`); + } if (!width) { width = styles.getPropertyValue(`--right-panel-width`); } @@ -589,6 +594,7 @@ export default class GmfDesktopCanvas extends BaseElement { panelResizeEvent.separator.style.left = `${panelResizeEvent.offsetLeft + deltaX}px`; const newRightWidth = `${panelResizeEvent.rightWidth - deltaX}px`; document.documentElement.style.setProperty(`--current-right-panel-width`, newRightWidth); + this.toolsPanelWidth_[this.toolPanel_] = newRightWidth; } return event; diff --git a/src/query/MapQuerent.js b/src/query/MapQuerent.js index ba4fffe971be..40285a7317b7 100644 --- a/src/query/MapQuerent.js +++ b/src/query/MapQuerent.js @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2017-2024 Camptocamp SA +// Copyright (c) 2017-2025 Camptocamp SA // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -225,7 +225,7 @@ export class MapQuerent { console.assert(dataSource); const querentResultItem = response[id]; const features = querentResultItem.features; - const limit = querentResultItem.limit; + const featuresCount = querentResultItem.featuresCount; const tooManyResults = querentResultItem.tooManyFeatures === true; const totalFeatureCount = querentResultItem.totalFeatureCount; const requestPartners = querentResultItem.requestPartners; @@ -299,7 +299,7 @@ export class MapQuerent { features: featuresByType, id: id, label: label, - limit: limit, + limit: featuresCount, pending: false, tooManyResults: tooManyResults, totalFeatureCount: totalFeatureCount, diff --git a/src/query/Querent.js b/src/query/Querent.js index e4b6ebe1cd57..e4012545d2f5 100644 --- a/src/query/Querent.js +++ b/src/query/Querent.js @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2017-2024 Camptocamp SA +// Copyright (c) 2017-2025 Camptocamp SA // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -46,7 +46,7 @@ import olSourceImageWMS from 'ol/source/ImageWMS'; /** * @typedef {Object} QuerentResultItem * @property {import('ol/Feature').default[]} features - * @property {number} limit + * @property {number} featuresCount * @property {boolean} [tooManyFeatures] * @property {number} [totalFeatureCount] * @property {string []} [requestPartners] All datasources requested in the same request @@ -403,8 +403,9 @@ export class Querent { 'version': '1.0.0', }); } - const limit = formatWFS.readFeatures(response.data).length; - const tooManyFeatures = totalFeatureCount > limit; + const featuresCount = formatWFS.readFeatures(response.data).length; + const tooManyFeatures = + totalFeatureCount > 0 ? totalFeatureCount > featuresCount : maxFeatures <= featuresCount; /** @type {string[]} */ const datasourceNames = []; for (const dataSource of dataSources) { @@ -418,13 +419,13 @@ export class Querent { this.setUniqueIds_(features, dataSource.id); hash[dataSourceId] = { features, - limit, + featuresCount: featuresCount, tooManyFeatures, totalFeatureCount, }; } Object.values(hash).forEach(function (value, index) { - value.limit = limit; + value.featuresCount = featuresCount; value.tooManyFeatures = tooManyFeatures; value.requestPartners = datasourceNames; }); @@ -456,7 +457,7 @@ export class Querent { this.setUniqueIds_(features, dataSource.id); hash[dataSourceId] = { features, - limit, + featuresCount: limit, tooManyFeatures, totalFeatureCount, }; @@ -468,7 +469,7 @@ export class Querent { this.setUniqueIds_(features, dataSource.id); hash[dataSourceId] = { features, - limit, + featuresCount: limit, }; } } @@ -740,7 +741,6 @@ export class Querent { // If we do not need to count features first, then proceed with // an normal WFS GetFeature request. - options.queryCountFirst = false; const canceler = this.registerCanceler_(); /** @type {angular.IPromise} */ const countPromise = new Promise((resolve, reject) => { diff --git a/src/query/component.js b/src/query/component.js index e3c7d142f3d4..141764a2c6fb 100644 --- a/src/query/component.js +++ b/src/query/component.js @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2019-2024 Camptocamp SA +// Copyright (c) 2019-2025 Camptocamp SA // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -321,7 +321,7 @@ export class QueryController { .issue({ action, extent, - limit, + limit: limit, map, }) .then(() => {}) @@ -350,7 +350,7 @@ export class QueryController { .issue({ action, geometry, - limit, + limit: limit, map, }) .then(() => {}) diff --git a/src/query/gridComponent.html.js b/src/query/gridComponent.html.js index 3a77d6c14e25..d314d666372c 100644 --- a/src/query/gridComponent.html.js +++ b/src/query/gridComponent.html.js @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2024 Camptocamp SA +// Copyright (c) 2024-2025 Camptocamp SA // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -62,9 +62,12 @@ export default `
>
{{'Only' | translate}} {{ctrl.sumOfFeatures}} {{'of' | translate}} {{ctrl.sumOfAvailableResults}} + >{{'Only' | translate}} {{ctrl.sumOfFeatures}} {{'of' | translate}} {{ctrl.sumOfAvailableResults}} {{'results displayed, as the maximum number is reached. Please refine your query.' | translate }}{{'One of the query returns the maximum of results, probably not all the results are displayed. Please refine your query.' | translate}} +
diff --git a/src/query/gridComponent.js b/src/query/gridComponent.js index e6b682bff66e..36e8282096a2 100644 --- a/src/query/gridComponent.js +++ b/src/query/gridComponent.js @@ -10,7 +10,7 @@ QueryGridController.$inject = [ ]; // The MIT License (MIT) // -// Copyright (c) 2016-2024 Camptocamp SA +// Copyright (c) 2016-2025 Camptocamp SA // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -368,7 +368,12 @@ QueryGridController.prototype.updateData_ = function () { this.sumOfFeatures += source.features.length; } if (!source.requestPartners || !source.requestPartners.some((label) => countedSources.includes(label))) { - this.sumOfAvailableResults += source.totalFeatureCount; + if (source.totalFeatureCount < 0 || this.sumOfAvailableResults < 0) { + // At least one query without any count => we can't display the total count + this.sumOfAvailableResults = -1; + } else { + this.sumOfAvailableResults += source.totalFeatureCount; + } } countedSources.push(source.label); });