Skip to content

Commit

Permalink
Merge pull request #2354 from okauppinen/admin-layer-search-index
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakarFin authored Jul 27, 2023
2 parents 6369f43 + b243d57 commit 3089a67
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bundles/framework/layerlist/model/LayerGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class LayerGroup {
this.groups = groups || [];
this.searchIndex = {};
this.tools = [];
this._isAdmin = Oskari.user().isAdmin();
}

getParentId () {
Expand Down Expand Up @@ -104,10 +105,15 @@ export class LayerGroup {
newLayers.forEach(layer => this.addLayer(layer));
}
_getSearchIndex (layer) {
var val = layer.getName() + ' ' +
let val = layer.getName() + ' ' +
layer.getInspireName() + ' ' +
layer.getOrganizationName();
// TODO: maybe filter out undefined texts
if (this._isAdmin) {
val = val + ' ' +
layer.getId() + ' ' +
layer.getLayerName();
}
return val.toLowerCase();
}
matchesKeyword (layerId, keyword) {
Expand Down
7 changes: 7 additions & 0 deletions src/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

function (userData) {
this._loggedIn = false;
this._admin = false;
this._roles = [];
if (userData) {
this._firstName = userData.firstName;
Expand All @@ -53,6 +54,9 @@
if (userData.userUUID) {
this._loggedIn = true;
}
if (userData.admin === true) {
this._admin = true;
}
this._apiKey = userData.apikey;
}
}, {
Expand Down Expand Up @@ -145,6 +149,9 @@
isLoggedIn: function () {
return this._loggedIn;
},
isAdmin: function () {
return this._admin;
},
/**
* @method getRoles
* Roles for the user
Expand Down

0 comments on commit 3089a67

Please sign in to comment.