Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

Updates to editing request.

thehollidayinn16bcb65d94e9
diff --git a/components/collections/addCollection.vue b/components/collections/addCollection.vue
index ece90297e..94619f00b 100644
--- a/components/collections/addCollection.vue
+++ b/components/collections/addCollection.vue
@@ -53,7 +53,7 @@ export default {
},
watch: {
show() {
- if (!this.editingCollection.collectionIndex);
+ if (!this.editingCollection.collectionIndex) return;
this.newCollection = Object.assign({}, this.editingCollection);
},
},
diff --git a/components/collections/addFolder.vue b/components/collections/addFolder.vue
index 090b0b73e..b318d0b43 100644
--- a/components/collections/addFolder.vue
+++ b/components/collections/addFolder.vue
@@ -50,7 +50,7 @@ export default {
},
watch: {
show() {
- if (!this.editingFolder.folderIndex);
+ if (!this.editingFolder.folderIndex) return;
this.newFolder = Object.assign({}, this.editingFolder);
},
},
diff --git a/components/collections/collection.vue b/components/collections/collection.vue
index c7284f409..138c41bca 100644
--- a/components/collections/collection.vue
+++ b/components/collections/collection.vue
@@ -69,6 +69,7 @@
padding: 0;
width: 20px;
margin: 0;
+ margin-right: .2rem;
height: 20px;
border-radius: 50%;
}
diff --git a/components/collections/folder.vue b/components/collections/folder.vue
index 120dbe7eb..5706d0ed9 100644
--- a/components/collections/folder.vue
+++ b/components/collections/folder.vue
@@ -42,6 +42,7 @@
padding: 0;
width: 20px;
margin: 0;
+ margin-right: .2rem;
height: 20px;
border-radius: 50%;
}
diff --git a/components/collections/saveRequest.vue b/components/collections/saveRequest.vue
index b29b432fb..7f5d31037 100644
--- a/components/collections/saveRequest.vue
+++ b/components/collections/saveRequest.vue
@@ -71,6 +71,26 @@ export default {
show() {
this.request = Object.assign(this.request, this.editingRequest);
},
+ 'request.collection': function (newValue, oldValue) {
+ if (!oldValue) return;
+
+ if (newValue === oldValue) {
+ delete this.request.oldCollection;
+ return;
+ }
+ this.request.oldFolder = this.request.folder;
+ this.request.folder = -1;
+ this.request.oldCollection = oldValue;
+ },
+ 'request.folder': function (newValue, oldValue) {
+ if (!oldValue) return;
+
+ if (newValue === oldValue) {
+ delete this.request.oldFolder;
+ return;
+ }
+ this.request.oldFolder = oldValue;
+ }
},
computed: {
collections() {
diff --git a/store/postwoman.js b/store/postwoman.js
index eb7a36659..2f021683d 100644
--- a/store/postwoman.js
+++ b/store/postwoman.js
@@ -111,6 +111,21 @@ export const mutations = {
saveRequest (state, payload) {
const { request } = payload;
+
+ // Remove the old request from collection
+ if (request.hasOwnProperty('oldCollection') && request.oldCollection > -1) {
+ const folder = request.hasOwnProperty('oldFolder') && request.oldFolder >= -1 ? request.oldFolder : request.folder;
+ if (folder > -1) {
+ state.collections[request.oldCollection].folders[folder].requests.splice(request.requestIndex, 1)
+ } else {
+ state.collections[request.oldCollection].requests.splice(request.requestIndex, 1)
+ }
+ } else if (request.hasOwnProperty('oldFolder') && request.oldFolder !== -1) {
+ state.collections[request.collection].folders[folder].requests.splice(request.requestIndex, 1)
+ }
+
+ delete request.oldCollection;
+ delete request.oldFolder;
// Request that is directly attached to collection
if (request.folder === -1) {