From bc8cba13b3dc5b8c6d2f1514e31cd962cd9db2de Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 15 Sep 2022 12:38:59 +0200 Subject: [PATCH] add location and location name for group --- backend/src/db/graphql/groups.js | 1 + backend/src/schema/resolvers/groups.js | 16 +++++- backend/src/schema/types/type/Group.gql | 1 + webapp/components/Group/GroupForm.vue | 74 ++++++++++++++++++++++++- webapp/components/Group/GroupList.vue | 4 +- webapp/graphql/groups.js | 5 +- webapp/pages/group/create.vue | 4 +- webapp/pages/group/edit/_id/index.vue | 4 +- 8 files changed, 96 insertions(+), 13 deletions(-) diff --git a/backend/src/db/graphql/groups.js b/backend/src/db/graphql/groups.js index ff63f1a25..301146280 100644 --- a/backend/src/db/graphql/groups.js +++ b/backend/src/db/graphql/groups.js @@ -159,6 +159,7 @@ export const groupQuery = gql` deleted about description + descriptionExcerpt groupType actionRadius categories { diff --git a/backend/src/schema/resolvers/groups.js b/backend/src/schema/resolvers/groups.js index 239a299dd..4a84b524f 100644 --- a/backend/src/schema/resolvers/groups.js +++ b/backend/src/schema/resolvers/groups.js @@ -6,6 +6,7 @@ import { DESCRIPTION_WITHOUT_HTML_LENGTH_MIN } from '../../constants/groups' import { removeHtmlTags } from '../../middleware/helpers/cleanHtml.js' import Resolver from './helpers/Resolver' import { mergeImage } from './images/images' +import createOrUpdateLocations from './users/location' export default { Query: { @@ -130,7 +131,9 @@ export default { return group }) try { - return await writeTxResultPromise + const group = await writeTxResultPromise + await createOrUpdateLocations(params.id, params.locationName, session) + return group } catch (error) { if (error.code === 'Neo.ClientError.Schema.ConstraintValidationFailed') throw new UserInputError('Group with this slug already exists!') @@ -201,7 +204,9 @@ export default { return group }) try { - return await writeTxResultPromise + const group = await writeTxResultPromise + await createOrUpdateLocations(params.id, params.locationName, session) + return group } catch (error) { if (error.code === 'Neo.ClientError.Schema.ConstraintValidationFailed') throw new UserInputError('Group with this slug already exists!') @@ -274,11 +279,18 @@ export default { }, Group: { ...Resolver('Group', { + undefinedToNull: [ + 'deleted', + 'disabled', + 'locationName', + 'about', + ], hasMany: { categories: '-[:CATEGORIZED]->(related:Category)', }, hasOne: { avatar: '-[:AVATAR_IMAGE]->(related:Image)', + location: '-[:IS_IN]->(related:Location)', }, }), }, diff --git a/backend/src/schema/types/type/Group.gql b/backend/src/schema/types/type/Group.gql index c1b097857..afb2264ba 100644 --- a/backend/src/schema/types/type/Group.gql +++ b/backend/src/schema/types/type/Group.gql @@ -29,6 +29,7 @@ type Group { about: String # goal description: String! + descriptionExcerpt: String! groupType: GroupType! actionRadius: GroupActionRadius! diff --git a/webapp/components/Group/GroupForm.vue b/webapp/components/Group/GroupForm.vue index 01f5f906c..3adf3204c 100644 --- a/webapp/components/Group/GroupForm.vue +++ b/webapp/components/Group/GroupForm.vue @@ -1,5 +1,6 @@