Newer
Older
<template>
<b-modal id="add-group-modal" title="Add group" @show="resetModal" @shown="afterShow" ok-title="Add" @ok="addGroup">
<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" ref="newGroupNameInput" class="w-75" aria-describedby="new-group-name-input-feedback" :state="newGroupNameState" v-on:input="resetError" @keydown.native.enter="addGroup">
<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="leaf">is leaf</b-form-checkbox>
</template>
<script>
import client from 'api-client';
export default {
name: 'AddGroupModal',
computed: {
newGroupNameState() {
}
}
},
data: function() {
return {
newGroupName: '',
newGroupNameError: '',
};
},
methods: {
resetModal: function() {
this.newGroupName = null;
this.resetError();
},
afterShow: function() {
this.$refs.newGroupNameInput.focus();
},
resetError: function() {
this.newGroupNameError = null;
},
addGroup: function(event) {
// Prevent modal from closing
event.preventDefault();
this.newGroupNameError = "Group name is required";
client.addGroup(this.newGroupName, this.leaf, this.$store.state.input)
Sonia Zorba
committed
this.$store.commit('updateGroupsPanel', res);
this.$bvModal.hide('add-group-modal');
})
.catch(res => {
this.newGroupNameError = res.message;
}
}
}
}
</script>