From 038fa9d9cfab34c4f76d2ad68ea20f3310daf9d1 Mon Sep 17 00:00:00 2001 From: nboisteault Date: Mon, 21 Aug 2023 15:42:26 +0200 Subject: [PATCH] Fix popup from atlas not working with shortnames Fix #3762 --- assets/src/legacy/atlas.js | 4 +- tests/qgis-projects/tests/atlas.qgs | 724 ++++++++++++++++++++++++ tests/qgis-projects/tests/atlas.qgs.cfg | 121 ++++ 3 files changed, 848 insertions(+), 1 deletion(-) create mode 100644 tests/qgis-projects/tests/atlas.qgs create mode 100644 tests/qgis-projects/tests/atlas.qgs.cfg diff --git a/assets/src/legacy/atlas.js b/assets/src/legacy/atlas.js index 32e3599981..f4679cb1b7 100644 --- a/assets/src/legacy/atlas.js +++ b/assets/src/legacy/atlas.js @@ -86,6 +86,7 @@ } const layerConfig = getLayerConfig[1]; var featureType = getLayerConfig[0]; + const wmsName = layerConfig?.shortname || featureType; var atlasLayerOptions = lizAtlasLayers.layerOptions[layerId]; @@ -100,6 +101,7 @@ var lizAtlasConfig = { 'layername': featureType, 'layerId': layerConfig.id, + 'wmsName': wmsName, 'displayLayerDescription': atlasLayerOptions['atlasDisplayLayerDescription'] == 'True' ? true : false, 'primaryKey': primaryKey, 'titleField': titleField, @@ -520,7 +522,7 @@ // Display popup if (lizAtlasConfig['atlasDisplayPopup']) { - lizMap.getFeaturePopupContent(lizAtlasConfig.featureType, feature, function (data) { + lizMap.getFeaturePopupContent(lizAtlasConfig.wmsName, feature, function (data) { var popupContainerId = 'liz-atlas-item-detail'; // Add class to table var popupReg = new RegExp('lizmapPopupTable', 'g'); diff --git a/tests/qgis-projects/tests/atlas.qgs b/tests/qgis-projects/tests/atlas.qgs new file mode 100644 index 0000000000..c17e85860e --- /dev/null +++ b/tests/qgis-projects/tests/atlas.qgs @@ -0,0 +1,724 @@ + + + + + + + + + GEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],MEMBER["World Geodetic System 1984 (G2139)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["Horizontal component of 3D system."],AREA["World."],BBOX[-90,-180,90,180]],ID["EPSG",4326]] + +proj=longlat +datum=WGS84 +no_defs + 3452 + 4326 + EPSG:4326 + WGS 84 + longlat + EPSG:7030 + true + + + + + + + + + + + + + quartiers_e3295d7e_c923_44a3_bb6c_a864adde76be + + + + + + + + + + + degrees + + 3.80371385911856397 + 43.56453741722413042 + 3.94468718844682176 + 43.65553790271894741 + + 0 + + + GEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],MEMBER["World Geodetic System 1984 (G2139)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["Horizontal component of 3D system."],AREA["World."],BBOX[-90,-180,90,180]],ID["EPSG",4326]] + +proj=longlat +datum=WGS84 +no_defs + 3452 + 4326 + EPSG:4326 + WGS 84 + longlat + EPSG:7030 + true + + + 0 + + + + + + + + + + + + Annotations_1b82beaa_5a0a_445e_b2ad_d7288106e20f + + + + + + + + GEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],MEMBER["World Geodetic System 1984 (G2139)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["Horizontal component of 3D system."],AREA["World."],BBOX[-90,-180,90,180]],ID["EPSG",4326]] + +proj=longlat +datum=WGS84 +no_defs + 3452 + 4326 + EPSG:4326 + WGS 84 + longlat + EPSG:7030 + true + + + + + + + + + + + + + + + + + 0 + 0 + + + + + false + + + + + + 1 + 0 + + + + + + 3.80707036695971279 + 43.56670409545019851 + 3.94133068060567293 + 43.65337122449288643 + + + 3.80707036695971279 + 43.56670409545019851 + 3.94133068060567293 + 43.65337122449288643 + + quartiers_e3295d7e_c923_44a3_bb6c_a864adde76be + service='lizmapdb' sslmode=disable key='quartier' estimatedmetadata=true srid=4326 type=MultiPolygon checkPrimaryKeyUnicity='1' table="tests_projects"."quartiers" (geom) + Quartiers_a_Montpellier + + + + Quartiers à Montpellier + + + GEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],MEMBER["World Geodetic System 1984 (G2139)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["Horizontal component of 3D system."],AREA["World."],BBOX[-90,-180,90,180]],ID["EPSG",4326]] + +proj=longlat +datum=WGS84 +no_defs + 3452 + 4326 + EPSG:4326 + WGS 84 + longlat + EPSG:7030 + true + + + + + + + dataset + + + + + + + + + + + + + + + + + GEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],MEMBER["World Geodetic System 1984 (G2139)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["Horizontal component of 3D system."],AREA["World."],BBOX[-90,-180,90,180]],ID["EPSG",4326]] + +proj=longlat +datum=WGS84 +no_defs + 3452 + 4326 + EPSG:4326 + WGS 84 + longlat + EPSG:7030 + true + + + + + + + + + + + + + postgres + + + + + + + + + + + 1 + 1 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + # -*- coding: utf-8 -*- +""" +QGIS forms can have a Python function that is called when the form is +opened. + +Use this function to add extra logic to your forms. + +Enter the name of the function in the "Python Init function" +field. +An example follows: +""" +from qgis.PyQt.QtWidgets import QWidget + +def my_form_open(dialog, layer, feature): + geom = feature.geometry() + control = dialog.findChild(QWidget, "MyLineEdit") + + 0 + generatedlayout + + + + + + + + + + + + + + + + + + + + + + + + "quartmno" + + + + + + + + + + + + + 1 + true + + + 0 + + + 255 + 255 + 255 + 255 + 0 + 255 + 255 + + + false + + + + + + EPSG:7030 + + + m2 + meters + + + 5 + 2.5 + false + false + 1 + 0 + false + false + true + 0 + 255,0,0,255 + + + false + + + true + 2 + MU + + false + + 1 + + + + lizmap_repository + lizmap_user + lizmap_user_groups + + + intranet + + + + + + + + quartiers_e3295d7e_c923_44a3_bb6c_a864adde76be + + + 8 + + + + + + + + None + false + + + + + + 1 + + 3.7914656533198445 + 43.56453741722413 + 3.956935394245541 + 43.65553790271895 + + false + conditions unknown + 90 + + + + 1 + + 8 + atlas + false + + true + atlas + 0 + + false + + + + + + + + false + + + + + false + + 5000 + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + nboisteault + 2023-08-21T14:52:23 + + + + + + + + + GEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],MEMBER["World Geodetic System 1984 (G2139)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["Horizontal component of 3D system."],AREA["World."],BBOX[-90,-180,90,180]],ID["EPSG",4326]] + +proj=longlat +datum=WGS84 +no_defs + 3452 + 4326 + EPSG:4326 + WGS 84 + longlat + EPSG:7030 + true + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/qgis-projects/tests/atlas.qgs.cfg b/tests/qgis-projects/tests/atlas.qgs.cfg new file mode 100644 index 0000000000..6c48252c68 --- /dev/null +++ b/tests/qgis-projects/tests/atlas.qgs.cfg @@ -0,0 +1,121 @@ +{ + "metadata": { + "qgis_desktop_version": 32216, + "lizmap_plugin_version_str": "3.16.4-alpha", + "lizmap_plugin_version": 31604, + "lizmap_web_client_target_version": 30700, + "lizmap_web_client_target_status": "Dev", + "instance_target_url": "http://localhost:8130/", + "instance_target_repository": "intranet", + "project_valid": true + }, + "warnings": [], + "options": { + "projection": { + "proj4": "+proj=longlat +datum=WGS84 +no_defs", + "ref": "EPSG:4326" + }, + "bbox": [ + "3.7914656533198445", + "43.56453741722413", + "3.956935394245541", + "43.65553790271895" + ], + "mapScales": [ + 10000, + 25000, + 50000, + 100000, + 250000, + 500000 + ], + "minScale": 10000, + "maxScale": 500000, + "initialExtent": [ + 3.7914656533198445, + 43.56453741722413, + 3.956935394245541, + 43.65553790271895 + ], + "popupLocation": "dock", + "pointTolerance": 25, + "lineTolerance": 10, + "polygonTolerance": 5, + "tmTimeFrameSize": 10, + "tmTimeFrameType": "seconds", + "tmAnimationFrameLength": 1000, + "datavizLocation": "dock", + "theme": "dark", + "fixed_scale_overview_map": true, + "atlasLayer": "quartiers_e3295d7e_c923_44a3_bb6c_a864adde76be", + "atlasPrimaryKey": "quartier", + "atlasDisplayLayerDescription": "True", + "atlasFeatureLabel": "quartier", + "atlasSortField": "quartier", + "atlasHighlightGeometry": "False", + "atlasDisplayPopup": "True", + "atlasTriggerFilter": "False", + "atlasDuration": 5, + "atlasEnabled": "True", + "atlasMaxWidth": 25, + "dataviz_drag_drop": [] + }, + "layers": { + "Quartiers \u00e0 Montpellier": { + "id": "quartiers_e3295d7e_c923_44a3_bb6c_a864adde76be", + "name": "Quartiers \u00e0 Montpellier", + "type": "layer", + "geometryType": "polygon", + "extent": [ + 3.807070366959713, + 43.5667040954502, + 3.941330680605673, + 43.653371224492886 + ], + "crs": "EPSG:4326", + "title": "Quartiers \u00e0 Montpellier", + "abstract": "", + "link": "", + "minScale": 1, + "maxScale": 1000000000000, + "toggled": "False", + "popup": "True", + "popupSource": "auto", + "popupTemplate": "", + "popupMaxFeatures": 10, + "popupDisplayChildren": "False", + "popup_allow_download": true, + "legend_image_option": "hide_at_startup", + "groupAsLayer": "False", + "baseLayer": "False", + "displayInLegend": "True", + "group_visibility": [], + "singleTile": "True", + "imageFormat": "image/png", + "cached": "False", + "clientCacheExpiration": 300 + } + }, + "locateByLayer": {}, + "attributeLayers": {}, + "tooltipLayers": {}, + "editionLayers": {}, + "layouts": { + "config": { + "default_popup_print": false + }, + "list": [] + }, + "loginFilteredLayers": {}, + "timemanagerLayers": {}, + "datavizLayers": {}, + "filter_by_polygon": { + "config": { + "polygon_layer_id": "quartiers_e3295d7e_c923_44a3_bb6c_a864adde76be", + "group_field": "quartier", + "filter_by_user": false + }, + "layers": [] + }, + "formFilterLayers": {} +}