From 2401dcb8a47f15fb4264a4a4a2fb76c7bea475c6 Mon Sep 17 00:00:00 2001 From: Davide Alberani Date: Sun, 12 Feb 2017 11:47:53 +0100 Subject: [PATCH] fixes #21: groups can be renamed --- src/Group.vue | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/src/Group.vue b/src/Group.vue index 7f04e54..21841ad 100644 --- a/src/Group.vue +++ b/src/Group.vue @@ -16,6 +16,10 @@ edit notes edit + + rename group + label + delete group delete @@ -94,6 +98,15 @@ :md-cancel-text="noteDialog.cancel" ref="dialogGroupNotes"> + + { + this.groupsInfoUrl.update( + {day: this.day, group: this.group.group}, + {notes: this.groupNotes}).then((response) => { return response.json(); }, (response) => { this.$refs.dialogObj.show({text: 'unable to edit group notes'}); @@ -222,14 +239,36 @@ export default { if (type != 'ok' || !this.group || !this.group.group || !this.day || !this.loggedInUser.isAdmin) { return; } - var data = {day: this.day, group: this.group.group}; - this.groupsUrl.delete(data).then((response) => { + this.groupsUrl.delete({day: this.day, group: this.group.group}).then((response) => { return response.json(); }, (response) => { this.$refs.dialogObj.show({text: 'unable to delete this group'}); }).then((json) => { this.$emit('updated'); }); + }, + + openRenameGroupDialog() { + this.$refs.dialogRenameGroup.open(); + }, + + dialogRenameGroupOpen() { + this.groupNewName = this.group.group || ''; + }, + + dialogRenameGroupClose(type) { + if (type != 'ok' || !this.group || !this.group.group || !this.day || !this.groupNewName) { + return; + } + this.groupsUrl.update( + {day: this.day, group: this.group.group}, + {newName: this.groupNewName}).then((response) => { + return response.json(); + }, (response) => { + this.$refs.dialogObj.show({text: 'unable to rename this group'}); + }).then((json) => { + this.$emit('updated'); + }); } },