There are 3 desks in a table with role IDs 2, 4, and 6. In this scenario, two tables are involved. The goal is to dynamically display a specific role name on a button based on the current user's role ID.
The desired displays are:
- If the current user's role ID is 2, then show the role name associated with role ID 4
- If the current user's role ID is 4, then display the role name linked to role ID 6
User Table https://i.stack.imgur.com/XLLyA.png
Registration Table https://i.stack.imgur.com/pVG7N.png
Code Snippet
<span v-if="user.user_role_id ==results.desk_user_role_id">
<v-btn small color="primary" v-on:click="getNextDesk" style="width:400px;">Forward to </v-btn>
<v-btn small color="primary" v-on:click="getPreviousDesk" style="width:400px;">Revert </v-btn>
</span>
Script Implementation
getNextDesk(currentdeskid) {
if (currentdeskid === 2) {
return 'Technical Desk';
}
if (currentdeskid === 4) {
return 'Executive Desk';
}
return '';
},
getPreviousDesk(currentdeskid) {
if (currentdeskid === 6) {
return 'Technical Desk';
}
if (currentdeskid === 4) {
return 'Registration Desk';
}
return '';
},