move collections actions to parent

This commit is contained in:
Liyas Thomas
2021-05-09 05:30:31 +00:00
committed by GitHub
parent 5c11bcb2c6
commit 97b7320939
4 changed files with 264 additions and 476 deletions

View File

@@ -93,6 +93,8 @@
:name="collection.name"
:collection-index="index"
:collection="collection"
:folders="collection.children"
:requests="collection.requests"
:doc="doc"
:isFiltered="filterText.length > 0"
:selected="selected.some((coll) => coll == collection)"
@@ -117,6 +119,8 @@
})
"
@unselect-collection="$emit('remove-collection', collection)"
@expand-collection="expandCollection"
@removve-collection="removeCollection"
/>
</li>
</ul>
@@ -534,6 +538,53 @@ export default {
)
}
},
expandCollection(collectionID) {
console.log(collectionID)
this.teamCollectionAdapter.expandCollection(collectionID)
},
removeCollection(collectionsType, collectionIndex, collectionID) {
console.log("removing")
if (collectionsType.type == "my-collections") {
this.$store.commit("postwoman/removeCollection", {
collectionIndex: collectionIndex,
flag: "rest",
})
this.$toast.error(this.$t("deleted"), {
icon: "delete",
})
this.syncCollections()
} else if (collectionsType.type == "team-collections") {
if (collectionsType.selectedTeam.myRole != "VIEWER") {
this.$apollo
.mutate({
// Query
mutation: gql`
mutation($collectionID: String!) {
deleteCollection(collectionID: $collectionID)
}
`,
// Parameters
variables: {
collectionID: collectionID,
},
})
.then((data) => {
// Result
this.$toast.success(this.$t("deleted"), {
icon: "delete",
})
console.log(data)
})
.catch((error) => {
// Error
this.$toast.error(this.$t("error_occurred"), {
icon: "done",
})
console.error(error)
})
}
}
},
},
beforeDestroy() {
document.removeEventListener("keydown", this._keyListener)