Change names in group constants files

This commit is contained in:
Wolfgang Huß 2022-11-09 15:55:59 +01:00
parent 7402cb5774
commit c960abf372
5 changed files with 21 additions and 17 deletions

View File

@ -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

View File

@ -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) => {

View File

@ -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!')
}

View File

@ -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()]

View File

@ -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