Newer
Older
<template>
<b-modal id="edit-group-modal" title="Edit group" ok-title="Update" @ok="updateGroup">
<b-form inline>
<label class="w-25" for="new-group-name-input">Group name:</label>
<b-form-input v-model="newGroupName" id="new-group-name-input" class="w-75" aria-describedby="new-group-name-input-feedback" :state="newGroupNameState" v-on:input="resetError" @keydown.native.enter.prevent="updateGroup">
<b-form-invalid-feedback id="new-group-name-input-feedback" class="text-right">{{newGroupNameError}}</b-form-invalid-feedback>
<b-form-checkbox class="mt-3 ml-3" v-model="allowChildGroups">allow child groups</b-form-checkbox>
</template>
<script>
import client from 'api-client';
export default {
computed: {
newGroupNameState() {
}
}
},
data: function() {
return {
groupId: '',
oldGroupName: '',
newGroupName: '',
newGroupNameError: '',
allowChildGroups: false,
reloadChildren: false
};
},
methods: {
resetError: function() {
this.newGroupNameError = null;
},
openEditGroupModal: function(group, reloadChildren) {
this.newGroupName = group.groupName;
this.groupId = group.groupId;
this.allowChildGroups = !group.leaf;
this.$bvModal.show('edit-group-modal');
this.reloadChildren = reloadChildren;
},
updateGroup: function(event) {
// Prevent modal from closing
event.preventDefault();
this.newGroupNameError = "Group name is required";
return;
}
if (this.oldGroupName === this.newGroupName) {
this.$bvModal.hide('edit-group-modal');
return;
}
client.updateGroup(this.groupId, this.newGroupName, !this.allowChildGroups, this.$store.state.input)
.then(res => {
if (this.reloadChildren) {
this.$store.commit('updateGroupsPanel', res);
} else {
this.$store.dispatch('updateCurrentGroup', {
newGroupName: this.newGroupName,
leaf: !this.allowChildGroups
});
}
Sonia Zorba
committed
this.$bvModal.hide('edit-group-modal');
})
.catch(res => {
this.newGroupNameError = res.message;
});
}
}
}
</script>