Skip to content

Commit

Permalink
11679 - Fix bug causing Edit button to not display in the map popup
Browse files Browse the repository at this point in the history
  • Loading branch information
bferguso authored and chiatt committed Dec 12, 2024
1 parent e46e0ca commit fefd063
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
22 changes: 13 additions & 9 deletions arches/app/media/js/viewmodels/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,17 @@ define([
var id = data.resourceinstanceid;
const userid = ko.unwrap(self.userid);
data.showFilterByFeatureButton = !!params.search;
data.showEditButton = false;
data.sendFeatureToMapFilter = mapPopupProvider.sendFeatureToMapFilter.bind(mapPopupProvider);
data.showFilterByFeature = mapPopupProvider.showFilterByFeature.bind(mapPopupProvider);
const descriptionProperties = ['displayname', 'graph_name', 'map_popup', 'geometries'];
const setEditButtonVisibility = function(data)
{
const isFeatureEditable = self.canEdit &&
ko.unwrap(data.permissions)?.users_without_edit_perm?.includes(userid) === false ||
ko.unwrap(data.permissions)?.principal_user?.includes(userid) ||
ko.unwrap(data.permissions)?.users_edit?.includes(userid);
data.showEditButton(isFeatureEditable);
}
if (id) {
if (!self.resourceLookup[id]){
data = _.defaults(data, {
Expand All @@ -358,21 +365,16 @@ define([
'map_popup': '',
'geometries': [],
'feature': feature,
'showEditButton': ko.observable(false)
});

if (data.permissions) {
try {
data.permissions = JSON.parse(ko.unwrap(data.permissions));
} catch (err) {
data.permissions = koMapping.toJS(ko.unwrap(data.permissions));
}

const hasInstanceEditPermission = data.permissions.users_without_edit_perm?.includes(userid) === false ||
data.permissions.principal_user?.includes(userid) ||
data.permissions.users_edit?.includes(userid);

if (self.canEdit && hasInstanceEditPermission) {
data.showEditButton = true;
}
setEditButtonVisibility(data);
}
descriptionProperties.forEach(prop => data[prop] = ko.observable(data[prop]));
data.reportURL = arches.urls.resource_report;
Expand All @@ -381,6 +383,8 @@ define([
$.get(arches.urls.resource_descriptors + id, function(data) {
data.loading = false;
descriptionProperties.forEach(prop => self.resourceLookup[id][prop](data[prop]));
self.resourceLookup[id].permissions = data["permissions"];
setEditButtonVisibility(self.resourceLookup[id]);
});
}
self.resourceLookup[id].feature = feature;
Expand Down
1 change: 1 addition & 0 deletions releases/7.6.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Fix Graph Designer failure when editing large graphs #[11615](https://github.com/archesproject/arches/issues/11615)
- Fix failure to download exported search results when using non file-system based storages #[11620](https://github.com/archesproject/arches/issues/11620)
- Cache resource relationship preflabels to improve report load time #[11583](https://github.com/archesproject/arches/issues/11583)
- Fix bug causing the Edit button to not display in the map popup #[11679](https://github.com/archesproject/arches/issues/11679)

### Dependency changes:

Expand Down

0 comments on commit fefd063

Please sign in to comment.