Commit 5816f213 authored by Danilo Trombino's avatar Danilo Trombino
Browse files

Mutual Exclusion on Layers

parent ffa0accc
......@@ -1177,6 +1177,31 @@ function cockpitWidgetControllerFunction(
return false;
}
$scope.mutualExclusionToggle = function() {
$scope.ngModel.mutualExclusion = !$scope.ngModel.mutualExclusion;
console.log($scope.ngModel.mutualExclusion);
if($scope.ngModel.mutualExclusion !== undefined) {
var l = $scope.getLayerByName($scope.ngModel.content.layers[0].name);
if (!l) return; //do nothing
l.setVisible(true);
if( $scope.ngModel.mutualExclusion === true) {
//By default select only the first layer
for(var i = 1; i < $scope.ngModel.content.layers.length ; i++) {
var l = $scope.getLayerByName($scope.ngModel.content.layers[i].name);
if (!l) return; //do nothing
l.setVisible(false);
}
} else {
//By default select all layers
for(var i = 1; i < $scope.ngModel.content.layers.length ; i++) {
var l = $scope.getLayerByName($scope.ngModel.content.layers[i].name);
if (!l) return; //do nothing
l.setVisible(true);
}
}
}
}
$scope.modalQuickWidget= function(ev) {
if($scope.ngModel.type == 'chart'){
$scope.addTableFromChart("table");
......
......@@ -104,6 +104,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<md-icon md-font-icon="fa fa-mouse-pointer" ng-show="ngModel.cliccable"></md-icon>
<md-icon md-font-icon="fa fa-filter" ng-show="!ngModel.cliccable"></md-icon>
</md-button>
<!-- XOR BUTTON -->
<md-button class="md-icon-button " ng-init="ngModel.mutualExclusion=false" ng-if="ngModel.type=='map'" aria-label="mutual exclusion button" ng-click="mutualExclusionToggle();$event.stopPropagation();" >
<md-tooltip md-direction="top" md-delay="1000">View only one layer at time</md-tooltip>
<md-icon md-font-icon="fa fa-long-arrow-right" ng-if="ngModel.mutualExclusion==false"></md-icon>
<md-icon md-font-icon="fa fa-arrows-h" ng-if="ngModel.mutualExclusion==true"></md-icon>
</md-button>
<!-- quick widget BUTTON -->
<md-button class="md-icon-button " ng-if="ngModel.type=='chart' || ngModel.type=='table' || ngModel.type=='map'" aria-label="expand button" ng-click="modalQuickWidget($event);$event.stopPropagation();" >
......
......@@ -641,11 +641,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//control panel events
$scope.toggleLayer = function(e,n){
e.stopPropagation();
var l = $scope.getLayerByName(n);
if (!l) return; //do nothing
var toggle = !l.getVisible();
l.setVisible(!l.getVisible());
e.stopPropagation();
console.log($scope.ngModel.mutualExclusion);
if($scope.ngModel.mutualExclusion === false) {
console.log("Non mutual exclusion");
var l = $scope.getLayerByName(n);
if (!l) return; //do nothing
var toggle = !l.getVisible();
l.setVisible(!l.getVisible());
} else {
console.log("Mutual exclusion, layer selected: "+n);
var l = $scope.getLayerByName(n);
if (!l) return; //do nothing
l.setVisible(true);
for(var i in $scope.ngModel.content.layers) {
var layerName = $scope.ngModel.content.layers[i].name;
console.log(layerName);
if(n !== layerName ) {
console.log("setting to false");
var l_tmp = $scope.getLayerByName(layerName);
if (!l_tmp) return; //do nothing
l_tmp.setVisible(false);
}
}
}
}
$scope.toggleLayerExpanse = function(layer){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment