diff --git a/src/Bundle/ChillMainBundle/Entity/PostalCode.php b/src/Bundle/ChillMainBundle/Entity/PostalCode.php index 26d75a532..01d03ed52 100644 --- a/src/Bundle/ChillMainBundle/Entity/PostalCode.php +++ b/src/Bundle/ChillMainBundle/Entity/PostalCode.php @@ -54,6 +54,13 @@ class PostalCode */ private $country; + /** + * @var integer + * + * @ORM\Column(name="origin", type="integer", nullable=true) + * @groups({"write", "read"}) + */ + private $origin = 0; /** * Get id @@ -65,6 +72,32 @@ class PostalCode return $this->id; } + + /** + * Set origin + * + * @param int $origin + * + * @return PostalCode + */ + public function setOrigin($origin) + { + $this->origin = $origin; + + return $this; + } + + /** + * Get origin + * + * @return int + */ + public function getOrigin() + { + return $this->origin; + } + + /** * Set name * diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/store/index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/store/index.js index 9aeea6f01..acbf4dcbb 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/store/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/store/index.js @@ -45,10 +45,12 @@ const store = createStore({ console.log('@A addAddress payload', payload); if('newPostalCode' in payload){ - postPostalCode(payload.newPostalCode) + let postalCodeBody = payload.newPostalCode; + postalCodeBody = Object.assign(postalCodeBody, {'origin': 3}); + postPostalCode(postalCodeBody) .then(postalCode => { let body = payload; - body.postcode = {'id': postalCode.id }, + body.postcode = {'id': postalCode.id}, postAddress(body) .then(address => new Promise((resolve, reject) => { commit('addAddress', address); @@ -95,7 +97,9 @@ const store = createStore({ console.log('@A updateAddress payload', payload); if('newPostalCode' in payload.newAddress){ // TODO change the condition because it writes new postal code in edit mode now: !writeNewPostalCode - postPostalCode(payload.newAddress.newPostalCode) + let postalCodeBody = payload.newAddress.newPostalCode; + postalCodeBody = Object.assign(postalCodeBody, {'origin': 3}); + postPostalCode(postalCodeBody) .then(postalCode => { let body = payload.newAddress; body.postcode = {'id': postalCode.id }, diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddAddress.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddAddress.vue index 57422d044..3417a2d0d 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddAddress.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/AddAddress.vue @@ -181,8 +181,8 @@ export default { getCities(country) { console.log('getCities for', country.name); fetchCities(country).then(cities => new Promise((resolve, reject) => { - this.address.loaded.cities = cities.results; - resolve() + this.address.loaded.cities = cities.results.filter(c => c.origin !== 3); // filter out user-defined cities + resolve(); })) .catch((error) => { this.errorMsg.push(error.message); diff --git a/src/Bundle/ChillMainBundle/migrations/Version20210616134328.php b/src/Bundle/ChillMainBundle/migrations/Version20210616134328.php new file mode 100644 index 000000000..c54f0a183 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20210616134328.php @@ -0,0 +1,29 @@ +addSql('ALTER TABLE chill_main_postal_code ADD origin INT DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_main_postal_code DROP origin'); + } +}