From 91b64c2360a6a611aabd292a60b6b40f71bdc026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 30 Sep 2020 14:02:53 +0200 Subject: [PATCH] Implement postActions, first try --- .../features/SearchResults/SearchResults.vue | 12 ++++-- webapp/mixins/postActions.js | 39 +++++++++++++++++++ webapp/pages/index.vue | 2 + 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 webapp/mixins/postActions.js diff --git a/webapp/components/_new/features/SearchResults/SearchResults.vue b/webapp/components/_new/features/SearchResults/SearchResults.vue index c1140424f..1280ba481 100644 --- a/webapp/components/_new/features/SearchResults/SearchResults.vue +++ b/webapp/components/_new/features/SearchResults/SearchResults.vue @@ -13,9 +13,6 @@ - - - @@ -29,6 +26,9 @@ + + + diff --git a/webapp/mixins/postActions.js b/webapp/mixins/postActions.js new file mode 100644 index 000000000..bf77cc300 --- /dev/null +++ b/webapp/mixins/postActions.js @@ -0,0 +1,39 @@ +export default { + methods: { + deletePost(deletedPost) { + this.posts = this.posts.filter((post) => { + return post.id !== deletedPost.id + }) + }, + pinPost(post) { + this.$apollo + .mutate({ + mutation: PostMutations().pinPost, + variables: { + id: post.id + }, + }) + .then(() => { + this.$toast.success(this.$t('post.menu.pinnedSuccessfully')) + this.resetPostList() + this.$apollo.queries.Post.refetch() + }) + .catch((error) => this.$toast.error(error.message)) + }, + unpinPost(post) { + this.$apollo + .mutate({ + mutation: PostMutations().unpinPost, + variables: { + id: post.id + }, + }) + .then(() => { + this.$toast.success(this.$t('post.menu.unpinnedSuccessfully')) + this.resetPostList() + this.$apollo.queries.Post.refetch() + }) + .catch((error) => this.$toast.error(error.message)) + }, + }, +} diff --git a/webapp/pages/index.vue b/webapp/pages/index.vue index e6504cc7a..1bb08ebbd 100644 --- a/webapp/pages/index.vue +++ b/webapp/pages/index.vue @@ -64,6 +64,7 @@