Use _permission data
In we added support for enhancing JSON objects with permissions for the current user:
{
"uuid": "95493e3d-ccf4-4357-803a-7632c5fda034",
"id": 1,
"version": 1,
"active": true,
"createdBy": 1,
"createdDate": 1513622186000,
"lastModifiedBy": 1,
"lastModifiedDate": 1513622203000,
"shortName": "GCDT",
"name": "Global Crop Diversity Trust",
"description": "The Global Crop Diversity Trust is an international organization with Headquarters in Bonn, Germany whose mission is to ensure the conservation and availability of crop diversity for food security worldwide.",
"urls": null,
"wiewsCodes": null,
"_permissions": {
"create": true,
"read": true,
"write": true,
"delete": true,
"manage": true
}
}
The _permissions
property is automagically added to all objects that support ACL security on the server (examples Partner
, Dataset
, Descriptor
, ...).
- Declare a class
CurrentPermissions
with boolean properties as seen above (create
,read
, ...) - Declare an interface
IUserPermissions
in the client model with_permissions: CurrentPermissions;
- Update relevant class declarations of the model to implement
IUserPermissions
- Update user interface so that
Edit
orDelete
buttons are displayed whenwrite===true
ordelete===true
respectively.
Example
The "Edit" button on https://catalog.demo.genesys-pgr.org/partner/95493e3d-ccf4-4357-803a-7632c5fda034 should only be displayed if the _permissions.write
of this Partner record is true
.