mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Refine create and edit group form
This commit is contained in:
parent
68cb597fa6
commit
350d59bf12
@ -9,12 +9,11 @@
|
|||||||
>
|
>
|
||||||
<!-- "errors" is only working if you use a submit event on the form -->
|
<!-- "errors" is only working if you use a submit event on the form -->
|
||||||
<template #default="{ errors }">
|
<template #default="{ errors }">
|
||||||
<base-card>
|
<!-- group Name -->
|
||||||
<!-- Group Name -->
|
|
||||||
<ds-input
|
<ds-input
|
||||||
:label="$t('group.name')"
|
:label="$t('group.name')"
|
||||||
model="name"
|
|
||||||
name="name"
|
name="name"
|
||||||
|
model="name"
|
||||||
autofocus
|
autofocus
|
||||||
:placeholder="`${$t('group.name')} …`"
|
:placeholder="`${$t('group.name')} …`"
|
||||||
/>
|
/>
|
||||||
@ -23,7 +22,7 @@
|
|||||||
<base-icon v-if="errors && errors.name" name="warning" />
|
<base-icon v-if="errors && errors.name" name="warning" />
|
||||||
</ds-chip>
|
</ds-chip>
|
||||||
|
|
||||||
<!-- Group Slug -->
|
<!-- group Slug -->
|
||||||
<ds-input
|
<ds-input
|
||||||
v-if="update"
|
v-if="update"
|
||||||
:label="$t('group.labelSlug')"
|
:label="$t('group.labelSlug')"
|
||||||
@ -37,13 +36,12 @@
|
|||||||
{{ $t('group.type') }}
|
{{ $t('group.type') }}
|
||||||
</ds-text>
|
</ds-text>
|
||||||
<!-- TODO: change it has to be implemented later -->
|
<!-- TODO: change it has to be implemented later -->
|
||||||
<!-- TODO: move 'ds-select' from styleguide to main code and implement missen translation etc. functionality -->
|
<!-- TODO: move 'ds-select' from style guide to main code and implement missing translation etc. functionality -->
|
||||||
<select
|
<select
|
||||||
class="select ds-input appearance--auto"
|
class="select ds-input appearance--auto"
|
||||||
|
name="groupType"
|
||||||
:value="formData.groupType"
|
:value="formData.groupType"
|
||||||
:disabled="update"
|
:disabled="update"
|
||||||
model="groupType"
|
|
||||||
name="groupType"
|
|
||||||
@change="changeGroupType($event)"
|
@change="changeGroupType($event)"
|
||||||
>
|
>
|
||||||
<option v-for="groupType in groupTypeOptions" :key="groupType" :value="groupType">
|
<option v-for="groupType in groupTypeOptions" :key="groupType" :value="groupType">
|
||||||
@ -51,19 +49,22 @@
|
|||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<ds-chip
|
<ds-chip
|
||||||
v-if="formData.groupType === ''"
|
|
||||||
size="base"
|
size="base"
|
||||||
:color="formData.groupType === '' ? 'danger' : 'medium'"
|
:color="errors && errors.groupType && formData.groupType === '' && 'danger'"
|
||||||
>
|
>
|
||||||
<base-icon v-if="formData.groupType === ''" name="warning" />
|
{{ `${formData.groupType === '' ? 0 : 1} / 1` }}
|
||||||
|
<base-icon
|
||||||
|
v-if="errors && errors.groupType && formData.groupType === ''"
|
||||||
|
name="warning"
|
||||||
|
/>
|
||||||
</ds-chip>
|
</ds-chip>
|
||||||
|
|
||||||
<!-- goal -->
|
<!-- goal -->
|
||||||
<ds-input
|
<ds-input
|
||||||
|
name="about"
|
||||||
:label="$t('group.goal')"
|
:label="$t('group.goal')"
|
||||||
v-model="formData.about"
|
v-model="formData.about"
|
||||||
:placeholder="$t('group.goal') + ' …'"
|
:placeholder="$t('group.goal') + ' …'"
|
||||||
name="about"
|
|
||||||
rows="3"
|
rows="3"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@ -90,11 +91,10 @@
|
|||||||
<ds-text class="select-label">
|
<ds-text class="select-label">
|
||||||
{{ $t('group.actionRadius') }}
|
{{ $t('group.actionRadius') }}
|
||||||
</ds-text>
|
</ds-text>
|
||||||
<!-- TODO: change it has to be implemented later -->
|
<!-- TODO: move 'ds-select' from styleguide to main code and implement missing translation etc. functionality -->
|
||||||
<!-- TODO: move 'ds-select' from styleguide to main code and implement missen translation etc. functionality -->
|
|
||||||
<select
|
<select
|
||||||
class="select ds-input appearance--auto"
|
class="select ds-input appearance--auto"
|
||||||
:options="actionRadiusOptions"
|
name="actionRadius"
|
||||||
:value="formData.actionRadius"
|
:value="formData.actionRadius"
|
||||||
@change="changeActionRadius($event)"
|
@change="changeActionRadius($event)"
|
||||||
>
|
>
|
||||||
@ -102,18 +102,19 @@
|
|||||||
v-for="actionRadius in actionRadiusOptions"
|
v-for="actionRadius in actionRadiusOptions"
|
||||||
:key="actionRadius"
|
:key="actionRadius"
|
||||||
:value="actionRadius"
|
:value="actionRadius"
|
||||||
model="actionRadius"
|
|
||||||
name="actionRadius"
|
|
||||||
>
|
>
|
||||||
{{ $t(`group.actionRadii.${actionRadius}`) }}
|
{{ $t(`group.actionRadii.${actionRadius}`) }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<ds-chip
|
<ds-chip
|
||||||
v-if="formData.actionRadius === ''"
|
|
||||||
size="base"
|
size="base"
|
||||||
:color="formData.actionRadius === '' ? 'danger' : 'medium'"
|
:color="errors && errors.actionRadius && formData.actionRadius === '' && 'danger'"
|
||||||
>
|
>
|
||||||
<base-icon v-if="formData.actionRadius === ''" name="warning" />
|
{{ `${formData.actionRadius === '' ? 0 : 1} / 1` }}
|
||||||
|
<base-icon
|
||||||
|
v-if="errors && errors.actionRadius && formData.actionRadius === ''"
|
||||||
|
name="warning"
|
||||||
|
/>
|
||||||
</ds-chip>
|
</ds-chip>
|
||||||
|
|
||||||
<!-- location -->
|
<!-- location -->
|
||||||
@ -133,8 +134,8 @@
|
|||||||
icon="close"
|
icon="close"
|
||||||
ghost
|
ghost
|
||||||
size="small"
|
size="small"
|
||||||
@click="formData.locationName = ''"
|
|
||||||
style="position: relative; display: inline-block; right: -93%; top: -45px"
|
style="position: relative; display: inline-block; right: -93%; top: -45px"
|
||||||
|
@click="formData.locationName = ''"
|
||||||
></base-button>
|
></base-button>
|
||||||
|
|
||||||
<ds-space margin-top="small" />
|
<ds-space margin-top="small" />
|
||||||
@ -146,7 +147,6 @@
|
|||||||
name="categoryIds"
|
name="categoryIds"
|
||||||
:existingCategoryIds="formData.categoryIds"
|
:existingCategoryIds="formData.categoryIds"
|
||||||
/>
|
/>
|
||||||
<ds-text align="right">
|
|
||||||
<ds-chip
|
<ds-chip
|
||||||
v-if="categoriesActive"
|
v-if="categoriesActive"
|
||||||
size="base"
|
size="base"
|
||||||
@ -155,9 +155,8 @@
|
|||||||
{{ formData.categoryIds.length }} / 3
|
{{ formData.categoryIds.length }} / 3
|
||||||
<base-icon v-if="errors && errors.categoryIds" name="warning" />
|
<base-icon v-if="errors && errors.categoryIds" name="warning" />
|
||||||
</ds-chip>
|
</ds-chip>
|
||||||
</ds-text>
|
|
||||||
|
|
||||||
<!-- Submit -->
|
<!-- submit -->
|
||||||
<ds-space margin-top="large">
|
<ds-space margin-top="large">
|
||||||
<nuxt-link to="/my-groups">
|
<nuxt-link to="/my-groups">
|
||||||
<ds-button>{{ $t('actions.cancel') }}</ds-button>
|
<ds-button>{{ $t('actions.cancel') }}</ds-button>
|
||||||
@ -166,7 +165,6 @@
|
|||||||
{{ update ? $t('group.update') : $t('group.save') }}
|
{{ update ? $t('group.update') : $t('group.save') }}
|
||||||
</ds-button>
|
</ds-button>
|
||||||
</ds-space>
|
</ds-space>
|
||||||
</base-card>
|
|
||||||
</template>
|
</template>
|
||||||
</ds-form>
|
</ds-form>
|
||||||
</div>
|
</div>
|
||||||
@ -227,10 +225,20 @@ export default {
|
|||||||
formSchema: {
|
formSchema: {
|
||||||
name: { required: true, min: NAME_LENGTH_MIN, max: NAME_LENGTH_MAX },
|
name: { required: true, min: NAME_LENGTH_MIN, max: NAME_LENGTH_MAX },
|
||||||
slug: { required: false, min: NAME_LENGTH_MIN },
|
slug: { required: false, min: NAME_LENGTH_MIN },
|
||||||
groupType: { required: true },
|
groupType: { required: true, min: 1 },
|
||||||
about: { required: false },
|
about: { required: false },
|
||||||
description: { required: true, min: DESCRIPTION_WITHOUT_HTML_LENGTH_MIN },
|
description: {
|
||||||
actionRadius: { required: true },
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
min: DESCRIPTION_WITHOUT_HTML_LENGTH_MIN,
|
||||||
|
validator: (_, value = '') => {
|
||||||
|
if (this.$filters.removeHtml(value).length < this.formSchema.description.min) {
|
||||||
|
return [new Error()]
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
},
|
||||||
|
},
|
||||||
|
actionRadius: { required: true, min: 1 },
|
||||||
locationName: { required: false },
|
locationName: { required: false },
|
||||||
categoryIds: {
|
categoryIds: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
@ -254,11 +262,11 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changeGroupType(e) {
|
changeGroupType(event) {
|
||||||
this.formData.groupType = e.target.value
|
this.formData.groupType = event.target.value
|
||||||
},
|
},
|
||||||
changeActionRadius(e) {
|
changeActionRadius(event) {
|
||||||
this.formData.actionRadius = e.target.value
|
this.formData.actionRadius = event.target.value
|
||||||
},
|
},
|
||||||
updateEditorDescription(value) {
|
updateEditorDescription(value) {
|
||||||
this.$refs.groupForm.update('description', value)
|
this.$refs.groupForm.update('description', value)
|
||||||
@ -329,6 +337,7 @@ export default {
|
|||||||
-moz-appearance: auto;
|
-moz-appearance: auto;
|
||||||
appearance: auto;
|
appearance: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.select-label {
|
.select-label {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
padding-bottom: 4px;
|
padding-bottom: 4px;
|
||||||
@ -340,7 +349,7 @@ export default {
|
|||||||
padding-bottom: 14px;
|
padding-bottom: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.group-form > .base-card {
|
.group-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user