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 { ...@@ -35,7 +35,7 @@ export default {
addGroup() { addGroup() {
return fetch(groupsPanel); return fetch(groupsPanel);
}, },
renameGroup() { updateGroup() {
return fetch(groupsPanel); return fetch(groupsPanel);
}, },
removeGroup() { removeGroup() {
......
...@@ -145,7 +145,7 @@ export default { ...@@ -145,7 +145,7 @@ export default {
}) })
}); });
}, },
renameGroup(groupId, newGroupName, leaf, input) { updateGroup(groupId, newGroupName, leaf, input) {
let url = BASE_API_URL + 'group/' + groupId; let url = BASE_API_URL + 'group/' + groupId;
return apiRequest(url, { return apiRequest(url, {
method: 'PUT', method: 'PUT',
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<b-list-group-item href="#" v-on:click="openGroup(group)"> <b-list-group-item href="#" v-on:click="openGroup(group)">
<span class="float-left">{{group.groupName}}</span> <span class="float-left">{{group.groupName}}</span>
<span v-if="group.permission === 'ADMIN'" class="float-right"> <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> <font-awesome-icon icon="edit"></font-awesome-icon>
</a> </a>
&nbsp; &nbsp;
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
<p v-if="model.groupsPanel.items.length === 0">No groups</p> <p v-if="model.groupsPanel.items.length === 0">No groups</p>
</div> </div>
<Paginator :paginatedPanel="model.groupsPanel" :onUpdate="updatePagination" :paginatorInput="input" /> <Paginator :paginatedPanel="model.groupsPanel" :onUpdate="updatePagination" :paginatorInput="input" />
<RenameGroupModal ref="renameGroupModal" /> <EditGroupModal ref="editGroupModal" />
<ConfirmRemoveGroupModal ref="confirmRemoveGroupModal" /> <ConfirmRemoveGroupModal ref="confirmRemoveGroupModal" />
</b-tab> </b-tab>
</template> </template>
<script> <script>
import RenameGroupModal from './modals/RenameGroupModal.vue'; import EditGroupModal from './modals/EditGroupModal.vue';
import ConfirmRemoveGroupModal from './modals/ConfirmRemoveGroupModal.vue'; import ConfirmRemoveGroupModal from './modals/ConfirmRemoveGroupModal.vue';
import Paginator from './Paginator.vue'; import Paginator from './Paginator.vue';
import { import {
...@@ -42,7 +42,7 @@ import debounce from 'debounce'; // for delaying the input event (search filter) ...@@ -42,7 +42,7 @@ import debounce from 'debounce'; // for delaying the input event (search filter)
export default { export default {
name: 'GroupsPanel', name: 'GroupsPanel',
components: { components: {
RenameGroupModal, EditGroupModal,
ConfirmRemoveGroupModal, ConfirmRemoveGroupModal,
Paginator Paginator
}, },
...@@ -54,8 +54,8 @@ export default { ...@@ -54,8 +54,8 @@ export default {
openGroup: function(group) { openGroup: function(group) {
this.$store.commit('openGroup', group.groupId); this.$store.commit('openGroup', group.groupId);
}, },
openRenameGroupModal: function(group) { openEditGroupModal: function(group) {
this.$refs.renameGroupModal.openRenameGroupModal(group); this.$refs.editGroupModal.openEditGroupModal(group);
}, },
openRemoveGroupModal: function(group) { openRemoveGroupModal: function(group) {
this.$refs.confirmRemoveGroupModal.openRemoveGroupModal(group); this.$refs.confirmRemoveGroupModal.openRemoveGroupModal(group);
......
<template> <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> <b-form inline>
<label class="w-25" for="new-group-name-input">Group name:</label> <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"> <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 @@ ...@@ -14,7 +14,7 @@
import client from 'api-client'; import client from 'api-client';
export default { export default {
name: 'RenameGroupModal', name: 'EditGroupModal',
computed: { computed: {
newGroupNameState() { newGroupNameState() {
if (this.newGroupNameError) { if (this.newGroupNameError) {
...@@ -36,13 +36,13 @@ export default { ...@@ -36,13 +36,13 @@ export default {
resetError: function() { resetError: function() {
this.newGroupNameError = null; this.newGroupNameError = null;
}, },
openRenameGroupModal: function(group) { openEditGroupModal: function(group) {
this.newGroupName = group.groupName; this.newGroupName = group.groupName;
this.groupId = group.groupId; this.groupId = group.groupId;
this.leaf = group.leaf; 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 // Prevent modal from closing
event.preventDefault(); event.preventDefault();
...@@ -52,17 +52,17 @@ export default { ...@@ -52,17 +52,17 @@ export default {
} }
if (this.oldGroupName === this.newGroupName) { if (this.oldGroupName === this.newGroupName) {
this.$bvModal.hide('rename-group-modal'); this.$bvModal.hide('edit-group-modal');
return; 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 => { .then(res => {
if (res.status === 400) { if (res.status === 400) {
this.newGroupNameError = res.message; this.newGroupNameError = res.message;
} else { } else {
this.$store.commit('updateGroupsPanel', res); 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