[fusion-commits] r2942 - in trunk/widgets: . SelectWithin widgetinfo
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Wed May 4 10:36:08 PDT 2016
Author: jng
Date: 2016-05-04 10:36:08 -0700 (Wed, 04 May 2016)
New Revision: 2942
Modified:
trunk/widgets/SelectWithin.js
trunk/widgets/SelectWithin/SelectWithinPanel.php
trunk/widgets/SelectWithin/SelectWithinPanel.templ
trunk/widgets/widgetinfo/selectwithin.xml
Log:
#637: Allow invisible layers to be hidden from the layer list of the Select Within UI. This behaviour can be toggled through a new OmitInvisibleLayers extension property. The default value is false, preserving the existing behaviour.
Original patch by morkl, tweaked by me to allow for configurability and to avoid usage of browser APIs that are not uniform across browsers (Array.prototype.filter)
Modified: trunk/widgets/SelectWithin/SelectWithinPanel.php
===================================================================
--- trunk/widgets/SelectWithin/SelectWithinPanel.php 2016-05-04 17:06:05 UTC (rev 2941)
+++ trunk/widgets/SelectWithin/SelectWithinPanel.php 2016-05-04 17:36:08 UTC (rev 2942)
@@ -36,24 +36,27 @@
$popup = "";
$mapName = "";
$sessionId = "";
+ $bOmitInvisibleLayers = false;
GetRequestParameters();
$templ = file_get_contents("./SelectWithinPanel.templ");
SetLocalizedFilesPath(GetLocalizationPath());
$templ = Localize($templ, $locale, GetClientOS());
- print sprintf($templ, $popup, "./widgets/SelectWithin/SelectWithin.php", $mapName, $sessionId);
+ print sprintf($templ, $popup, "./widgets/SelectWithin/SelectWithin.php", $mapName, $sessionId, ($bOmitInvisibleLayers ? "true" : "false"));
function GetParameters($params)
{
- global $mapName, $sessionId, $locale, $popup;
+ global $mapName, $sessionId, $locale, $popup, $bOmitInvisibleLayers;
- if(isset($params['locale']))
+ if (isset($params['locale']))
$locale = $params['locale'];
$mapName = $params['mapname'];
$sessionId = $params['session'];
$popup = $params['popup'];
+ if (isset($params['omit_invisible_layers']))
+ $bOmitInvisibleLayers = ($params['omit_invisible_layers'] == "1");
}
function GetRequestParameters()
Modified: trunk/widgets/SelectWithin/SelectWithinPanel.templ
===================================================================
--- trunk/widgets/SelectWithin/SelectWithinPanel.templ 2016-05-04 17:06:05 UTC (rev 2941)
+++ trunk/widgets/SelectWithin/SelectWithinPanel.templ 2016-05-04 17:36:08 UTC (rev 2942)
@@ -40,6 +40,7 @@
var webAgent = '%s';
var mapName = '%s';
var sessionId = '%s';
+var bOmitInvisibleLayers = %s;
var zoomTo = false;
function InitDocument()
@@ -119,13 +120,39 @@
}
}
+function CheckVisibility(groupOrLayer)
+{
+ if (!groupOrLayer.isVisible())
+ return false;
+ if (groupOrLayer.parentGroup)
+ return CheckVisibility(groupOrLayer.parentGroup);
+ return true;
+}
+
+function GetSelectableLayers(layers)
+{
+ if (bOmitInvisibleLayers) {
+ var filtered = [];
+ for (var i = 0; i < layers.length; i++) {
+ var groupOrLayer = layers[i];
+ if (CheckVisibility(groupOrLayer))
+ {
+ filtered.push(groupOrLayer);
+ }
+ }
+ return filtered;
+ } else {
+ return layers;
+ }
+}
+
function FillLayerList()
{
var list = document.getElementById("layers");
var listNames = document.getElementById("layerNames");
list.options.length = 0;
var map = GetParent().Fusion.getMapByName(mapName);
- var layers = map.getSelectableLayers();
+ var layers = GetSelectableLayers(map.getSelectableLayers());
if(layers.length > 0) {
for(var i = 0; i < layers.length; i++) {
var layer = layers[i];
Modified: trunk/widgets/SelectWithin.js
===================================================================
--- trunk/widgets/SelectWithin.js 2016-05-04 17:06:05 UTC (rev 2941)
+++ trunk/widgets/SelectWithin.js 2016-05-04 17:36:08 UTC (rev 2942)
@@ -45,7 +45,9 @@
this.bSelectionOnly = (json.DisableIfSelectionEmpty &&
(json.DisableIfSelectionEmpty[0] == 'true' ||
json.DisableIfSelectionEmpty[0] == '1')) ? true : false;
-
+ this.bOmitInvisibleLayers = (json.OmitInvisibleLayers &&
+ (json.OmitInvisibleLayers[0] == 'true' ||
+ json.OmitInvisibleLayers[0] == '1')) ? true : false;
this.additionalParameters = [];
if (json.AdditionalParameter) {
for (var i=0; i<json.AdditionalParameter.length; i++) {
@@ -104,6 +106,7 @@
} else {
params.push('popup=true');
}
+ params.push('omit_invisible_layers=' + (this.bOmitInvisibleLayers ? "1" : "0"));
params = params.concat(this.additionalParameters);
if (url.indexOf('?') < 0) {
Modified: trunk/widgets/widgetinfo/selectwithin.xml
===================================================================
--- trunk/widgets/widgetinfo/selectwithin.xml 2016-05-04 17:06:05 UTC (rev 2941)
+++ trunk/widgets/widgetinfo/selectwithin.xml 2016-05-04 17:36:08 UTC (rev 2942)
@@ -26,4 +26,12 @@
<DefaultValue>true</DefaultValue>
<IsMandatory>false</IsMandatory>
</Parameter>
+ <Parameter>
+ <Name>OmitInvisibleLayers</Name>
+ <Description>A flag to indicate if invisible layers that are in the current selection should be omitted from the list of layers to restrict</Description>
+ <Type>boolean</Type>
+ <Label>Omit invisible layers</Label>
+ <DefaultValue>false</DefaultValue>
+ <IsMandatory>false</IsMandatory>
+ </Parameter>
</WidgetInfo>
More information about the fusion-commits
mailing list