Hello all,
Is there an easy way to hide the "Remove link" button on subpanels to specific users?
I tried with roles but it doesn't work.
Thanks
Hello all,
Is there an easy way to hide the "Remove link" button on subpanels to specific users?
I tried with roles but it doesn't work.
Thanks
I don't think there is an out of the box way to do this (no Role based Subpanel Views that I know of) and I have not tried to do this but I can think of two main ways to do this. In both cases I would create a Role or other parameter in the Users module to determine who can/cannot unlink.
1) see if you can conditionally disable the button (which is what you are asking)
To disable the action you could try to extend the unlink-action field within the extension framework
clients/base/fields/unlink-action/unlink-action.js
and extend the hasAccess function to see if the user meets your criteria. If they don't have access to unlink then just return False, if they do, then just run them through the the standard has access checks.
2) capture the action, check the user, and tell them they can't if they are not allowed and stop the action from going through.
extend the clients/base/views/subpanel-list/subpanel-list.js
within the extension framework:
custom/clients/base/views/subpanel-list/subpanel-list.js
You can see there that there is an unlinkrow event which executes the warnUnlink function before doing anything else.
You could extend the warnUnlink function to first check the current user and block the execution of the showUnlinkMessage and warn the user with an alert that they don't have access to unlink, and set
self._modelToUnlink = null;
if they can continue, then call the super for warnUnlink and let the system to its thing.
Hope this helps,
FrancescaS