Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release_3_7] [Fix] Add Popup dock server side #4415

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions assets/src/legacy/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -2396,29 +2396,36 @@ window.lizMap = function() {
break;
}
}
if ( !popupsAvailable )
if ( !popupsAvailable ) {
if ($('#mapmenu .nav-list > li.popupcontent > a').length ) {
$('#mapmenu .nav-list > li.popupcontent').remove();
}
return null;
}

// Create the dock if needed
if( 'popupLocation' in config.options &&
config.options.popupLocation != 'map' &&
!$('#mapmenu .nav-list > li.popupcontent > a').length ) {
// Verifying the message
if ( !('popup.msg.start' in lizDict) )
lizDict['popup.msg.start'] = 'Click to the map to get informations.';
// Initialize dock
var popupContainerId = 'popupcontent';
var pcontent = '<div class="lizmapPopupContent"><h4>'+lizDict['popup.msg.start']+'</h4></div>';
addDock(popupContainerId, 'Popup', config.options.popupLocation, pcontent, 'icon-comment');
$('#button-popupcontent').click(function(){
if($(this).parent().hasClass('active')) {
// clean locate layer
clearDrawLayer('locatelayer');
// remove information
$('#popupcontent > div.menu-content').html('<div class="lizmapPopupContent"><h4>'+lizDict['popup.msg.start']+'</h4></div>');
}
});

config.options.popupLocation != 'map' ) {
if ( !$('#mapmenu .nav-list > li.popupcontent > a').length ) {
// Verifying the message
if ( !('popup.msg.start' in lizDict) )
lizDict['popup.msg.start'] = 'Click to the map to get informations.';
// Initialize dock
var popupContainerId = 'popupcontent';
var pcontent = '<div class="lizmapPopupContent"><h4>'+lizDict['popup.msg.start']+'</h4></div>';
addDock(popupContainerId, 'Popup', config.options.popupLocation, pcontent, 'icon-comment');
$('#button-popupcontent').click(function(){
if($(this).parent().hasClass('active')) {
// clear highlight layer
lizMap.mainLizmap.map.clearHighlightFeatures();
// remove information
$('#popupcontent > div.menu-content').html('<div class="lizmapPopupContent"><h4>'+lizDict['popup.msg.start']+'</h4></div>');
}
});
} else {
$('#mapmenu .nav-list > li.popupcontent > a > span.icon').append('<i class="icon-comment icon-white" style="margin-left: 4px;"></i>');
$('#mapmenu .nav-list > li.popupcontent > a > span.icon').css('background-image', 'none');
}
}

var WMSGetFeatureInfo = new OpenLayers.Control.WMSGetFeatureInfo({
Expand Down
39 changes: 39 additions & 0 deletions lizmap/modules/lizmap/lib/Project/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,15 @@ public function getDefaultDockable()
);
}

if ($this->getOption('popupLocation') === 'dock') {
$dockable[] = new \lizmapMapDockItem(
'popupcontent',
'Popup',
'<div class="menu-content"><div class="lizmapPopupContent"><h4>'.$this->appContext->getLocale('view~dictionnary.popup.msg.start').'</h4></div></div>',
4
);
}

return $dockable;
}

Expand All @@ -2182,6 +2191,15 @@ public function getDefaultMiniDockable()
$dockable = array();
$bp = $this->appContext->appConfig()->urlengine['basePath'];

if ($this->getOption('popupLocation') === 'mini-dock') {
$dockable[] = new \lizmapMapDockItem(
'popupcontent',
'Popup',
'<div class="menu-content"><div class="lizmapPopupContent"><h4>'.$this->appContext->getLocale('view~dictionnary.popup.msg.start').'</h4></div></div>',
0
);
}

if ($this->hasAttributeLayers()) {
// Add layer-export attribute to lizmap-selection-tool component if allowed
$layerExport = $this->appContext->aclCheck('lizmap.tools.layer.export', $this->repository->getKey()) ? 'layer-export' : '';
Expand Down Expand Up @@ -2339,6 +2357,27 @@ public function getDefaultBottomDockable()
return $dockable;
}

/**
* @throws \jExceptionSelector
*
* @return \lizmapMapDockItem[]
*/
public function getDefaultRightDockable()
{
$dockable = array();

if ($this->getOption('popupLocation') === 'right-dock') {
$dockable[] = new \lizmapMapDockItem(
'popupcontent',
'Popup',
'<div class="menu-content"><div class="lizmapPopupContent"><h4>'.$this->appContext->getLocale('view~dictionnary.popup.msg.start').'</h4></div></div>',
0
);
}

return $dockable;
}

/**
* Check if the project needs an update which lead to an error.
*
Expand Down
2 changes: 1 addition & 1 deletion lizmap/modules/view/controllers/lizMap.classic.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ protected function getProjectDockables()
$items = jEvent::notify('mapBottomDockable', array('repository' => $repository, 'project' => $project))->getResponse();
$assign['bottomdockable'] = mapDockItemsMerge($assign['bottomdockable'], $items);

$assign['rightdockable'] = array();
$assign['rightdockable'] = $lproj->getDefaultRightDockable();
$items = jEvent::notify('mapRightDockable', array('repository' => $repository, 'project' => $project))->getResponse();
$assign['rightdockable'] = mapDockItemsMerge($assign['rightdockable'], $items);

Expand Down
Loading