Skip to content

Commit

Permalink
Merge branch 'hotfix/user-contact-field' into fix/user-contacts-access
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Zaritskyi committed Nov 25, 2024
2 parents 5cfcec4 + 33be7e3 commit 659db83
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ export default {
route: this.$route,
});
},
hasReadAccessToContacts() {
return this.$store.getters['userinfo/HAS_ACCESS_TO_OBJECT']('contacts');
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
/>

<wt-select
:disabled="disableUserInput"
:disabled="!hasReadAccessToContacts"
:label="$tc('vocabulary.contact', 1)"
:search-method="loadContactsOptions"
:value="itemInstance.contact"
Expand Down Expand Up @@ -85,5 +85,4 @@ export default {
};
</script>

<style lang="scss" scoped>
</style>
<style lang="scss" scoped></style>
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,12 @@ export default Object.freeze([
// PERMISSIONS
{ field: null, name: AdminSections.OBJECTS, route: RouteNames.OBJECTS }, // permissions: add
{ field: 'roles', name: AdminSections.ROLES, route: RouteNames.ROLES }, // scope: roles

// Not used in ui sections
// it used for check if some entities have access to this object
{
field: 'contacts',
name: 'contacts',
route: null, // there is no associated section and route in Admin
},
]);
8 changes: 8 additions & 0 deletions src/modules/userinfo/store/userinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ const getters = {
}, []),

IS_CHANGE_USER_PASSWORD_ALLOW: (state) => !!state.permissions.change_user_password,

// FIXME: remove this getter after refactoring of userinfo module in SDK
HAS_ACCESS_TO_OBJECT: (state, getters) => (objectName) => {
const objectScope = getters.GET_OBJECT_SCOPE({ name: objectName });
if (!objectScope) return false;
// don`t used existing HAS_READ_ACCESS, because it have CHECK_OBJECT_ACCESS inside (UI-access)
return objectScope.access.includes('r');
},
};

const actions = {
Expand Down

0 comments on commit 659db83

Please sign in to comment.