mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-23 10:44:24 +00:00
stronger client-side validation of addresses: also validate when initForm
This commit is contained in:
parent
bd9963e65f
commit
7895699ef3
@ -14,6 +14,7 @@ and this project adheres to
|
|||||||
* [person]: AddPersons: allow creation of person or thirdparty depending on allowed types (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/422)
|
* [person]: AddPersons: allow creation of person or thirdparty depending on allowed types (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/422)
|
||||||
* [person]: AddPersons: add suggestion of name when creating new person or thirdparty (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/422)
|
* [person]: AddPersons: add suggestion of name when creating new person or thirdparty (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/422)
|
||||||
* [main] Address: fix small bug: when modifying an address without street (isNoAddress), also check errors if street is an empty string as back-end change null value to empty string for street (and streetNumber)
|
* [main] Address: fix small bug: when modifying an address without street (isNoAddress), also check errors if street is an empty string as back-end change null value to empty string for street (and streetNumber)
|
||||||
|
* [main] Address: stronger client-side validation of addresses (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/449)
|
||||||
|
|
||||||
|
|
||||||
<!-- write down unreleased development here -->
|
<!-- write down unreleased development here -->
|
||||||
|
@ -260,8 +260,7 @@ export default {
|
|||||||
editPane: false,
|
editPane: false,
|
||||||
datePane: false,
|
datePane: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
success: false,
|
success: false
|
||||||
dirty: false
|
|
||||||
},
|
},
|
||||||
errors: [],
|
errors: [],
|
||||||
defaultz: {
|
defaultz: {
|
||||||
@ -537,17 +536,19 @@ export default {
|
|||||||
|
|
||||||
checkErrors() {
|
checkErrors() {
|
||||||
this.errors = [];
|
this.errors = [];
|
||||||
if (this.flag.dirty) {
|
if (this.entity.selected.country === null) {
|
||||||
if (this.entity.selected.country === null) {
|
this.errors.push("Un pays doit être sélectionné.");
|
||||||
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.");
|
||||||
|
} else {
|
||||||
if (Object.keys(this.entity.selected.city).length === 0) {
|
if (Object.keys(this.entity.selected.city).length === 0) {
|
||||||
this.errors.push("Une ville doit être sélectionnée.");
|
this.errors.push("Une ville doit être sélectionnée.");
|
||||||
}
|
}
|
||||||
if (!this.entity.selected.isNoAddress) {
|
}
|
||||||
if (this.entity.selected.address.street === null || this.entity.selected.address.street === '' || this.entity.selected.address.streetNumber === null || this.entity.selected.address.streetNumber === '') {
|
if (!this.entity.selected.isNoAddress) {
|
||||||
this.errors.push("Une adresse doit être sélectionnée.");
|
if (this.entity.selected.address.street === null || this.entity.selected.address.street === '' || this.entity.selected.address.streetNumber === null || this.entity.selected.address.streetNumber === '') {
|
||||||
}
|
this.errors.push("Une adresse doit être sélectionnée.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -567,7 +568,7 @@ export default {
|
|||||||
|
|
||||||
this.entity.selected.country = this.context.edit ? this.entity.address.country : {};
|
this.entity.selected.country = this.context.edit ? this.entity.address.country : {};
|
||||||
this.entity.selected.postcode = this.context.edit ? this.entity.address.postcode : {};
|
this.entity.selected.postcode = this.context.edit ? this.entity.address.postcode : {};
|
||||||
this.entity.selected.city = {};
|
this.entity.selected.city = this.context.edit ? this.entity.address.postcode : {};
|
||||||
|
|
||||||
this.entity.selected.address = {};
|
this.entity.selected.address = {};
|
||||||
this.entity.selected.address.street = this.context.edit ? this.entity.address.street: null;
|
this.entity.selected.address.street = this.context.edit ? this.entity.address.street: null;
|
||||||
@ -583,6 +584,8 @@ export default {
|
|||||||
this.entity.selected.writeNew.address = this.context.edit && this.entity.address.addressReference === null && this.entity.address.street.length > 0
|
this.entity.selected.writeNew.address = this.context.edit && this.entity.address.addressReference === null && this.entity.address.street.length > 0
|
||||||
this.entity.selected.writeNew.postcode = false // NB: this used to be this.context.edit, but think it was erroneous;
|
this.entity.selected.writeNew.postcode = false // NB: this used to be this.context.edit, but think it was erroneous;
|
||||||
console.log('!! just set writeNew.postcode to', this.entity.selected.writeNew.postcode);
|
console.log('!! just set writeNew.postcode to', this.entity.selected.writeNew.postcode);
|
||||||
|
|
||||||
|
this.checkErrors();
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -111,11 +111,9 @@ export default {
|
|||||||
this.entity.selected.address.streetNumber = value.streetNumber;
|
this.entity.selected.address.streetNumber = value.streetNumber;
|
||||||
this.entity.selected.writeNew.address = false;
|
this.entity.selected.writeNew.address = false;
|
||||||
this.updateMapCenter(value.point);
|
this.updateMapCenter(value.point);
|
||||||
this.flag.dirty = true;
|
|
||||||
this.checkErrors();
|
this.checkErrors();
|
||||||
},
|
},
|
||||||
remove() {
|
remove() {
|
||||||
this.flag.dirty = true;
|
|
||||||
this.entity.selected.address = {};
|
this.entity.selected.address = {};
|
||||||
this.checkErrors();
|
this.checkErrors();
|
||||||
},
|
},
|
||||||
@ -158,7 +156,6 @@ export default {
|
|||||||
this.entity.selected.address.street = addr.street;
|
this.entity.selected.address.street = addr.street;
|
||||||
this.entity.selected.address.streetNumber = addr.number;
|
this.entity.selected.address.streetNumber = addr.number;
|
||||||
this.entity.selected.writeNew.address = true;
|
this.entity.selected.writeNew.address = true;
|
||||||
this.flag.dirty = true;
|
|
||||||
this.checkErrors();
|
this.checkErrors();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -125,11 +125,9 @@ export default {
|
|||||||
if (value.center) {
|
if (value.center) {
|
||||||
this.updateMapCenter(value.center);
|
this.updateMapCenter(value.center);
|
||||||
}
|
}
|
||||||
this.flag.dirty = true;
|
|
||||||
this.checkErrors();
|
this.checkErrors();
|
||||||
},
|
},
|
||||||
remove() {
|
remove() {
|
||||||
this.flag.dirty = true;
|
|
||||||
this.entity.selected.city = {};
|
this.entity.selected.city = {};
|
||||||
this.checkErrors();
|
this.checkErrors();
|
||||||
},
|
},
|
||||||
|
@ -51,7 +51,6 @@ export default {
|
|||||||
init() {
|
init() {
|
||||||
if (this.value !== undefined) {
|
if (this.value !== undefined) {
|
||||||
this.selectCountry(this.value);
|
this.selectCountry(this.value);
|
||||||
this.flag.dirty = false;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectCountryByCode(countryCode) {
|
selectCountryByCode(countryCode) {
|
||||||
@ -67,7 +66,6 @@ export default {
|
|||||||
this.checkErrors();
|
this.checkErrors();
|
||||||
},
|
},
|
||||||
remove() {
|
remove() {
|
||||||
this.flag.dirty = true;
|
|
||||||
this.entity.selected.country = null;
|
this.entity.selected.country = null;
|
||||||
this.checkErrors();
|
this.checkErrors();
|
||||||
},
|
},
|
||||||
|
@ -157,6 +157,7 @@ export default {
|
|||||||
set(value) {
|
set(value) {
|
||||||
console.log('isNoAddress value', value);
|
console.log('isNoAddress value', value);
|
||||||
this.entity.selected.isNoAddress = value;
|
this.entity.selected.isNoAddress = value;
|
||||||
|
this.checkErrors();
|
||||||
},
|
},
|
||||||
get() {
|
get() {
|
||||||
return this.entity.selected.isNoAddress;
|
return this.entity.selected.isNoAddress;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user