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,164 +9,162 @@
|
|||||||
>
|
>
|
||||||
<!-- "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')"
|
name="name"
|
||||||
model="name"
|
model="name"
|
||||||
name="name"
|
autofocus
|
||||||
autofocus
|
:placeholder="`${$t('group.name')} …`"
|
||||||
:placeholder="`${$t('group.name')} …`"
|
/>
|
||||||
|
<ds-chip size="base" :color="errors && errors.name && 'danger'">
|
||||||
|
{{ `${formData.name.length} / ${formSchema.name.min}–${formSchema.name.max}` }}
|
||||||
|
<base-icon v-if="errors && errors.name" name="warning" />
|
||||||
|
</ds-chip>
|
||||||
|
|
||||||
|
<!-- group Slug -->
|
||||||
|
<ds-input
|
||||||
|
v-if="update"
|
||||||
|
:label="$t('group.labelSlug')"
|
||||||
|
model="slug"
|
||||||
|
icon="at"
|
||||||
|
:placeholder="`${$t('group.labelSlug')} …`"
|
||||||
|
></ds-input>
|
||||||
|
|
||||||
|
<!-- groupType -->
|
||||||
|
<ds-text class="select-label">
|
||||||
|
{{ $t('group.type') }}
|
||||||
|
</ds-text>
|
||||||
|
<!-- TODO: change it has to be implemented later -->
|
||||||
|
<!-- TODO: move 'ds-select' from style guide to main code and implement missing translation etc. functionality -->
|
||||||
|
<select
|
||||||
|
class="select ds-input appearance--auto"
|
||||||
|
name="groupType"
|
||||||
|
:value="formData.groupType"
|
||||||
|
:disabled="update"
|
||||||
|
@change="changeGroupType($event)"
|
||||||
|
>
|
||||||
|
<option v-for="groupType in groupTypeOptions" :key="groupType" :value="groupType">
|
||||||
|
{{ $t(`group.types.${groupType}`) }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<ds-chip
|
||||||
|
size="base"
|
||||||
|
:color="errors && errors.groupType && formData.groupType === '' && 'danger'"
|
||||||
|
>
|
||||||
|
{{ `${formData.groupType === '' ? 0 : 1} / 1` }}
|
||||||
|
<base-icon
|
||||||
|
v-if="errors && errors.groupType && formData.groupType === ''"
|
||||||
|
name="warning"
|
||||||
/>
|
/>
|
||||||
<ds-chip size="base" :color="errors && errors.name && 'danger'">
|
</ds-chip>
|
||||||
{{ `${formData.name.length} / ${formSchema.name.min}–${formSchema.name.max}` }}
|
|
||||||
<base-icon v-if="errors && errors.name" name="warning" />
|
|
||||||
</ds-chip>
|
|
||||||
|
|
||||||
<!-- Group Slug -->
|
<!-- goal -->
|
||||||
<ds-input
|
<ds-input
|
||||||
v-if="update"
|
name="about"
|
||||||
:label="$t('group.labelSlug')"
|
:label="$t('group.goal')"
|
||||||
model="slug"
|
v-model="formData.about"
|
||||||
icon="at"
|
:placeholder="$t('group.goal') + ' …'"
|
||||||
:placeholder="`${$t('group.labelSlug')} …`"
|
rows="3"
|
||||||
></ds-input>
|
/>
|
||||||
|
|
||||||
<!-- groupType -->
|
<ds-space margin-top="small" />
|
||||||
<ds-text class="select-label">
|
|
||||||
{{ $t('group.type') }}
|
<!-- description -->
|
||||||
</ds-text>
|
<ds-text class="select-label">
|
||||||
<!-- TODO: change it has to be implemented later -->
|
{{ $t('group.description') }}
|
||||||
<!-- TODO: move 'ds-select' from styleguide to main code and implement missen translation etc. functionality -->
|
</ds-text>
|
||||||
<select
|
<editor
|
||||||
class="select ds-input appearance--auto"
|
:users="null"
|
||||||
:value="formData.groupType"
|
:value="formData.description"
|
||||||
:disabled="update"
|
:hashtags="null"
|
||||||
model="groupType"
|
model="description"
|
||||||
name="groupType"
|
name="description"
|
||||||
@change="changeGroupType($event)"
|
@input="updateEditorDescription"
|
||||||
|
/>
|
||||||
|
<ds-chip size="base" :color="errors && errors.description && 'danger'">
|
||||||
|
{{ `${descriptionLength} / ${formSchema.description.min}` }}
|
||||||
|
<base-icon v-if="errors && errors.description" name="warning" />
|
||||||
|
</ds-chip>
|
||||||
|
|
||||||
|
<!-- actionRadius -->
|
||||||
|
<ds-text class="select-label">
|
||||||
|
{{ $t('group.actionRadius') }}
|
||||||
|
</ds-text>
|
||||||
|
<!-- TODO: move 'ds-select' from styleguide to main code and implement missing translation etc. functionality -->
|
||||||
|
<select
|
||||||
|
class="select ds-input appearance--auto"
|
||||||
|
name="actionRadius"
|
||||||
|
:value="formData.actionRadius"
|
||||||
|
@change="changeActionRadius($event)"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="actionRadius in actionRadiusOptions"
|
||||||
|
:key="actionRadius"
|
||||||
|
:value="actionRadius"
|
||||||
>
|
>
|
||||||
<option v-for="groupType in groupTypeOptions" :key="groupType" :value="groupType">
|
{{ $t(`group.actionRadii.${actionRadius}`) }}
|
||||||
{{ $t(`group.types.${groupType}`) }}
|
</option>
|
||||||
</option>
|
</select>
|
||||||
</select>
|
<ds-chip
|
||||||
<ds-chip
|
size="base"
|
||||||
v-if="formData.groupType === ''"
|
:color="errors && errors.actionRadius && formData.actionRadius === '' && 'danger'"
|
||||||
size="base"
|
>
|
||||||
:color="formData.groupType === '' ? 'danger' : 'medium'"
|
{{ `${formData.actionRadius === '' ? 0 : 1} / 1` }}
|
||||||
>
|
<base-icon
|
||||||
<base-icon v-if="formData.groupType === ''" name="warning" />
|
v-if="errors && errors.actionRadius && formData.actionRadius === ''"
|
||||||
</ds-chip>
|
name="warning"
|
||||||
|
|
||||||
<!-- goal -->
|
|
||||||
<ds-input
|
|
||||||
:label="$t('group.goal')"
|
|
||||||
v-model="formData.about"
|
|
||||||
:placeholder="$t('group.goal') + ' …'"
|
|
||||||
name="about"
|
|
||||||
rows="3"
|
|
||||||
/>
|
/>
|
||||||
|
</ds-chip>
|
||||||
|
|
||||||
<ds-space margin-top="small" />
|
<!-- location -->
|
||||||
|
<ds-select
|
||||||
|
id="city"
|
||||||
|
:label="$t('settings.data.labelCity')"
|
||||||
|
v-model="formData.locationName"
|
||||||
|
:options="cities"
|
||||||
|
icon="map-marker"
|
||||||
|
:icon-right="null"
|
||||||
|
:placeholder="$t('settings.data.labelCity') + ' …'"
|
||||||
|
:loading="loadingGeo"
|
||||||
|
@input.native="handleCityInput"
|
||||||
|
/>
|
||||||
|
<base-button
|
||||||
|
v-if="formData.locationName !== ''"
|
||||||
|
icon="close"
|
||||||
|
ghost
|
||||||
|
size="small"
|
||||||
|
style="position: relative; display: inline-block; right: -93%; top: -45px"
|
||||||
|
@click="formData.locationName = ''"
|
||||||
|
></base-button>
|
||||||
|
|
||||||
<!-- description -->
|
<ds-space margin-top="small" />
|
||||||
<ds-text class="select-label">
|
|
||||||
{{ $t('group.description') }}
|
|
||||||
</ds-text>
|
|
||||||
<editor
|
|
||||||
:users="null"
|
|
||||||
:value="formData.description"
|
|
||||||
:hashtags="null"
|
|
||||||
model="description"
|
|
||||||
name="description"
|
|
||||||
@input="updateEditorDescription"
|
|
||||||
/>
|
|
||||||
<ds-chip size="base" :color="errors && errors.description && 'danger'">
|
|
||||||
{{ `${descriptionLength} / ${formSchema.description.min}` }}
|
|
||||||
<base-icon v-if="errors && errors.description" name="warning" />
|
|
||||||
</ds-chip>
|
|
||||||
|
|
||||||
<!-- actionRadius -->
|
<!-- category -->
|
||||||
<ds-text class="select-label">
|
<categories-select
|
||||||
{{ $t('group.actionRadius') }}
|
v-if="categoriesActive"
|
||||||
</ds-text>
|
model="categoryIds"
|
||||||
<!-- TODO: change it has to be implemented later -->
|
name="categoryIds"
|
||||||
<!-- TODO: move 'ds-select' from styleguide to main code and implement missen translation etc. functionality -->
|
:existingCategoryIds="formData.categoryIds"
|
||||||
<select
|
/>
|
||||||
class="select ds-input appearance--auto"
|
<ds-chip
|
||||||
:options="actionRadiusOptions"
|
v-if="categoriesActive"
|
||||||
:value="formData.actionRadius"
|
size="base"
|
||||||
@change="changeActionRadius($event)"
|
:color="errors && errors.categoryIds && 'danger'"
|
||||||
>
|
>
|
||||||
<option
|
{{ formData.categoryIds.length }} / 3
|
||||||
v-for="actionRadius in actionRadiusOptions"
|
<base-icon v-if="errors && errors.categoryIds" name="warning" />
|
||||||
:key="actionRadius"
|
</ds-chip>
|
||||||
:value="actionRadius"
|
|
||||||
model="actionRadius"
|
|
||||||
name="actionRadius"
|
|
||||||
>
|
|
||||||
{{ $t(`group.actionRadii.${actionRadius}`) }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<ds-chip
|
|
||||||
v-if="formData.actionRadius === ''"
|
|
||||||
size="base"
|
|
||||||
:color="formData.actionRadius === '' ? 'danger' : 'medium'"
|
|
||||||
>
|
|
||||||
<base-icon v-if="formData.actionRadius === ''" name="warning" />
|
|
||||||
</ds-chip>
|
|
||||||
|
|
||||||
<!-- location -->
|
<!-- submit -->
|
||||||
<ds-select
|
<ds-space margin-top="large">
|
||||||
id="city"
|
<nuxt-link to="/my-groups">
|
||||||
:label="$t('settings.data.labelCity')"
|
<ds-button>{{ $t('actions.cancel') }}</ds-button>
|
||||||
v-model="formData.locationName"
|
</nuxt-link>
|
||||||
:options="cities"
|
<ds-button type="submit" icon="save" primary :disabled="errors" fill>
|
||||||
icon="map-marker"
|
{{ update ? $t('group.update') : $t('group.save') }}
|
||||||
:icon-right="null"
|
</ds-button>
|
||||||
:placeholder="$t('settings.data.labelCity') + ' …'"
|
</ds-space>
|
||||||
:loading="loadingGeo"
|
|
||||||
@input.native="handleCityInput"
|
|
||||||
/>
|
|
||||||
<base-button
|
|
||||||
v-if="formData.locationName !== ''"
|
|
||||||
icon="close"
|
|
||||||
ghost
|
|
||||||
size="small"
|
|
||||||
@click="formData.locationName = ''"
|
|
||||||
style="position: relative; display: inline-block; right: -93%; top: -45px"
|
|
||||||
></base-button>
|
|
||||||
|
|
||||||
<ds-space margin-top="small" />
|
|
||||||
|
|
||||||
<!-- category -->
|
|
||||||
<categories-select
|
|
||||||
v-if="categoriesActive"
|
|
||||||
model="categoryIds"
|
|
||||||
name="categoryIds"
|
|
||||||
:existingCategoryIds="formData.categoryIds"
|
|
||||||
/>
|
|
||||||
<ds-text align="right">
|
|
||||||
<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>
|
|
||||||
</ds-text>
|
|
||||||
|
|
||||||
<!-- Submit -->
|
|
||||||
<ds-space margin-top="large">
|
|
||||||
<nuxt-link to="/my-groups">
|
|
||||||
<ds-button>{{ $t('actions.cancel') }}</ds-button>
|
|
||||||
</nuxt-link>
|
|
||||||
<ds-button type="submit" icon="save" primary :disabled="errors" fill>
|
|
||||||
{{ update ? $t('group.update') : $t('group.save') }}
|
|
||||||
</ds-button>
|
|
||||||
</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