Adapting editor window actions to read-only situation

Hi

Some of our users are not allowed to write entities, this is fairly common. But once, while testing with a user after ajusting its profile to read-only, I got afraid when he opened an editor and I saw the “save & close” & “save” buttons.

Fortunately, he had “access refused” when he tried to save, which is expected behavior. However, displaying “save & close” & “save” buttons when user don’t have write access to the entity is confusing.

So I provide here a small class replacing CUBA edit actions frames (simple & extended ones), and adjusting automatically the editor buttons setup depending on the user having write access or not to the entity

To use it, simply extend edit-window.actions.xml and extended-edit-window.actions.xml frames and set the controller to be ExtExtendedEditWindowActionsFrame.

Sample project attached, with screens for Customer (using simple edit actions Ok & Cancel) & CustomerOrder (using “Save & Close”, “Save”, and “Cancel” buttons).

To use it log in as admin, create a “readonly” role of type “readonly”, assign it to a new user “readonly” (e.g), then creates entities (still as admin).

Then login as readonly and notice that when you open an entity editor you will have a single “Ok” button which is behinf the scene mapped to Window Close (<=> cancel).

Michael

editactions.zip (93.3 KB)

4 Likes