Reset save req selection when selected item is deleted

This commit is contained in:
Andrew Bastin
2021-06-15 08:26:01 -04:00
parent 07a505c365
commit 0921cccb4c
6 changed files with 62 additions and 0 deletions

View File

@@ -197,6 +197,10 @@ export default Vue.extend({
this.showChildren = !this.showChildren
},
removeCollection() {
// Cancel pick if picked collection is deleted
if (this.picked && this.picked.pickedType === "gql-my-collection" && this.picked.collectionIndex === this.collectionIndex) {
this.$emit("select", { picked: null })
}
removeGraphqlCollection(this.collectionIndex)
this.$toast.error(this.$t("deleted").toString(), {

View File

@@ -181,6 +181,11 @@ export default Vue.extend({
this.showChildren = !this.showChildren
},
removeFolder() {
// Cancel pick if the picked folder is deleted
if (this.picked && this.picked.pickedType === "gql-my-folder" && this.picked.folderPath === this.folderPath) {
this.$emit("select", { picked: null })
}
removeGraphqlFolder(this.folderPath)
this.$toast.error(this.$t("deleted").toString(), {
icon: "delete",

View File

@@ -122,6 +122,11 @@ export default Vue.extend({
dataTransfer.setData("requestIndex", this.requestIndex)
},
removeRequest() {
// Cancel pick if the picked request is deleted
if (this.picked && this.picked.pickedType === "gql-my-request" && this.picked.folderPath === this.folderPath && this.picked.requestIndex === this.requestIndex) {
this.$emit("select", { picked: null })
}
removeGraphqlRequest(this.folderPath, this.requestIndex)
this.$toast.error(this.$t("deleted").toString(), {
icon: "delete",

View File

@@ -531,12 +531,22 @@ export default {
},
removeCollection({ collectionsType, collectionIndex, collectionID }) {
if (collectionsType.type === "my-collections") {
// Cancel pick if picked collection is deleted
if (this.picked && this.picked.pickedType === "my-collection" && this.picked.collectionIndex === collectionIndex) {
this.$emit("select", { picked: null })
}
removeRESTCollection(collectionIndex)
this.$toast.error(this.$t("deleted"), {
icon: "delete",
})
} else if (collectionsType.type === "team-collections") {
// Cancel pick if picked collection is deleted
if (this.picked && this.picked.pickedType === "teams-collection" && this.picked.collectionID === collectionID) {
this.$emit("select", { picked: null })
}
if (collectionsType.selectedTeam.myRole !== "VIEWER") {
this.$apollo
.mutate({
@@ -569,12 +579,30 @@ export default {
},
removeRequest({ requestIndex, folderPath }) {
if (this.collectionsType.type === "my-collections") {
// Cancel pick if the picked item is being deleted
if (
this.picked &&
this.picked.pickedType === "my-request" &&
this.picked.folderPath === folderPath &&
this.picked.requestIndex === requestIndex
) {
this.$emit("select", { picked: null })
}
removeRESTRequest(folderPath, requestIndex)
this.$toast.error(this.$t("deleted"), {
icon: "delete",
})
} else if (this.collectionsType.type === "team-collections") {
// Cancel pick if the picked item is being deleted
if (
this.picked &&
this.picked.pickedType === "teams-request" &&
this.picked.requestID === requestIndex
) {
this.$emit("select", { picked: null })
}
teamUtils
.deleteRequest(this.$apollo, requestIndex)
.then(() => {

View File

@@ -193,6 +193,11 @@ export default {
this.showChildren = !this.showChildren
},
removeFolder() {
// TODO: Bubble it up ?
// Cancel pick if picked folder was deleted
if (this.picked && this.picked.pickedType === "my-folder" && this.picked.folderPath === this.folderPath) {
this.$emit("select", { picked: null })
}
removeRESTFolder(this.folderPath)
this.$toast.error(this.$t("deleted"), {
@@ -206,6 +211,16 @@ export default {
moveRESTRequest(folderPath, requestIndex, this.folderPath)
},
removeRequest({ requestIndex }) {
// TODO: Bubble it up to root ?
// Cancel pick if the picked item is being deleted
if (
this.picked &&
this.picked.pickedType === "my-request" &&
this.picked.folderPath === this.folderPath &&
this.picked.requestIndex === requestIndex
) {
this.$emit("select", { picked: null })
}
removeRESTRequest(this.folderPath, requestIndex)
},
},

View File

@@ -189,6 +189,11 @@ export default {
},
removeFolder() {
if (this.collectionsType.selectedTeam.myRole !== "VIEWER") {
// Cancel pick if picked collection folder was deleted
if (this.picked && this.picked.pickedType === "teams-folder" && this.picked.folderID === this.folder.id) {
this.$emit("select", { picked: null })
}
teamUtils
.deleteCollection(this.$apollo, this.folder.id)
.then(() => {