Skip to content

Commit

Permalink
Only enable the filter tool in the toolbar if at least on layer has b…
Browse files Browse the repository at this point in the history
…een set in the filterable_layers list in the project config, either as anonymous functionalities or through a functionalities set to a role in the admin interface.
  • Loading branch information
ochriste committed Mar 6, 2019
1 parent 2a953b1 commit ca95dba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion contribs/gmf/apps/desktop/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
data-toggle="tooltip" data-placement="left" data-original-title="{{'Draw and Measure'|translate}}">
<span class="fa fa-paint-brush"></span>
</button>
<button ngeo-btn class="btn btn-default" ng-model="mainCtrl.filterSelectorActive"
<button ngeo-btn class="btn btn-default" ng-if="mainCtrl.filterSelectorEnabled" ng-model="mainCtrl.filterSelectorActive"
data-toggle="tooltip" data-placement="left" data-original-title="{{'Filter'|translate}}">
<span class="fa fa-filter"></span>
</button>
Expand Down
16 changes: 15 additions & 1 deletion contribs/gmf/src/controllers/AbstractAppController.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,18 @@ const exports = function(config, $scope, $injector) {
const user = evt.detail.user;
const roleId = (user.username !== null) ? user.role_id : undefined;

const functionalities = this.gmfUser.functionalities;

// Enable filter tool in toolbar
if (functionalities &&
'filterable_layers' in functionalities &&
functionalities['filterable_layers'].length > 0) {
this.filterSelectorEnabled = true;
}

// Open filter panel if 'open_panel' is set in functionalities and
// has 'layer_filter' as first value
this.gmfThemes_.getThemesObject().then((themes) => {
const functionalities = this.gmfUser.functionalities;
if (functionalities &&
functionalities.open_panel &&
functionalities.open_panel[0] === 'layer_filter') {
Expand Down Expand Up @@ -276,6 +284,12 @@ const exports = function(config, $scope, $injector) {
stroke: queryStroke
});

/**
* @type {boolean}
* @export
*/
this.filterSelectorEnabled = false;

/**
* @type {boolean}
* @export
Expand Down

0 comments on commit ca95dba

Please sign in to comment.