简体   繁体   中英

Return multi-level menu drawer navigation items based on permissions

Function doesn't return particular item, instead of it returns whole group where the given item exists.

In given codepen example: https://codepen.io/simon.network/pen/YzvgVBa?editors=1011

user has permissions:

userPermissionGroup: [
        "dictionary_company_high_department",
        "dictionary_company_department",
        "user_user"
      ]

And menu returns entire groups in the menu where items with those permissions exists instead of just three items in two groups

Working solution in the codepen: https://codepen.io/simon.network/pen/YzvgVBa?editors=0111

Basically I can use computed properties in Vue stacked together, so I created two computed properties: filterSubItems(subItems) for menu search and filterSubItemsByPermissions(subItems) for menu permissions.

<v-list-item
    v-for="child in filterSubItems(filterSubItemsByPermissions(item.items))"
    :key="child.title"
    :to="child.link"
    dense
    link
    >
    <v-list-item-content>
      <v-list-item-title>{{ child.title }}</v-list-item-title>
    </v-list-item-content>
</v-list-item>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM