improve validators and fix place selection

This commit is contained in:
les
2020-09-05 00:53:44 +02:00
parent 6ec1a0a2e3
commit 48829c9e20

View File

@@ -12,7 +12,7 @@
//- title //- title
v-text-field.mb-3(v-model='event.title' v-text-field.mb-3(v-model='event.title'
:rules="[validators.required('title')]" :rules="[$validators.required()]"
:label="$t('event.what_description')" :label="$t('event.what_description')"
autofocus autofocus
ref='title') ref='title')
@@ -25,18 +25,15 @@
style='max-height: 400px;') style='max-height: 400px;')
//- tags //- tags
//- div {{$t('event.tag_description')}}
//- client-only
v-combobox.mt-3(v-model='event.tags' v-combobox.mt-3(v-model='event.tags'
chips small-chips multiple deletable-chips hide-no-data hide-selected chips small-chips multiple deletable-chips hide-no-data hide-selected persistent-hint
:delimiters="[',', ' ']" :delimiters="[',', ' ']"
:items="tags.map(t => t.tag)" :items="tags.map(t => t.tag)"
:hints="$t('event.tag_description')"
:label="$t('common.tags')") :label="$t('common.tags')")
//- WHERE //- WHERE
v-combobox.mt-2(v-model='event.place.name' v-combobox.mt-2(v-model='event.place.name'
:rules="[validators.required('place')]" :rules="[$validators.required()]"
:label="$t('common.where')" :label="$t('common.where')"
:hint="$t('event.where_description')" :hint="$t('event.where_description')"
persistent-hint persistent-hint
@@ -50,7 +47,7 @@
v-list-item-subtitle {{item.address}} v-list-item-subtitle {{item.address}}
v-text-field.mt-3(ref='address' v-text-field.mt-3(ref='address'
:rules="[validators.required('address')]" :rules="[$validators.required()]"
:label="$t('common.address')" :label="$t('common.address')"
v-model='event.place.address' v-model='event.place.address'
:disabled='disableAddress') :disabled='disableAddress')
@@ -63,14 +60,13 @@
v-btn(value='multidate' label="multidate") {{$t('event.multidate')}} v-btn(value='multidate' label="multidate") {{$t('event.multidate')}}
v-btn(v-if='settings.allow_recurrent_event' value='recurrent' label="recurrent") {{$t('event.recurrent')}} v-btn(v-if='settings.allow_recurrent_event' value='recurrent' label="recurrent") {{$t('event.recurrent')}}
p {{$t(`event.${event.type}_description`)}} p {{$t(`event.${event.type}_description`)}} {{date}}
v-select(v-if='event.type==="recurrent"' v-select(v-if='event.type==="recurrent"'
:items="frequencies" :items="frequencies"
v-model='event.recurrent.frequency') v-model='event.recurrent.frequency')
//- v-option(:label="$t('event.each_week')" value='1w' key='1w') //- v-option(:label="$t('event.each_week')" value='1w' key='1w')
//- v-option(:label="$t('event.each_2w')" value='2w' key='2w') //- v-option(:label="$t('event.each_2w')" value='2w' key='2w')
//- el-option(:label="$t('event.each_month')" value='1m' key='1m') //- el-option(:label="$t('event.each_month')" value='1m' key='1m')
client-only client-only
.datePicker .datePicker
v-date-picker( v-date-picker(
@@ -105,7 +101,7 @@
template(v-slot:activator='{ on }') template(v-slot:activator='{ on }')
v-text-field( v-text-field(
:label="$t('event.from')" :label="$t('event.from')"
:rules="[validators.required('from')]" :rules="[$validators.required()]"
:value='time.start' :value='time.start'
v-on='on' v-on='on'
clearable) clearable)
@@ -158,7 +154,7 @@
v-card-actions v-card-actions
v-spacer v-spacer
v-btn(@click='done' :loading='loading' :disabled='!valid || loading' v-btn(@click='done' :loading='loading' :disabled='!valid || loading || !date'
color='primary') {{edit?$t('common.edit'):$t('common.send')}} color='primary') {{edit?$t('common.edit'):$t('common.send')}}
</template> </template>
@@ -168,7 +164,6 @@ import _ from 'lodash'
import moment from 'moment-timezone' import moment from 'moment-timezone'
import Editor from '@/components/Editor' import Editor from '@/components/Editor'
import List from '@/components/List' import List from '@/components/List'
import { validators } from '../../plugins/helpers'
export default { export default {
name: 'NewEvent', name: 'NewEvent',
@@ -216,7 +211,6 @@ export default {
const month = moment().month() + 1 const month = moment().month() + 1
const year = moment().year() const year = moment().year()
return { return {
validators,
valid: false, valid: false,
dueDateMenu: false, dueDateMenu: false,
fromDateMenu: false, fromDateMenu: false,
@@ -336,10 +330,9 @@ export default {
methods: { methods: {
...mapActions(['addEvent', 'updateEvent', 'updateMeta', 'updateEvents']), ...mapActions(['addEvent', 'updateEvent', 'updateMeta', 'updateEvents']),
selectPlace (p) { selectPlace (p) {
console.error('dentro selecte place ', p) const place = p && this.places.find(place => place.id === p.id)
const place = this.places.find(place => place.id === p.id)
console.error('vediamo se ho trovato il place', place)
if (place && place.address) { if (place && place.address) {
this.event.place.name = p.name
this.event.place.address = place.address this.event.place.address = place.address
this.disableAddress = true this.disableAddress = true
} else { } else {