Custom button with permission level is displayed only after page refresh

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Vit
    replied
    Thank you so much. It worked

    Leave a comment:


  • yuri
    replied
    Code:
    this.view.getAcl()

    Leave a comment:


  • Vit
    replied
    Is this.getAcl().getPermissionLevel() method visible in handlers?

    Leave a comment:


  • yuri
    replied
    Use a handler instead. Not the view.

    Leave a comment:


  • Vit
    replied
    Moving logic from setup to afterRender function did not help.

    Leave a comment:


  • Custom button with permission level is displayed only after page refresh

    I've added some buttons via extending views/details this way

    Code:
    define(['views/detail'], (DetailView) => {
    return class DetailExtendView extends DetailView{
    setup(){
    super.setup();
    .....
    if (this.getAcl().getPermissionLevel('gw') === 'team'
    || this.getAcl().getPermissionLevel('gw') === 'all'
    ) {
    this.addMenuItem('buttons', {
    name: 'add-gw',
    iconHtml: '<span class="fas fa-suitcase" style="color:#e5e5e5"></span>',
    className: 'btn-success',
    acl: 'edit',
    text: this.translate('Add GW'),
    onClick: () => this.actionAddGw(),
    });
    }

    They are displayed fine for admin users. For users with appropriate permission, their display varies with how you open entity details

    Steps to recreate
    1. Click on an entity in the main menu
    2. Click on an item to enter entity details
    (button is not displayed)
    3. Refresh the page
    (button is displayed)
    4. Click on an entity name (not in the menu)
    5. Click on an item to enter entity details
    (button is not displayed)
    6. Click on another entity in the menu.
    7. Click on the target entity
    8. Click on the entity item
    (button is displayed)

    I believe that it's a matter of caching buttons or rendered views.

    Extending views/record/detail won't work as it has no addMenuItem function in it, and can not be called thus.

    Setting button with adding them in clientDefs is an option though, but I do not know how to check getPermissionLevel globally, not for a particular entity

    Click image for larger version  Name:	image.png Views:	3 Size:	19.9 KB ID:	119177
    Last edited by Vit; 07-05-2025, 03:15 PM.
Working...