@@ -100,6 +103,7 @@ export default {
showCreateGroupModal: false,
showEditGroupModal: false,
newGroupName: "",
+ editedGroupName: "",
};
},
computed: {
@@ -182,6 +186,10 @@ export default {
});
this.download(json, "subscriptions.json", "application/json");
},
+ selectGroup(group) {
+ this.selectedGroup = group;
+ this.editedGroupName = group.groupName;
+ },
createGroup() {
if (!this.newGroupName || this.channelGroups.some(group => group.groupName == this.newGroupName)) return;
@@ -196,6 +204,21 @@ export default {
this.showCreateGroupModal = false;
},
+ editGroupName() {
+ const oldGroupName = this.selectedGroup.groupName;
+ const newGroupName = this.editedGroupName;
+
+ // the group mustn't yet exist and the name can't be empty
+ if (!newGroupName || newGroupName == oldGroupName) return;
+ if (this.channelGroups.some(group => group.groupName == newGroupName)) return;
+
+ // create a new group with the same info and delete the old one
+ this.selectedGroup.groupName = newGroupName;
+ this.createOrUpdateChannelGroup(this.selectedGroup);
+ this.deleteChannelGroup(oldGroupName);
+
+ this.showEditGroupModal = false;
+ },
deleteGroup(group) {
this.deleteChannelGroup(group.groupName);
this.channelGroups = this.channelGroups.filter(g => g != group);