mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2026-04-06 01:25:31 +00:00
env vatiable for CATEGORIES_ACTIVE and switch for categories in contribution form
This commit is contained in:
parent
458f17b3bb
commit
e31f250ea5
@ -4,3 +4,4 @@ PUBLIC_REGISTRATION=false
|
|||||||
INVITE_REGISTRATION=true
|
INVITE_REGISTRATION=true
|
||||||
WEBSOCKETS_URI=ws://localhost:3000/api/graphql
|
WEBSOCKETS_URI=ws://localhost:3000/api/graphql
|
||||||
GRAPHQL_URI=http://localhost:4000/
|
GRAPHQL_URI=http://localhost:4000/
|
||||||
|
CATEGORIES_ACTIVE=false
|
||||||
@ -51,6 +51,19 @@
|
|||||||
{{ contentLength }}
|
{{ contentLength }}
|
||||||
<base-icon v-if="errors && errors.content" name="warning" />
|
<base-icon v-if="errors && errors.content" name="warning" />
|
||||||
</ds-chip>
|
</ds-chip>
|
||||||
|
<categories-select
|
||||||
|
v-if="categoriesActive"
|
||||||
|
model="categoryIds"
|
||||||
|
:existingCategoryIds="formData.categoryIds"
|
||||||
|
/>
|
||||||
|
<ds-chip
|
||||||
|
v-if="categoriesActive"
|
||||||
|
size="base"
|
||||||
|
:color="errors && errors.categoryIds && 'danger'"
|
||||||
|
>
|
||||||
|
{{ formData.categoryIds.length }} / 3
|
||||||
|
<base-icon v-if="errors && errors.categoryIds" name="warning" />
|
||||||
|
</ds-chip>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<base-button data-test="cancel-button" :disabled="loading" @click="$router.back()" danger>
|
<base-button data-test="cancel-button" :disabled="loading" @click="$router.back()" danger>
|
||||||
{{ $t('actions.cancel') }}
|
{{ $t('actions.cancel') }}
|
||||||
@ -69,6 +82,7 @@ import gql from 'graphql-tag'
|
|||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import HcEditor from '~/components/Editor/Editor'
|
import HcEditor from '~/components/Editor/Editor'
|
||||||
import PostMutations from '~/graphql/PostMutations.js'
|
import PostMutations from '~/graphql/PostMutations.js'
|
||||||
|
import CategoriesSelect from '~/components/CategoriesSelect/CategoriesSelect'
|
||||||
import ImageUploader from '~/components/ImageUploader/ImageUploader'
|
import ImageUploader from '~/components/ImageUploader/ImageUploader'
|
||||||
import links from '~/constants/links.js'
|
import links from '~/constants/links.js'
|
||||||
import PageParamsLink from '~/components/_new/features/PageParamsLink/PageParamsLink.vue'
|
import PageParamsLink from '~/components/_new/features/PageParamsLink/PageParamsLink.vue'
|
||||||
@ -78,6 +92,7 @@ export default {
|
|||||||
HcEditor,
|
HcEditor,
|
||||||
ImageUploader,
|
ImageUploader,
|
||||||
PageParamsLink,
|
PageParamsLink,
|
||||||
|
CategoriesSelect,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
contribution: {
|
contribution: {
|
||||||
@ -86,7 +101,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const { title, content, image } = this.contribution
|
const { title, content, image, categories } = this.contribution
|
||||||
const {
|
const {
|
||||||
sensitive: imageBlurred = false,
|
sensitive: imageBlurred = false,
|
||||||
aspectRatio: imageAspectRatio = null,
|
aspectRatio: imageAspectRatio = null,
|
||||||
@ -94,6 +109,7 @@ export default {
|
|||||||
} = image || {}
|
} = image || {}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
categoriesActive: this.$env.CATEGORIES_ACTIVE,
|
||||||
links,
|
links,
|
||||||
formData: {
|
formData: {
|
||||||
title: title || '',
|
title: title || '',
|
||||||
@ -102,11 +118,22 @@ export default {
|
|||||||
imageAspectRatio,
|
imageAspectRatio,
|
||||||
imageType,
|
imageType,
|
||||||
imageBlurred,
|
imageBlurred,
|
||||||
|
categoryIds: categories ? categories.map((category) => category.id) : [],
|
||||||
},
|
},
|
||||||
formSchema: {
|
formSchema: {
|
||||||
title: { required: true, min: 3, max: 100 },
|
title: { required: true, min: 3, max: 100 },
|
||||||
content: { required: true },
|
content: { required: true },
|
||||||
imageBlurred: { required: false },
|
imageBlurred: { required: false },
|
||||||
|
categoryIds: {
|
||||||
|
type: 'array',
|
||||||
|
required: true,
|
||||||
|
validator: (_, value = []) => {
|
||||||
|
if (value.length === 0 || value.length > 3) {
|
||||||
|
return [new Error(this.$t('common.validations.categories'))]
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
loading: false,
|
loading: false,
|
||||||
users: [],
|
users: [],
|
||||||
@ -125,7 +152,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
submit() {
|
submit() {
|
||||||
let image = null
|
let image = null
|
||||||
const { title, content } = this.formData
|
const { title, content, categoryIds } = this.formData
|
||||||
if (this.formData.image) {
|
if (this.formData.image) {
|
||||||
image = {
|
image = {
|
||||||
sensitive: this.formData.imageBlurred,
|
sensitive: this.formData.imageBlurred,
|
||||||
@ -143,6 +170,7 @@ export default {
|
|||||||
variables: {
|
variables: {
|
||||||
title,
|
title,
|
||||||
content,
|
content,
|
||||||
|
categoryIds,
|
||||||
id: this.contribution.id || null,
|
id: this.contribution.id || null,
|
||||||
image,
|
image,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -33,6 +33,7 @@ const options = {
|
|||||||
// Cookies
|
// Cookies
|
||||||
COOKIE_EXPIRE_TIME: process.env.COOKIE_EXPIRE_TIME || 730, // Two years by default
|
COOKIE_EXPIRE_TIME: process.env.COOKIE_EXPIRE_TIME || 730, // Two years by default
|
||||||
COOKIE_HTTPS_ONLY: process.env.COOKIE_HTTPS_ONLY || process.env.NODE_ENV === 'production', // ensure true in production if not set explicitly
|
COOKIE_HTTPS_ONLY: process.env.COOKIE_HTTPS_ONLY || process.env.NODE_ENV === 'production', // ensure true in production if not set explicitly
|
||||||
|
CATEGORIES_ACTIVE: process.env.CATEGORIES_ACTIVE === 'true' || false,
|
||||||
}
|
}
|
||||||
|
|
||||||
const CONFIG = {
|
const CONFIG = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user