I have a Vue component which has a template that goes like this:
<template>
<div>
<div class="row" >
<button class="btn btn-primary" style="margin-bottom:20px" @click="changeSelectedComp">Back</button>
<button class="btn btn-primary" style="margin-left:1000px" @click="EditMode">Edit</button>
</div>
<vue-tabs>
<v-tab title="Basic">
<app-players></app-players>
</v-tab>
<v-tab title="History">
<app-histories></app-histories>
</v-tab>
<v-tab title="Timetable">
<app-timetables></app-timetables>
</v-tab>
<v-tab title="Scholarship">
<app-scholarship></app-scholarship>
</v-tab>
</vue-tabs>
</div>
</template>
What I want to achieve is to hide the tabs History
, Timetable
and Scholarship
if this statement is true:
IsCurrentUserMemberOfGroup("Admins", function (isCurrentUserInGroup) {
if(isCurrentUserInGroup) {
// hide the tabs
}
});
This is the IsCurrentUserMemberOfGroup
function:
function IsCurrentUserMemberOfGroup(groupName, OnComplete) {
var currentContext = new SP.ClientContext.get_current();
var currentWeb = currentContext.get_web();
var currentUser = currentContext.get_web().get_currentUser();
currentContext.load(currentUser);
var allGroups = currentWeb.get_siteGroups();
currentContext.load(allGroups);
var group = allGroups.getByName(groupName);
currentContext.load(group);
var groupUsers = group.get_users();
currentContext.load(groupUsers);
currentContext.executeQueryAsync(OnSuccess,OnFailure);
function OnSuccess(sender, args) {
var userInGroup = false;
var groupUserEnumerator = groupUsers.getEnumerator();
while (groupUserEnumerator.moveNext()) {
var groupUser = groupUserEnumerator.get_current();
if (groupUser.get_id() == currentUser.get_id()) {
userInGroup = true;
break;
}
}
OnComplete(userInGroup);
}
function OnFailure(sender, args) {
OnComplete(false);
}
}
I looked at v-if
(Conditional rendering), but haven't understood the syntax. Tried <vue-tabs v-if="IsCurrentMemberofGroup">
, but it wouldn't work.
How can I hide the tabs if the if statement is true? (Here's the full component)
Aucun commentaire:
Enregistrer un commentaire