@@ -1090,7 +1090,8 @@ window.lizMap = function() {
1090
1090
1091
1091
// prepare utilities object
1092
1092
let rUtilities = {
1093
- rLayerId : rLayerId // pivot id or table id
1093
+ rLayerId : rLayerId , // pivot id or table id
1094
+ relationId : relation . relationId , // relationId
1094
1095
} ;
1095
1096
const pivotAttributeLayerConf = lizMap . getLayerConfigById ( rLayerId , lizMap . config . attributeLayers , 'layerId' ) ;
1096
1097
// check if child is a pivot table
@@ -1144,7 +1145,8 @@ window.lizMap = function() {
1144
1145
if ( rGetLayerConfig ) {
1145
1146
preProcessRequest = {
1146
1147
oneToN :true ,
1147
- layer :rGetLayerConfig [ 1 ]
1148
+ layer :rGetLayerConfig [ 1 ] ,
1149
+ relationId :relation . relationId ,
1148
1150
}
1149
1151
let ut = {
1150
1152
referencingField : relation . referencingField ,
@@ -1332,7 +1334,10 @@ window.lizMap = function() {
1332
1334
1333
1335
parentDiv . append ( childPopup ) ;
1334
1336
1335
- childPopupElements . push ( childPopup ) ;
1337
+ childPopupElements . push ( {
1338
+ childPopupElement :childPopup ,
1339
+ relationId :utilities . relationId ,
1340
+ } ) ;
1336
1341
1337
1342
// Trigger event for single popup children
1338
1343
lizMap . events . triggerEvent (
@@ -1366,33 +1371,11 @@ window.lizMap = function() {
1366
1371
1367
1372
// place children in the right div, if any
1368
1373
let relations = parentDiv . children ( '.container.popup_lizmap_dd' ) . find ( ".popup_lizmap_dd_relation" ) ;
1369
- relations . each ( ( ind , relation ) => {
1370
- let referencingLayerId = $ ( relation ) . attr ( 'data-referencing-layer-id' ) ;
1371
- if ( referencingLayerId ) {
1372
- let relLayerId = null ;
1373
- let referencingLayerConfig = lizMap . getLayerConfigById ( referencingLayerId , lizMap . config . attributeLayers , 'layerId' ) ;
1374
- if ( referencingLayerConfig && referencingLayerConfig [ 1 ] ?. pivot == 'True' && config . relations . pivot && config . relations . pivot [ referencingLayerId ] ) {
1375
- // relation is a pivot, search for "m" child layers
1376
- let mLayer = Object . keys ( config . relations . pivot [ referencingLayerId ] ) . filter ( ( k ) => { return k !== layerId } )
1377
- if ( mLayer . length == 1 ) {
1378
- relLayerId = mLayer [ 0 ] ;
1379
- }
1380
- } else {
1381
- // relation is 1:n, search for n layer
1382
- relLayerId = referencingLayerId ;
1383
- }
1384
-
1385
- if ( relLayerId ) {
1386
- let childLayer = childPopupElements . filter ( ( child ) => {
1387
- let lName = child . attr ( "data-layername" ) ;
1388
- let lId = lName ? lizMap . config . layers ?. [ lName ] ?. id : '' ;
1389
- return relLayerId == lId ;
1390
- } )
1391
-
1392
- if ( childLayer . length == 1 ) {
1393
- $ ( relation ) . append ( childLayer [ 0 ] )
1394
- }
1395
- }
1374
+ relations . each ( ( ind , relation ) => {
1375
+ let relationId = relation . dataset . relationId ;
1376
+ let elementToMove = childPopupElements . filter ( c => c . relationId == relationId ) ;
1377
+ if ( elementToMove . length == 1 ) {
1378
+ $ ( relation ) . append ( elementToMove [ 0 ] . childPopupElement ) ;
1396
1379
}
1397
1380
} ) ;
1398
1381
@@ -1401,7 +1384,7 @@ window.lizMap = function() {
1401
1384
"lizmappopupallchildrendisplayed" ,
1402
1385
{
1403
1386
parentPopupElement : self . parents ( '.lizmapPopupSingleFeature' ) ,
1404
- childPopupElements : childPopupElements
1387
+ childPopupElements : childPopupElements . map ( c => c . childPopupElement )
1405
1388
}
1406
1389
) ;
1407
1390
} ) ;
0 commit comments