Commit 3400d77f authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Renamed rename group functionality to edit group

parent 9e0d84c6
......@@ -35,7 +35,7 @@ export default {
addGroup() {
return fetch(groupsPanel);
},
renameGroup() {
updateGroup() {
return fetch(groupsPanel);
},
removeGroup() {
......
......@@ -145,7 +145,7 @@ export default {
})
});
},
renameGroup(groupId, newGroupName, leaf, input) {
updateGroup(groupId, newGroupName, leaf, input) {
let url = BASE_API_URL + 'group/' + groupId;
return apiRequest(url, {
method: 'PUT',
......
......@@ -10,7 +10,7 @@
<b-list-group-item href="#" v-on:click="openGroup(group)">
<span class="float-left">{{group.groupName}}</span>
<span v-if="group.permission === 'ADMIN'" class="float-right">
<a href="#" v-on:click.stop="openRenameGroupModal(group)" title="Rename">
<a href="#" v-on:click.stop="openEditGroupModal(group)" title="Edit">
<font-awesome-icon icon="edit"></font-awesome-icon>
</a>
&nbsp;
......@@ -23,13 +23,13 @@
<p v-if="model.groupsPanel.items.length === 0">No groups</p>
</div>
<Paginator :paginatedPanel="model.groupsPanel" :onUpdate="updatePagination" :paginatorInput="input" />
<RenameGroupModal ref="renameGroupModal" />
<EditGroupModal ref="editGroupModal" />
<ConfirmRemoveGroupModal ref="confirmRemoveGroupModal" />
</b-tab>
</template>
<script>
import RenameGroupModal from './modals/RenameGroupModal.vue';
import EditGroupModal from './modals/EditGroupModal.vue';
import ConfirmRemoveGroupModal from './modals/ConfirmRemoveGroupModal.vue';
import Paginator from './Paginator.vue';
import {
......@@ -42,7 +42,7 @@ import debounce from 'debounce'; // for delaying the input event (search filter)
export default {
name: 'GroupsPanel',
components: {
RenameGroupModal,
EditGroupModal,
ConfirmRemoveGroupModal,
Paginator
},
......@@ -54,8 +54,8 @@ export default {
openGroup: function(group) {
this.$store.commit('openGroup', group.groupId);
},
openRenameGroupModal: function(group) {
this.$refs.renameGroupModal.openRenameGroupModal(group);
openEditGroupModal: function(group) {
this.$refs.editGroupModal.openEditGroupModal(group);
},
openRemoveGroupModal: function(group) {
this.$refs.confirmRemoveGroupModal.openRemoveGroupModal(group);
......
<template>
<b-modal id="rename-group-modal" title="Rename group" ok-title="Rename" @ok="renameGroup">
<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">
......@@ -14,7 +14,7 @@
import client from 'api-client';
export default {
name: 'RenameGroupModal',
name: 'EditGroupModal',
computed: {
newGroupNameState() {
if (this.newGroupNameError) {
......@@ -36,13 +36,13 @@ export default {
resetError: function() {
this.newGroupNameError = null;
},
openRenameGroupModal: function(group) {
openEditGroupModal: function(group) {
this.newGroupName = group.groupName;
this.groupId = group.groupId;
this.leaf = group.leaf;
this.$bvModal.show('rename-group-modal');
this.$bvModal.show('edit-group-modal');
},
renameGroup: function(event) {
updateGroup: function(event) {
// Prevent modal from closing
event.preventDefault();
......@@ -52,17 +52,17 @@ export default {
}
if (this.oldGroupName === this.newGroupName) {
this.$bvModal.hide('rename-group-modal');
this.$bvModal.hide('edit-group-modal');
return;
}
client.renameGroup(this.groupId, this.newGroupName, this.leaf, this.$store.state.input)
client.updateGroup(this.groupId, this.newGroupName, this.leaf, this.$store.state.input)
.then(res => {
if (res.status === 400) {
this.newGroupNameError = res.message;
} else {
this.$store.commit('updateGroupsPanel', res);
this.$bvModal.hide('rename-group-modal');
this.$bvModal.hide('edit-group-modal');
}
});
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment