diff --git a/components/collections/index.vue b/components/collections/index.vue index 4772ab5b..70f25648 100644 --- a/components/collections/index.vue +++ b/components/collections/index.vue @@ -124,6 +124,7 @@ @unselect-collection="$emit('remove-collection', collection)" @expand-collection="expandCollection" @remove-collection="removeCollection" + @remove-request="removeRequest" /> @@ -595,6 +596,36 @@ export default { } } }, + removeRequest({ collectionIndex, folderName, requestIndex }) { + if (this.collectionsType.type == "my-collections") { + this.$store.commit("postwoman/removeRequest", { + collectionIndex: collectionIndex, + folderName: folderName, + requestIndex: requestIndex, + flag: "rest", + }) + this.$toast.error(this.$t("deleted"), { + icon: "delete", + }) + this.syncCollections() + } else if (this.collectionsType.type == "team-collections") { + team_utils + .deleteRequest(this.$apollo, requestIndex) + .then((data) => { + // Result + this.$toast.success(this.$t("deleted"), { + icon: "delete", + }) + }) + .catch((error) => { + // Error + this.$toast.error(this.$t("error_occurred"), { + icon: "done", + }) + console.error(error) + }) + } + }, }, beforeDestroy() { document.removeEventListener("keydown", this._keyListener) diff --git a/components/collections/my/Collection.vue b/components/collections/my/Collection.vue index a85bbe81..d9bf8426 100644 --- a/components/collections/my/Collection.vue +++ b/components/collections/my/Collection.vue @@ -89,6 +89,7 @@ reqIdx: $event.reqIdx, }) " + @remove-request="removeRequest" /> @@ -115,6 +116,7 @@ reqIdx: $event.idx, }) " + @remove-request="removeRequest" /> @@ -224,6 +226,13 @@ export default { }) this.syncCollections() }, + removeRequest({ collectionIndex, folderName, requestIndex }) { + this.$emit("remove-request", { + collectionIndex, + folderName, + requestIndex, + }) + }, }, } diff --git a/components/collections/my/Folder.vue b/components/collections/my/Folder.vue index cdb7fdbf..7a1fd8ea 100644 --- a/components/collections/my/Folder.vue +++ b/components/collections/my/Folder.vue @@ -77,6 +77,7 @@ reqIdx: $event.reqIdx, }) " + @remove-request="removeRequest" /> @@ -103,6 +104,7 @@ reqIdx: $event.idx, }) " + @remove-request="removeRequest" /> @@ -206,6 +208,13 @@ export default { }) this.syncCollections() }, + removeRequest({ collectionIndex, folderName, requestIndex }) { + this.$emit("remove-request", { + collectionIndex, + folderName, + requestIndex, + }) + }, }, } diff --git a/components/collections/my/Request.vue b/components/collections/my/Request.vue index f43e7c2d..4d49f384 100644 --- a/components/collections/my/Request.vue +++ b/components/collections/my/Request.vue @@ -88,20 +88,7 @@ export default { confirmRemove: false, } }, - subscriptions() { - return { - SYNC_COLLECTIONS: getSettingSubject("syncCollections"), - } - }, methods: { - syncCollections() { - if (fb.currentUser !== null && this.SYNC_COLLECTIONS) { - fb.writeCollections( - JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)), - "collections" - ) - } - }, selectRequest() { if (this.$props.saveRequest) this.$emit("select-request", { @@ -118,16 +105,11 @@ export default { dataTransfer.setData("requestIndex", this.$props.requestIndex) }, removeRequest() { - this.$store.commit("postwoman/removeRequest", { + this.$emit("remove-request", { collectionIndex: this.$props.collectionIndex, folderName: this.$props.folderName, requestIndex: this.$props.requestIndex, - flag: "rest", }) - this.$toast.error(this.$t("deleted"), { - icon: "delete", - }) - this.syncCollections() }, getRequestLabelColor(method) { return this.requestMethodLabels[method.toLowerCase()] || this.requestMethodLabels.default diff --git a/components/collections/teams/Collection.vue b/components/collections/teams/Collection.vue index 3954ed82..ac81803b 100644 --- a/components/collections/teams/Collection.vue +++ b/components/collections/teams/Collection.vue @@ -97,6 +97,7 @@ }) " @expand-collection="expandCollection" + @remove-request="removeRequest" /> @@ -123,6 +124,7 @@ reqIdx: $event.idx, }) " + @remove-request="removeRequest" /> @@ -203,6 +205,13 @@ export default { expandCollection(collectionID) { this.$emit("expand-collection", collectionID) }, + removeRequest({ collectionIndex, folderName, requestIndex }) { + this.$emit("remove-request", { + collectionIndex, + folderName, + requestIndex, + }) + }, }, } diff --git a/components/collections/teams/Folder.vue b/components/collections/teams/Folder.vue index b9f36302..758fd3ea 100644 --- a/components/collections/teams/Folder.vue +++ b/components/collections/teams/Folder.vue @@ -81,6 +81,7 @@ }) " @expand-collection="expandCollection" + @remove-request="removeRequest" /> @@ -107,6 +108,7 @@ reqIdx: $event.idx, }) " + @remove-request="removeRequest" /> @@ -203,6 +205,13 @@ export default { expandCollection(collectionID) { this.$emit("expand-collection", collectionID) }, + removeRequest({ collectionIndex, folderName, requestIndex }) { + this.$emit("remove-request", { + collectionIndex, + folderName, + requestIndex, + }) + }, }, } diff --git a/components/collections/teams/Request.vue b/components/collections/teams/Request.vue index 14ef67d7..8ea33cbb 100644 --- a/components/collections/teams/Request.vue +++ b/components/collections/teams/Request.vue @@ -85,20 +85,7 @@ export default { confirmRemove: false, } }, - subscriptions() { - return { - SYNC_COLLECTIONS: getSettingSubject("syncCollections"), - } - }, methods: { - syncCollections() { - if (fb.currentUser !== null && this.SYNC_COLLECTIONS) { - fb.writeCollections( - JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)), - "collections" - ) - } - }, selectRequest() { if (this.$props.saveRequest) this.$emit("select-request", { @@ -107,30 +94,12 @@ export default { }) else this.$store.commit("postwoman/selectRequest", { request: this.request }) }, - dragStart({ dataTransfer }) { - this.dragging = !this.dragging - dataTransfer.setData("oldCollectionIndex", this.$props.collectionIndex) - dataTransfer.setData("oldFolderIndex", this.$props.folderIndex) - dataTransfer.setData("oldFolderName", this.$props.folderName) - dataTransfer.setData("requestIndex", this.$props.requestIndex) - }, removeRequest() { - team_utils - .deleteRequest(this.$apollo, this.$props.requestIndex) - .then((data) => { - // Result - this.$toast.success(this.$t("deleted"), { - icon: "delete", - }) - }) - .catch((error) => { - // Error - this.$toast.error(this.$t("error_occurred"), { - icon: "done", - }) - console.error(error) - }) - this.$data.confirmRemove = false + this.$emit("remove-request", { + collectionIndex: this.$props.collectionIndex, + folderName: this.$props.folderName, + requestIndex: this.$props.requestIndex, + }) }, getRequestLabelColor(method) { return this.requestMethodLabels[method.toLowerCase()] || this.requestMethodLabels.default diff --git a/components/teams/Edit.vue b/components/teams/Edit.vue index f80fda49..a40f77e0 100644 --- a/components/teams/Edit.vue +++ b/components/teams/Edit.vue @@ -6,7 +6,7 @@