diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue index 309f9d9c3..c1ef174ab 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue @@ -98,6 +98,8 @@ v-bind:defaultz="this.defaultz" v-bind:entity="this.entity" v-bind:flag="this.flag" + v-bind:errors="this.errors" + v-bind:checkErrors="this.checkErrors" @getCities="getCities" @getReferenceAddresses="getReferenceAddresses"> @@ -123,6 +125,8 @@ v-bind:defaultz="this.defaultz" v-bind:entity="this.entity" v-bind:flag="this.flag" + v-bind:errors="this.errors" + v-bind:checkErrors="this.checkErrors" v-bind:insideModal="false" @getCities="getCities" @getReferenceAddresses="getReferenceAddresses"> @@ -259,6 +263,7 @@ export default { success: false, dirty: false }, + errors: [], defaultz: { button: { text: { create: 'add_an_address_title', edit: 'edit_address' }, @@ -530,6 +535,16 @@ export default { }); }, + checkErrors() { + this.errors = []; + if (this.entity.selected.country === null) { + this.errors.push("Un pays doit être sélectionné."); + } + if (this.entity.selected.city === null) { + this.errors.push("Une ville doit être sélectionnée."); + } + }, + /* * Make form ready for new changes */ diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue index ea3409994..6c102ee99 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue @@ -7,6 +7,7 @@ @search-change="listenInputSearch" ref="citySelector" @select="selectCity" + @remove="remove" name="field" track-by="id" label="value" @@ -22,7 +23,6 @@ :loading="isLoading" :options="cities"> - {{ $t('choose_one_locality') }}
@@ -56,7 +56,7 @@ import { searchCities, fetchCities } from '../../api.js'; export default { name: 'CitySelection', components: { VueMultiselect }, - props: ['entity', 'context', 'focusOnAddress', 'updateMapCenter', 'flag'], + props: ['entity', 'context', 'focusOnAddress', 'updateMapCenter', 'flag', 'checkErrors'], emits: ['getReferenceAddresses'], data() { return { @@ -74,9 +74,6 @@ export default { isEnteredCustomCity() { return this.$data.value !== null && typeof this.$data.value.text !== 'undefined'; }, - isEmpty() { - return this.flag.dirty && this.value === null - }, cities() { return this.entity.loaded.cities.sort( (a, b) => Number(a.code) - Number(b.code) || a.name > b.name @@ -128,6 +125,11 @@ export default { this.updateMapCenter(value.center); } this.flag.dirty = true; + this.checkErrors(); + }, + remove() { + this.entity.selected.city = null; + this.checkErrors(); }, listenInputSearch(query) { if (query.length > 2) { diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue index e41a0e2bd..fd5fb682b 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue @@ -13,9 +13,9 @@ :deselect-label="$t('multiselect.deselect_label')" :selected-label="$t('multiselect.selected_label')" @select="selectCountry" + @remove="remove" > - {{ $t('choose_one_country') }}
@@ -25,7 +25,7 @@ import VueMultiselect from 'vue-multiselect'; export default { name: 'CountrySelection', components: { VueMultiselect }, - props: ['context', 'entity', 'flag'], + props: ['context', 'entity', 'flag', 'checkErrors'], emits: ['getCities'], data() { return { @@ -43,9 +43,6 @@ export default { sortedCountries.push(...countries.filter(c => c.countryCode !== 'FR').filter(c => c.countryCode !== 'BE')) return sortedCountries; }, - isEmpty() { - return this.flag.dirty && this.value === null - }, }, mounted() { this.init(); @@ -66,7 +63,13 @@ export default { //console.log('select country', value); this.entity.selected.country = value; this.$emit('getCities', value); - } + this.flag.dirty = true; + this.checkErrors(); + }, + remove() { + this.entity.selected.country = null; + this.checkErrors(); + }, } }; diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue index cebacad51..e6bb72883 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue @@ -7,6 +7,12 @@ Loading... +
+ +
+

{{ $t('select_an_address_title') }}

@@ -26,6 +32,7 @@ v-bind:context="context" v-bind:entity="entity" v-bind:flag="flag" + v-bind:checkErrors="checkErrors" @getCities="$emit('getCities', selected.country)"> @@ -35,6 +42,7 @@ v-bind:focusOnAddress="focusOnAddress" v-bind:updateMapCenter="updateMapCenter" v-bind:flag="flag" + v-bind:checkErrors="checkErrors" @getReferenceAddresses="$emit('getReferenceAddresses', selected.city)"> @@ -101,7 +109,9 @@ export default { 'flag', 'entity', 'errorMsg', - 'insideModal' + 'insideModal', + 'errors', + 'checkErrors', ], emits: ['getCities', 'getReferenceAddresses'], data() { @@ -130,7 +140,7 @@ export default { get() { return this.entity.selected.isNoAddress; } - } + }, }, methods: { focusOnAddress() {