In my Vue.js application, I have implemented a navigation drawer to display the different pages accessible to users. The visibility of each page is determined by the activation status of the related module, indicated by a unique moduleID
assigned to each page and its children. The list of displayed pages is populated by the array filteredPages[]
, which contains only the pages that the user has access to. The complete set of pages is stored in the original data source pages[]
.
To summarize, a page will only be displayed if both of the following conditions are met:
activatedModules[]
contains themoduleID
of the page and its children.userPermissions[]
includes thepermissions
value required for the children (or the page itself if there are no children).
Here is an excerpt of my code structure:
export default {
data: () => ({
// Pages information with their respective moduleIDs and permissions
pages: [
// Page "Team" containing "Dashboard" as child
{
text: 'Team', moduleID: 'm1',
children: [
{ text: 'Dashboard', route:'team/dashboard', permissions: 'p101', moduleID: 'm1-1' },
],
},
// Other pages with similar hierarchy and permission setup
],
// Array defining activated modules
activatedModules: ['m1', 'm1-1', 'm3', 'm3-1', 'm3-2', 'm4', 'm4-1', 'm4-2', 'm5'],
// User permissions required for accessing certain pages
userPermissions: ['p101', 'p301', 'p302', 'p402', 'p50'],
filteredPages: []
}),
computed: {
filterArray() {
// Need assistance in implementing the filtering logic here
}
}
}
The expected output after filtering should look like this:
filteredPages: [
// Displayed pages based on user's permissions and activated modules
]
User permissions are managed and stored in Firebase Cloud Firestore, illustrated by the provided screenshot.
If you can assist in finalizing the filtering process for the array, it would be greatly appreciated.