mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
addresses: filter out postal code introduced by user
This commit is contained in:
parent
5b72eeb147
commit
e2633a2a79
@ -54,6 +54,13 @@ class PostalCode
|
|||||||
*/
|
*/
|
||||||
private $country;
|
private $country;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*
|
||||||
|
* @ORM\Column(name="origin", type="integer", nullable=true)
|
||||||
|
* @groups({"write", "read"})
|
||||||
|
*/
|
||||||
|
private $origin = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get id
|
* Get id
|
||||||
@ -65,6 +72,32 @@ class PostalCode
|
|||||||
return $this->id;
|
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
|
* Set name
|
||||||
*
|
*
|
||||||
|
@ -45,10 +45,12 @@ const store = createStore({
|
|||||||
console.log('@A addAddress payload', payload);
|
console.log('@A addAddress payload', payload);
|
||||||
|
|
||||||
if('newPostalCode' in payload){
|
if('newPostalCode' in payload){
|
||||||
postPostalCode(payload.newPostalCode)
|
let postalCodeBody = payload.newPostalCode;
|
||||||
|
postalCodeBody = Object.assign(postalCodeBody, {'origin': 3});
|
||||||
|
postPostalCode(postalCodeBody)
|
||||||
.then(postalCode => {
|
.then(postalCode => {
|
||||||
let body = payload;
|
let body = payload;
|
||||||
body.postcode = {'id': postalCode.id },
|
body.postcode = {'id': postalCode.id},
|
||||||
postAddress(body)
|
postAddress(body)
|
||||||
.then(address => new Promise((resolve, reject) => {
|
.then(address => new Promise((resolve, reject) => {
|
||||||
commit('addAddress', address);
|
commit('addAddress', address);
|
||||||
@ -95,7 +97,9 @@ const store = createStore({
|
|||||||
console.log('@A updateAddress payload', payload);
|
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
|
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 => {
|
.then(postalCode => {
|
||||||
let body = payload.newAddress;
|
let body = payload.newAddress;
|
||||||
body.postcode = {'id': postalCode.id },
|
body.postcode = {'id': postalCode.id },
|
||||||
|
@ -181,8 +181,8 @@ export default {
|
|||||||
getCities(country) {
|
getCities(country) {
|
||||||
console.log('getCities for', country.name);
|
console.log('getCities for', country.name);
|
||||||
fetchCities(country).then(cities => new Promise((resolve, reject) => {
|
fetchCities(country).then(cities => new Promise((resolve, reject) => {
|
||||||
this.address.loaded.cities = cities.results;
|
this.address.loaded.cities = cities.results.filter(c => c.origin !== 3); // filter out user-defined cities
|
||||||
resolve()
|
resolve();
|
||||||
}))
|
}))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.errorMsg.push(error.message);
|
this.errorMsg.push(error.message);
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Main;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20210616134328 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->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');
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user