diff --git a/backend/src/middleware/permissionsMiddleware.js b/backend/src/middleware/permissionsMiddleware.js index 8a7aced85..29a171f29 100644 --- a/backend/src/middleware/permissionsMiddleware.js +++ b/backend/src/middleware/permissionsMiddleware.js @@ -154,6 +154,7 @@ const permissions = shield( User: or(noEmailFilter, isAdmin), isLoggedIn: allow, Badge: allow, + postsEmotionsCountByEmotion: allow, }, Mutation: { '*': deny, diff --git a/backend/src/schema/resolvers/posts.js b/backend/src/schema/resolvers/posts.js index 754d9a6ed..54351ffbb 100644 --- a/backend/src/schema/resolvers/posts.js +++ b/backend/src/schema/resolvers/posts.js @@ -107,4 +107,22 @@ export default { return !emoted }, }, + Query: { + postsEmotionsCountByEmotion: async (object, params, context, resolveInfo) => { + const session = context.driver.session() + const { id, data } = params + const transactionRes = await session.run( + `MATCH (post:Post {id: $id})<-[emoted:EMOTED {emotion: $data.emotion}]-() + RETURN COUNT(DISTINCT emoted) as emotionsCount + `, + { id, data }, + ) + session.close() + + const [emotionsCount] = transactionRes.records.map(record => { + return record.get('emotionsCount').low + }) + return emotionsCount + }, + }, } diff --git a/backend/src/schema/types/type/EMOTED.gql b/backend/src/schema/types/type/EMOTED.gql index 80d655b5c..d40eed0c4 100644 --- a/backend/src/schema/types/type/EMOTED.gql +++ b/backend/src/schema/types/type/EMOTED.gql @@ -7,4 +7,4 @@ type EMOTED @relation(name: "EMOTED") { #updatedAt: DateTime createdAt: String updatedAt: String -} \ No newline at end of file +} diff --git a/backend/src/schema/types/type/Post.gql b/backend/src/schema/types/type/Post.gql index 422ab2867..8aa2aee92 100644 --- a/backend/src/schema/types/type/Post.gql +++ b/backend/src/schema/types/type/Post.gql @@ -93,3 +93,7 @@ type Mutation { ): Post RemovePostEmotions(from: _UserInput!, to: _PostInput!, data: _EMOTEDInput!): Boolean! } + +type Query { + postsEmotionsCountByEmotion(id: ID!, data: _EMOTEDInput!): Int! +} diff --git a/webapp/components/EmotionsButtons/EmotionsButtons.vue b/webapp/components/EmotionsButtons/EmotionsButtons.vue new file mode 100644 index 000000000..0bc217f64 --- /dev/null +++ b/webapp/components/EmotionsButtons/EmotionsButtons.vue @@ -0,0 +1,126 @@ + + + diff --git a/webapp/graphql/PostQuery.js b/webapp/graphql/PostQuery.js index d2bba23ef..34a874d35 100644 --- a/webapp/graphql/PostQuery.js +++ b/webapp/graphql/PostQuery.js @@ -71,6 +71,7 @@ export default i18n => { } shoutedCount shoutedByCurrentUser + emotionsCount } } ` diff --git a/webapp/pages/post/_id/_slug/index.vue b/webapp/pages/post/_id/_slug/index.vue index d5e79f4b8..a4b7b37e3 100644 --- a/webapp/pages/post/_id/_slug/index.vue +++ b/webapp/pages/post/_id/_slug/index.vue @@ -43,14 +43,22 @@ - - + + + + + + + + + + @@ -71,6 +79,7 @@ import HcCommentForm from '~/components/comments/CommentForm' import HcCommentList from '~/components/comments/CommentList' import { postMenuModalsData, deletePostMutation } from '~/components/utils/PostHelpers' import PostQuery from '~/graphql/PostQuery.js' +import HcEmotionsButtons from '~/components/EmotionsButtons/EmotionsButtons' export default { name: 'PostSlug', @@ -86,6 +95,7 @@ export default { ContentMenu, HcCommentForm, HcCommentList, + HcEmotionsButtons, }, head() { return { diff --git a/webapp/static/img/svg/emoji/angry.svg b/webapp/static/img/svg/emoji/angry.svg new file mode 100644 index 000000000..74abe161f --- /dev/null +++ b/webapp/static/img/svg/emoji/angry.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/webapp/static/img/svg/emoji/angry_color.svg b/webapp/static/img/svg/emoji/angry_color.svg new file mode 100644 index 000000000..f6b4bd9a8 --- /dev/null +++ b/webapp/static/img/svg/emoji/angry_color.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/webapp/static/img/svg/emoji/cry.svg b/webapp/static/img/svg/emoji/cry.svg new file mode 100644 index 000000000..d375fd2fd --- /dev/null +++ b/webapp/static/img/svg/emoji/cry.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/webapp/static/img/svg/emoji/cry_color.svg b/webapp/static/img/svg/emoji/cry_color.svg new file mode 100644 index 000000000..6a32bc2c5 --- /dev/null +++ b/webapp/static/img/svg/emoji/cry_color.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/webapp/static/img/svg/emoji/funny.svg b/webapp/static/img/svg/emoji/funny.svg new file mode 100644 index 000000000..d23792d8c --- /dev/null +++ b/webapp/static/img/svg/emoji/funny.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/webapp/static/img/svg/emoji/funny_color.svg b/webapp/static/img/svg/emoji/funny_color.svg new file mode 100644 index 000000000..3ac2087e8 --- /dev/null +++ b/webapp/static/img/svg/emoji/funny_color.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/webapp/static/img/svg/emoji/happy.svg b/webapp/static/img/svg/emoji/happy.svg new file mode 100644 index 000000000..d0d8a4e80 --- /dev/null +++ b/webapp/static/img/svg/emoji/happy.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/webapp/static/img/svg/emoji/happy_color.svg b/webapp/static/img/svg/emoji/happy_color.svg new file mode 100644 index 000000000..d541639e3 --- /dev/null +++ b/webapp/static/img/svg/emoji/happy_color.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/webapp/static/img/svg/emoji/surprised.svg b/webapp/static/img/svg/emoji/surprised.svg new file mode 100644 index 000000000..8a02a5a50 --- /dev/null +++ b/webapp/static/img/svg/emoji/surprised.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/webapp/static/img/svg/emoji/surprised_color.svg b/webapp/static/img/svg/emoji/surprised_color.svg new file mode 100644 index 000000000..398c34f35 --- /dev/null +++ b/webapp/static/img/svg/emoji/surprised_color.svg @@ -0,0 +1 @@ + \ No newline at end of file