Skip to content

Commit

Permalink
Store the tools panel size
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Feb 6, 2025
1 parent 4d31fc0 commit 22df26f
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 21 deletions.
10 changes: 8 additions & 2 deletions src/canvas/DesktopElement.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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`);
}
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/query/MapQuerent.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -299,7 +299,7 @@ export class MapQuerent {
features: featuresByType,
id: id,
label: label,
limit: limit,
limit: featuresCount,
pending: false,
tooManyResults: tooManyResults,
totalFeatureCount: totalFeatureCount,
Expand Down
18 changes: 9 additions & 9 deletions src/query/Querent.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -46,7 +46,7 @@ import olSourceImageWMS from 'ol/source/ImageWMS';
/**
* @typedef {Object} QuerentResultItem
* @property {import('ol/Feature').default<import('ol/geom/Geometry').default>[]} features
* @property {number} limit
* @property {number} featuresCount
* @property {boolean} [tooManyFeatures]
* @property {number} [totalFeatureCount]
* @property {string []} [requestPartners] All datasources requested in the same request
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
});
Expand Down Expand Up @@ -456,7 +457,7 @@ export class Querent {
this.setUniqueIds_(features, dataSource.id);
hash[dataSourceId] = {
features,
limit,
featuresCount: limit,
tooManyFeatures,
totalFeatureCount,
};
Expand All @@ -468,7 +469,7 @@ export class Querent {
this.setUniqueIds_(features, dataSource.id);
hash[dataSourceId] = {
features,
limit,
featuresCount: limit,
};
}
}
Expand Down Expand Up @@ -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<QuerentResult>} */
const countPromise = new Promise((resolve, reject) => {
Expand Down
6 changes: 3 additions & 3 deletions src/query/component.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -321,7 +321,7 @@ export class QueryController {
.issue({
action,
extent,
limit,
limit: limit,
map,
})
.then(() => {})
Expand Down Expand Up @@ -350,7 +350,7 @@ export class QueryController {
.issue({
action,
geometry,
limit,
limit: limit,
map,
})
.then(() => {})
Expand Down
7 changes: 5 additions & 2 deletions src/query/gridComponent.html.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -62,9 +62,12 @@ export default `<div class="gmf-displayquerygrid panel" ng-show="ctrl.active">
>
<div class="col-md-5 my-auto">
<span ng-if="ctrl.hasOneWithTooManyResults_()" class="gmf-query-grid-too-many text-warning"
>{{'Only' | translate}} {{ctrl.sumOfFeatures}} {{'of' | translate}} {{ctrl.sumOfAvailableResults}}
><span ng-if="ctrl.sumOfAvailableResults >= 0">{{'Only' | translate}} {{ctrl.sumOfFeatures}} {{'of' | translate}} {{ctrl.sumOfAvailableResults}}
{{'results displayed, as the maximum number is reached. Please refine your query.' | translate
}}</span
><span ng-if="ctrl.sumOfAvailableResults < 0">{{'One of the query returns the maximum of results, probably not all the results are displayed. Please refine your query.' | translate}}
</span
></span
>
</div>
<div class="col-md-7" class="pull-right">
Expand Down
9 changes: 7 additions & 2 deletions src/query/gridComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
});
Expand Down

0 comments on commit 22df26f

Please sign in to comment.