diff --git a/backend/src/constants/groups.js b/backend/src/constants/groups.js index e9c941a89..e3f00bbd1 100644 --- a/backend/src/constants/groups.js +++ b/backend/src/constants/groups.js @@ -1,3 +1,6 @@ // this file is duplicated in `backend/src/constants/group.js` and `webapp/constants/group.js` -export const DESCRIPTION_WITHOUT_HTML_LENGTH_MIN = 100 // with removed HTML tags -export const DESCRIPTION_EXCERPT_HTML_LENGTH = 250 // with removed HTML tags +export const GROUPNAME_LENGTH_MIN = 3 +export const GROUPNAME_LENGTH_MAX = 50 +export const GROUPDESCRIPTION_WITHOUT_HTML_LENGTH_MIN = 100 // with removed HTML tags +export const GROUPDESCRIPTION_EXCERPT_HTML_LENGTH = 250 // with removed HTML tags +export const SHOW_GROUP_BUTTON_IN_HEADER = true diff --git a/backend/src/middleware/excerptMiddleware.js b/backend/src/middleware/excerptMiddleware.js index 28b30fb4f..a5600796a 100644 --- a/backend/src/middleware/excerptMiddleware.js +++ b/backend/src/middleware/excerptMiddleware.js @@ -1,15 +1,15 @@ import trunc from 'trunc-html' -import { DESCRIPTION_EXCERPT_HTML_LENGTH } from '../constants/groups' +import { GROUPDESCRIPTION_EXCERPT_HTML_LENGTH } from '../constants/groups' export default { Mutation: { CreateGroup: async (resolve, root, args, context, info) => { - args.descriptionExcerpt = trunc(args.description, DESCRIPTION_EXCERPT_HTML_LENGTH).html + args.descriptionExcerpt = trunc(args.description, GROUPDESCRIPTION_EXCERPT_HTML_LENGTH).html return resolve(root, args, context, info) }, UpdateGroup: async (resolve, root, args, context, info) => { if (args.description) - args.descriptionExcerpt = trunc(args.description, DESCRIPTION_EXCERPT_HTML_LENGTH).html + args.descriptionExcerpt = trunc(args.description, GROUPDESCRIPTION_EXCERPT_HTML_LENGTH).html return resolve(root, args, context, info) }, CreatePost: async (resolve, root, args, context, info) => { diff --git a/backend/src/schema/resolvers/groups.js b/backend/src/schema/resolvers/groups.js index 4ea588d28..cdb953933 100644 --- a/backend/src/schema/resolvers/groups.js +++ b/backend/src/schema/resolvers/groups.js @@ -2,7 +2,7 @@ import { v4 as uuid } from 'uuid' import { UserInputError } from 'apollo-server' import CONFIG from '../../config' import { CATEGORIES_MIN, CATEGORIES_MAX } from '../../constants/categories' -import { DESCRIPTION_WITHOUT_HTML_LENGTH_MIN } from '../../constants/groups' +import { GROUPDESCRIPTION_WITHOUT_HTML_LENGTH_MIN } from '../../constants/groups' import { removeHtmlTags } from '../../middleware/helpers/cleanHtml.js' import Resolver, { removeUndefinedNullValuesFromObject, @@ -134,7 +134,7 @@ export default { if ( params.description === undefined || params.description === null || - removeHtmlTags(params.description).length < DESCRIPTION_WITHOUT_HTML_LENGTH_MIN + removeHtmlTags(params.description).length < GROUPDESCRIPTION_WITHOUT_HTML_LENGTH_MIN ) { throw new UserInputError('Description too short!') } @@ -204,7 +204,7 @@ export default { } if ( params.description && - removeHtmlTags(params.description).length < DESCRIPTION_WITHOUT_HTML_LENGTH_MIN + removeHtmlTags(params.description).length < GROUPDESCRIPTION_WITHOUT_HTML_LENGTH_MIN ) { throw new UserInputError('Description too short!') } diff --git a/webapp/components/Group/GroupForm.vue b/webapp/components/Group/GroupForm.vue index 7b0f7840c..e1ddc67a2 100644 --- a/webapp/components/Group/GroupForm.vue +++ b/webapp/components/Group/GroupForm.vue @@ -179,9 +179,9 @@ import CategoriesSelect from '~/components/CategoriesSelect/CategoriesSelect' import { CATEGORIES_MIN, CATEGORIES_MAX } from '~/constants/categories.js' import { - NAME_LENGTH_MIN, - NAME_LENGTH_MAX, - DESCRIPTION_WITHOUT_HTML_LENGTH_MIN, + GROUPNAME_LENGTH_MIN, + GROUPNAME_LENGTH_MAX, + GROUPDESCRIPTION_WITHOUT_HTML_LENGTH_MIN, } from '~/constants/groups.js' import Editor from '~/components/Editor/Editor' import { queryLocations } from '~/graphql/location' @@ -233,14 +233,14 @@ export default { categoryIds: categories ? categories.map((category) => category.id) : [], }, formSchema: { - name: { required: true, min: NAME_LENGTH_MIN, max: NAME_LENGTH_MAX }, - slug: { required: false, min: NAME_LENGTH_MIN }, + name: { required: true, min: GROUPNAME_LENGTH_MIN, max: GROUPNAME_LENGTH_MAX }, + slug: { required: false, min: GROUPNAME_LENGTH_MIN }, groupType: { required: true, min: 1 }, about: { required: false }, description: { type: 'string', required: true, - min: DESCRIPTION_WITHOUT_HTML_LENGTH_MIN, + min: GROUPDESCRIPTION_WITHOUT_HTML_LENGTH_MIN, validator: (_, value = '') => { if (this.$filters.removeHtml(value).length < this.formSchema.description.min) { return [new Error()] diff --git a/webapp/constants/groups.js b/webapp/constants/groups.js index 1c49d3ff3..e3f00bbd1 100644 --- a/webapp/constants/groups.js +++ b/webapp/constants/groups.js @@ -1,5 +1,6 @@ // this file is duplicated in `backend/src/constants/group.js` and `webapp/constants/group.js` -export const NAME_LENGTH_MIN = 3 -export const NAME_LENGTH_MAX = 50 -export const DESCRIPTION_WITHOUT_HTML_LENGTH_MIN = 100 // with removed HTML tags +export const GROUPNAME_LENGTH_MIN = 3 +export const GROUPNAME_LENGTH_MAX = 50 +export const GROUPDESCRIPTION_WITHOUT_HTML_LENGTH_MIN = 100 // with removed HTML tags +export const GROUPDESCRIPTION_EXCERPT_HTML_LENGTH = 250 // with removed HTML tags export const SHOW_GROUP_BUTTON_IN_HEADER = true