mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge remote-tracking branch 'origin/_77_address_household' into features/household-edit-members-forms-improve-household
This commit is contained in:
commit
86e41fb877
@ -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
|
||||
*
|
||||
|
@ -248,6 +248,9 @@ div.address_form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-grow: 1;
|
||||
div.custom-address, div.custom-postcode {
|
||||
padding: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
div.address_form__select__map {
|
||||
@ -255,11 +258,19 @@ div.address_form {
|
||||
div#address_map {
|
||||
height:400px;
|
||||
width:400px;
|
||||
input {
|
||||
border: 1px solid #999;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
div.address_form__more {
|
||||
|
||||
& > div {
|
||||
display: flex;
|
||||
& > label {
|
||||
width: 30%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,16 +8,12 @@
|
||||
@addNewAddress="addNewAddress">
|
||||
</add-address>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div v-if="address.text">
|
||||
{{ address.text }}
|
||||
</div>
|
||||
<div v-if="address.postcode">
|
||||
{{ address.postcode.name }}
|
||||
</div>
|
||||
<div v-if="address.country">
|
||||
{{ address.country.name }}
|
||||
</div>
|
||||
<show-address
|
||||
v-if="address"
|
||||
v-bind:address="address">
|
||||
</show-address>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!edit" class='person__address__valid'>
|
||||
@ -49,11 +45,13 @@
|
||||
|
||||
<script>
|
||||
import AddAddress from '../_components/AddAddress.vue';
|
||||
import ShowAddress from '../_components/ShowAddress.vue';
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
components: {
|
||||
AddAddress
|
||||
AddAddress,
|
||||
ShowAddress
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -1,7 +1,9 @@
|
||||
const addressMessages = {
|
||||
fr: {
|
||||
add_an_address_title: 'Créer une adresse',
|
||||
edit_an_address_title: 'Modifier une adresse',
|
||||
create_a_new_address: 'Créer une nouvelle adresse',
|
||||
edit_a_new_address: 'Modifier l\'adresse',
|
||||
select_an_address_title: 'Sélectionner une adresse',
|
||||
fill_an_address: 'Compléter l\'adresse',
|
||||
select_country: 'Choisir le pays',
|
||||
|
@ -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);
|
||||
@ -94,12 +96,14 @@ const store = createStore({
|
||||
updateAddress({ commit }, payload) {
|
||||
console.log('@A updateAddress payload', payload);
|
||||
|
||||
if('newPostalCode' in payload.newAddress){
|
||||
postPostalCode(payload.newAddress.newPostalCode)
|
||||
if('newPostalCode' in payload.newAddress){ // TODO change the condition because it writes new postal code in edit mode now: !writeNewPostalCode
|
||||
let postalCodeBody = payload.newAddress.newPostalCode;
|
||||
postalCodeBody = Object.assign(postalCodeBody, {'origin': 3});
|
||||
postPostalCode(postalCodeBody)
|
||||
.then(postalCode => {
|
||||
let body = payload;
|
||||
let body = payload.newAddress;
|
||||
body.postcode = {'id': postalCode.id },
|
||||
patchAddress(body)
|
||||
patchAddress(payload.addressId, body)
|
||||
.then(address => new Promise((resolve, reject) => {
|
||||
commit('updateAddress', address);
|
||||
resolve();
|
||||
|
@ -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);
|
||||
@ -207,25 +207,28 @@ export default {
|
||||
},
|
||||
resetAll() {
|
||||
console.log('reset all selected');
|
||||
console.log(this.$store.state.editAddress);
|
||||
this.address.loaded.addresses = [];
|
||||
this.address.selected.address = {};
|
||||
this.address.loaded.cities = [];
|
||||
this.address.selected.city = {};
|
||||
this.address.selected.country = {};
|
||||
this.address.isNoAddress = false;
|
||||
this.address.street = null;
|
||||
this.address.streetNumber = null;
|
||||
this.address.floor = this.$store.state.editAddress.floor; //TODO other field and test if no edit
|
||||
this.address.corridor = null;
|
||||
this.address.steps = null;
|
||||
this.address.flat = null;
|
||||
this.address.buildingName = null;
|
||||
this.address.distribution = null;
|
||||
this.address.extra = null;
|
||||
this.address.writeNewAddress = false;
|
||||
this.address.writeNewPostalCode = false;
|
||||
this.address.newPostalCode = {};
|
||||
this.address.isNoAddress = this.edit ? this.$store.state.editAddress.isNoAddress: false;;
|
||||
this.address.street = this.edit ? this.$store.state.editAddress.street: null;
|
||||
this.address.streetNumber = this.edit ? this.$store.state.editAddress.streetNumber: null;
|
||||
this.address.floor = this.edit ? this.$store.state.editAddress.floor: null;
|
||||
this.address.corridor = this.edit ? this.$store.state.editAddress.corridor: null;
|
||||
this.address.steps = this.edit ? this.$store.state.editAddress.steps: null;
|
||||
this.address.flat = this.edit ? this.$store.state.editAddress.flat: null;
|
||||
this.address.buildingName = this.edit ? this.$store.state.editAddress.buildingName: null;
|
||||
this.address.distribution = this.edit ? this.$store.state.editAddress.distribution: null;
|
||||
this.address.extra = this.edit ? this.$store.state.editAddress.extra: null;
|
||||
this.address.writeNewAddress = this.edit;
|
||||
this.address.writeNewPostalCode = this.edit;
|
||||
this.address.newPostalCode = this.edit ?
|
||||
{
|
||||
code: this.$store.state.editAddress.postcode !== undefined ? this.$store.state.editAddress.postcode.code : null,
|
||||
name: this.$store.state.editAddress.postcode !== undefined ? this.$store.state.editAddress.postcode.name : null
|
||||
} : {};
|
||||
console.log('cities and addresses', this.address.loaded.cities, this.address.loaded.addresses);
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +1,56 @@
|
||||
<template>
|
||||
<h4>{{ $t('fill_an_address') }}</h4>
|
||||
<div>
|
||||
<h4>{{ $t('fill_an_address') }}</h4>
|
||||
<input
|
||||
<label for="floor">{{ $t('floor') }}</label>
|
||||
<input
|
||||
type="text"
|
||||
name="floor"
|
||||
:placeholder="$t('floor')"
|
||||
v-model="floor"/>
|
||||
<input
|
||||
</div>
|
||||
<div>
|
||||
<label for="corridor">{{ $t('corridor') }}</label>
|
||||
<input
|
||||
type="text"
|
||||
name="corridor"
|
||||
:placeholder="$t('corridor')"
|
||||
v-model="corridor"/>
|
||||
<input
|
||||
</div>
|
||||
<div>
|
||||
<label for="steps">{{ $t('steps') }}</label>
|
||||
<input
|
||||
type="text"
|
||||
name="steps"
|
||||
:placeholder="$t('steps')"
|
||||
v-model="steps"/>
|
||||
<input
|
||||
</div>
|
||||
<div>
|
||||
<label for="flat">{{ $t('flat') }}</label>
|
||||
<input
|
||||
type="text"
|
||||
name="flat"
|
||||
:placeholder="$t('flat')"
|
||||
v-model="flat"/>
|
||||
<input
|
||||
</div>
|
||||
<div>
|
||||
<label for="buildingName">{{ $t('buildingName') }}</label>
|
||||
<input
|
||||
type="text"
|
||||
name="buildingName"
|
||||
:placeholder="$t('buildingName')"
|
||||
v-model="buildingName"/>
|
||||
<input
|
||||
</div>
|
||||
<div>
|
||||
<label for="extra">{{ $t('extra') }}</label>
|
||||
<input
|
||||
type="text"
|
||||
name="extra"
|
||||
:placeholder="$t('extra')"
|
||||
v-model="extra"/>
|
||||
<input
|
||||
</div>
|
||||
<div>
|
||||
<label for="distribution">{{ $t('distribution') }}</label>
|
||||
<input
|
||||
type="text"
|
||||
name="distribution"
|
||||
:placeholder="$t('distribution')"
|
||||
|
@ -15,7 +15,7 @@
|
||||
:options="addresses">
|
||||
</VueMultiselect>
|
||||
</div>
|
||||
<div v-if="writeNewAddress || writeNewPostalCode">
|
||||
<div class="custom-address" v-if="writeNewAddress || writeNewPostalCode">
|
||||
<input
|
||||
type="text"
|
||||
name="street"
|
||||
|
@ -15,7 +15,7 @@
|
||||
:options="cities">
|
||||
</VueMultiselect>
|
||||
</div>
|
||||
<div v-if="writeNewPostalCode">
|
||||
<div class="custom-postcode" v-if="writeNewPostalCode">
|
||||
<input
|
||||
type="text"
|
||||
name="name"
|
||||
@ -71,6 +71,8 @@ export default {
|
||||
},
|
||||
selectCity(value) {
|
||||
this.address.selected.city = value;
|
||||
this.address.newPostalCode.name = value.name;
|
||||
this.address.newPostalCode.code = value.code;
|
||||
this.getReferenceAddresses(value);
|
||||
},
|
||||
addPostalCode() {
|
||||
|
@ -22,11 +22,16 @@ export default {
|
||||
props: ['address', 'getCities'],
|
||||
data() {
|
||||
return {
|
||||
value: this.address.loaded.countries.filter(c => c.countryCode === 'FR')[0]
|
||||
edit: window.mode === 'edit',
|
||||
defaultCountry: this.edit ? this.$store.state.editAddress.country.code : 'FR',
|
||||
value: this.address.loaded.countries.filter(c => c.countryCode === this.defaultCountry)[0]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.value = this.edit ?
|
||||
this.address.loaded.countries.filter(c => c.countryCode === this.$store.state.editAddress.country.code)[0]:
|
||||
this.address.loaded.countries.filter(c => c.countryCode === 'FR')[0]
|
||||
if (this.value !== undefined) {
|
||||
this.selectCountry(this.value);
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
<template>
|
||||
<div v-if="address.text">
|
||||
{{ address.text }}
|
||||
</div>
|
||||
<div v-if="address.postcode">
|
||||
{{ address.postcode.name }}
|
||||
</div>
|
||||
<div v-if="address.country">
|
||||
{{ address.country.name.fr }}
|
||||
</div>
|
||||
<div v-if="address.floor">
|
||||
<span>{{ $t('floor') }}</span>: {{ address.floor }}
|
||||
</div>
|
||||
<div v-if="address.corridor">
|
||||
<span>{{ $t('corridor') }}</span>: {{ address.corridor }}
|
||||
</div>
|
||||
<div v-if="address.steps">
|
||||
<span>{{ $t('steps') }}</span>: {{ address.steps }}
|
||||
</div>
|
||||
<div v-if="address.flat">
|
||||
<span>{{ $t('flat') }}</span>: {{ address.flat }}
|
||||
</div>
|
||||
<div v-if="address.buildingName">
|
||||
<span>{{ $t('buildingName') }}</span>: {{ address.buildingName }}
|
||||
</div>
|
||||
<div v-if="address.extra">
|
||||
<span>{{ $t('extra') }}</span>: {{ address.extra }}
|
||||
</div>
|
||||
<div v-if="address.distribution">
|
||||
<span>{{ $t('distribution') }}</span>: {{ address.distribution }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'ShowAddress',
|
||||
props: ['address'],
|
||||
data() {
|
||||
return {
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
@ -15,9 +15,14 @@ class AddressNormalizer implements NormalizerAwareInterface, NormalizerInterface
|
||||
{
|
||||
$data['address_id'] = $address->getId();
|
||||
$data['text'] = $address->getStreet().', '.$address->getStreetNumber();
|
||||
$data['street'] = $address->getStreet();
|
||||
$data['streetNumber'] = $address->getStreetNumber();
|
||||
$data['postcode']['name'] = $address->getPostCode()->getName();
|
||||
$data['postcode']['code'] = $address->getPostCode()->getCode();
|
||||
$data['country']['name'] = $address->getPostCode()->getCountry()->getName();
|
||||
$data['country']['code'] = $address->getPostCode()->getCountry()->getCountryCode();
|
||||
$data['floor'] = $address->getFloor();
|
||||
$data['corridor'] = $address->getCorridor();
|
||||
$data['steps'] = $address->getSteps();
|
||||
$data['flat'] = $address->getBuildingName();
|
||||
$data['buildingName'] = $address->getFlat();
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@ -120,4 +121,26 @@ class HouseholdController extends AbstractController
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(
|
||||
* "/{household_id}/address/edit",
|
||||
* name="chill_person_household_address_edit",
|
||||
* methods={"GET", "HEAD", "POST"}
|
||||
* )
|
||||
* @ParamConverter("household", options={"id" = "household_id"})
|
||||
*/
|
||||
public function addressEdit(Request $request, Household $household)
|
||||
{
|
||||
// TODO ACL
|
||||
//$address = $this->findAddressById($household, $address_id); //TODO
|
||||
|
||||
|
||||
return $this->render('@ChillPerson/Household/address_edit.html.twig',
|
||||
[
|
||||
'household' => $household,
|
||||
//'address' => $address,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class PersonAddressController extends AbstractController
|
||||
* @var ValidatorInterface
|
||||
*/
|
||||
protected $validator;
|
||||
|
||||
|
||||
/**
|
||||
* PersonAddressController constructor.
|
||||
*
|
||||
@ -55,7 +55,7 @@ class PersonAddressController extends AbstractController
|
||||
{
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
|
||||
public function listAction($person_id)
|
||||
{
|
||||
$person = $this->getDoctrine()->getManager()
|
||||
|
@ -8,12 +8,10 @@
|
||||
</add-address>
|
||||
</div>
|
||||
<div>
|
||||
<div v-if="newAddress.text">
|
||||
{{ newAddress.text }}
|
||||
</div>
|
||||
<div v-if="newAddress.postcode">
|
||||
{{ newAddress.postcode.name }}
|
||||
</div>
|
||||
<show-address
|
||||
v-if="newAddress"
|
||||
v-bind:address="newAddress">
|
||||
</show-address>
|
||||
</div>
|
||||
</div>
|
||||
<div class='household__address-move__valid'>
|
||||
@ -45,14 +43,17 @@
|
||||
<script>
|
||||
|
||||
import AddAddress from 'ChillMainAssets/vuejs/_components/AddAddress.vue';
|
||||
import ShowAddress from 'ChillMainAssets/vuejs/_components/ShowAddress.vue';
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
components: {
|
||||
AddAddress,
|
||||
ShowAddress
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
edit: window.mode === 'edit',
|
||||
householdId: window.householdId,
|
||||
backUrl: `/fr/person/household/${householdId}/addresses`, //TODO better way to pass this
|
||||
validFrom: new Date().toISOString().split('T')[0]
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
{% set activeRouteKey = '' %}
|
||||
|
||||
{% block title 'Update address for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) %}
|
||||
{% block title 'Modify address for %name%'|trans({ '%name%': person.firstName ~ ' ' ~ person.lastName } ) %}
|
||||
|
||||
{% block personcontent %}
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
{% extends '@ChillPerson/Household/layout.html.twig' %}
|
||||
|
||||
{% block title 'Edit household address'|trans %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ block('title') }}</h1>
|
||||
|
||||
<div>
|
||||
<div id="household-address"></div>
|
||||
</div>
|
||||
|
||||
{% block stylesheets %}
|
||||
<link href="{{ asset('build/address.css') }}" type="text/css" rel="stylesheet" />
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script type="text/javascript">
|
||||
window.householdId = {{ household.id|e('js') }};
|
||||
window.addressId = {{ address.id|e('js') }};
|
||||
window.mode = 'edit';
|
||||
window.vueRootComponent = 'app';
|
||||
</script>
|
||||
{{ encore_entry_script_tags('household_address') }}
|
||||
{% endblock %}
|
||||
|
||||
{% endblock %}
|
@ -54,8 +54,10 @@
|
||||
<span class="country">({{ address.postCode.country.name|localize_translatable_string }})</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
<a href="{{ path('chill_person_household_address_edit', { 'household_id': household.id, 'address_id' : address.id } ) }}" class="sc-button bt-edit"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -185,6 +185,7 @@ Pick a person: Choisir une personne
|
||||
No address given: Pas d'adresse renseignée
|
||||
The address has been successfully updated: L'adresse a été mise à jour avec succès
|
||||
Update address for %name%: Mettre à jour une adresse pour %name%
|
||||
Modify address for %name%: Modifier une adresse pour %name%
|
||||
Addresses'history for %name%: Historique des adresses de %name%
|
||||
Addresses'history: Historique des adresses
|
||||
New address for %name% : Nouvelle adresse pour %name%
|
||||
|
Loading…
x
Reference in New Issue
Block a user