Merge branch 'cire16' into 'master'

Cire issue #16 : fix some stuffs for staging cire instance

See merge request Chill-Projet/chill-bundles!467
This commit is contained in:
Julien Fastré 2022-12-22 18:51:33 +00:00
commit 0fec753118
41 changed files with 256 additions and 159 deletions

View File

@ -363,6 +363,7 @@ final class ActivityController extends AbstractController
if ($person instanceof Person) {
$entity->setPerson($person);
$entity->getPersons()->add($person);
}
if ($accompanyingPeriod instanceof AccompanyingPeriod) {

View File

@ -117,7 +117,8 @@ export default {
target: { //name, id
},
edit: false,
addressId: null
addressId: null,
defaults: window.addaddress
}
}
}

View File

@ -30,7 +30,7 @@ const store = createStore({
},
getters: {
suggestedEntities(state) {
if (typeof state.activity.accompanyingPeriod === "undefined") {
if (typeof state.activity.accompanyingPeriod === "undefined" || state.activity.accompanyingPeriod === null) {
return [];
}
const allEntities = [

View File

@ -39,6 +39,9 @@ const makeConcernedThirdPartiesLocation = (locationType, store) => {
return locations;
};
const makeAccompanyingPeriodLocation = (locationType, store) => {
if (store.state.activity.accompanyingPeriod === null) {
return {};
}
const accPeriodLocation = store.state.activity.accompanyingPeriod.location;
return {
type: 'location',

View File

@ -11,8 +11,8 @@ declare(strict_types=1);
namespace Chill\BudgetBundle\Entity;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\HasCenterInterface;
use Chill\MainBundle\Entity\HasCentersInterface;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
@ -22,7 +22,7 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Table(name="chill_budget.charge")
* @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ChargeRepository")
*/
class Charge extends AbstractElement implements HasCenterInterface
class Charge extends AbstractElement implements HasCentersInterface
{
public const HELP_ASKED = 'running';
@ -46,22 +46,24 @@ class Charge extends AbstractElement implements HasCenterInterface
private $help = self::HELP_NOT_RELEVANT;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
public function __construct()
{
$this->setStartDate(new DateTimeImmutable('today'));
}
public function getCenter(): ?Center
public function getCenters(): array
{
return $this->getPerson()->getCenter();
if (null !== $this->getPerson()) {
return [$this->getPerson()->getCenter()];
}
return $this->getHousehold()->getCurrentPersons()->map(static fn (Person $p) => $p->getCenter())->toArray();
}
public function getHelp()

View File

@ -11,8 +11,8 @@ declare(strict_types=1);
namespace Chill\BudgetBundle\Entity;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\HasCenterInterface;
use Chill\MainBundle\Entity\HasCentersInterface;
use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
@ -22,25 +22,27 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Table(name="chill_budget.resource")
* @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ResourceRepository")
*/
class Resource extends AbstractElement implements HasCenterInterface
class Resource extends AbstractElement implements HasCentersInterface
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
public function __construct()
{
$this->setStartDate(new DateTimeImmutable('today'));
}
public function getCenter(): ?Center
public function getCenters(): array
{
return $this->getPerson()->getCenter();
if (null !== $this->getPerson()) {
return [$this->getPerson()->getCenter()];
}
return $this->getHousehold()->getCurrentPersons()->map(static fn (Person $p) => $p->getCenter())->toArray();
}
/**

View File

@ -20,7 +20,7 @@ use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use function in_array;
use UnexpectedValueException;
class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
{
@ -68,12 +68,29 @@ class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierar
protected function supports($attribute, $subject)
{
return (in_array($attribute, self::ROLES, true) && $subject instanceof AbstractElement)
|| (($subject instanceof Person || $subject instanceof Household) && in_array($attribute, [self::SEE, self::CREATE], true));
return $this->voter->supports($attribute, $subject);
}
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
{
return $this->voter->voteOnAttribute($attribute, $subject, $token);
if (
$subject instanceof Person
|| ($subject instanceof AbstractElement && null !== $person = $subject->getPerson())) {
return $this->voter->voteOnAttribute($attribute, $person ?? $subject, $token);
}
if (
$subject instanceof Household
|| ($subject instanceof AbstractElement && null !== $household = $subject->getHousehold())) {
foreach (($household ?? $subject)->getCurrentPersons() as $person) {
if ($this->voter->voteOnAttribute($attribute, $person, $token)) {
return true;
}
}
return false;
}
throw new UnexpectedValueException('This subject is not supported, or is an element not associated with person or household');
}
}

View File

@ -151,7 +151,7 @@ class PickEventType extends AbstractType
} else {
$centers = $this->authorizationHelper->getReachableCenters(
$this->user,
(string) $options['role']
(string) $options['role']->getRole()
);
}

View File

@ -5,6 +5,7 @@
{% block title 'Delete event'|trans %}
{% block event_content %}
<div class="col-10">
{{ include('@ChillMain/Util/confirmation_template.html.twig',
{
@ -15,6 +16,6 @@
'form' : delete_form
}
) }}
</div>
{% endblock %}

View File

@ -3,6 +3,7 @@
{% block title 'Event edit'|trans %}
{% block event_content -%}
<div class="col-10">
<h1>{{ 'Event edit'|trans }}</h1>
{{ form_start(edit_form) }}
@ -28,6 +29,8 @@
{{ form_widget(edit_form.submit, { 'attr' : { 'class' : 'btn btn-update' } }) }}
</li>
</ul>
{{ form_end(edit_form) }}
</div>
{% endblock %}

View File

@ -6,42 +6,42 @@
<p>{{ 'Results %start%-%end% of %total%'|trans({ '%start%' : start, '%end%': start + events|length, '%total%' : total } ) }}</p>
<table class="events">
<table class="table events">
<thead>
<tr>
<th class="chill-red">{{ 'Name'|trans }}</th>
<th class="chill-green">{{ 'Date'|trans }}</th>
<th class="chill-orange">{{ 'Event type'|trans }}</th>
<th>&nbsp;</th>
</tr>
<tr>
<th class="chill-red">{{ 'Name'|trans }}</th>
<th class="chill-green">{{ 'Date'|trans }}</th>
<th class="chill-orange">{{ 'Event type'|trans }}</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{% for event in events %}
<tr>
<td>{{ event.name }}</td>
<td>{{ event.date|format_date('long') }}</td>
<td>{{ event.type.name|localize_translatable_string }}</td>
<td>
<ul class="record_actions">
<li>
{# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #}
<a href="{{ path('chill_event__event_show', { 'event_id' : event.id } ) }}" class="btn btn-dark">
{{ 'See'|trans }}
</a>
{# {% endif %} #}
{% if is_granted('CHILL_EVENT_UPDATE', event) %}
{% for event in events %}
<tr>
<td>{{ event.name }}</td>
<td>{{ event.date|format_date('long') }}</td>
<td>{{ event.type.name|localize_translatable_string }}</td>
<td>
<ul class="record_actions">
<li>
{# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #}
<a href="{{ path('chill_event__event_show', { 'event_id' : event.id } ) }}" class="btn btn-dark">
{{ 'See'|trans }}
</a>
{# {% endif %} #}
{% if is_granted('CHILL_EVENT_UPDATE', event) %}
<a href="{{ path('chill_event__event_edit', { 'event_id' : event.id } ) }}" class="btn btn-update">
{{ 'Edit'|trans }}
</a>
{% endif %}
</li>
</ul>
</td>
</tr>
{% endfor %}
{% endif %}
</li>
</ul>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
<ul class="record_actions">
@ -49,17 +49,18 @@
<a href="{{ path('chill_event__event_new_pickcenter') }}" class="btn btn-create" >
{{ 'New event'|trans }}
</a>
</li>
{% if preview == true and events|length < total %}
<li>
<a href="{{ path('chill_main_search', { "name": search_name, "q" : pattern }) }}" class="btn btn-next">
{{ 'See all results'|trans }}
</a>
</li>
{% if preview == true and events|length < total %}
<li>
<a href="{{ path('chill_main_search', { "name": search_name, "q" : pattern }) }}" class="btn btn-misc">
{{ 'See all results'|trans }}
</a>
</li>
{% endif %}
</ul>
{% if preview == false %}
{{ chill_pagination(paginator) }}
{{ chill_pagination(paginator) }}
{% endif %}

View File

@ -44,59 +44,59 @@
<td>{{ participation.role.name|localize_translatable_string }}</td>
<td>{{ participation.status.name|localize_translatable_string }}</td>
<td>
<ul class="list-inline">
<div class="btn-group" role="group" aria-label="Button group actions">
{% set currentPath = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) %}
{% set returnLabel = 'Back to %person% events'|trans({ '%person%' : currentPerson } ) %}
{% if is_granted('CHILL_EVENT_SEE_DETAILS', participation.event) %}
<li class="list-inline-item">
<a href="{{ path('chill_event__event_show', { 'event_id' : participation.event.id, 'return_path' : currentPath, 'return_label' : returnLabel } ) }}"
class="btn btn-primary btn-sm" title="{{ 'See details of the event'|trans }}"><i class="fa fa-fw fa-eye"></i></a>
</li>
class="btn btn-primary btn-sm" title="{{ 'See details of the event'|trans }}">
<i class="fa fa-fw fa-eye"></i>
</a>
{% endif %}
{% if is_granted('CHILL_EVENT_UPDATE', participation.event)
and is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %}
<li class="list-inline-item">
<div class="btn dropdown-toggle">
<a href="" class="btn btn-warning btn-sm"><i class="fa fa-fw fa-pencil"></i></a>
<div class="dropdown-menu">
<div class="btn-group" role="group">
<button class="btn btn-sm btn-warning dropdown-toggle" type="button" id="dropdownEdit" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa fa-pencil"></i>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownEdit">
<li>
<a href="{{ path('chill_event__event_edit', { 'event_id' : participation.event.id, 'return_path' : currentPath, 'return_label' : returnLabel }) }}"
class="btn btn-warning btn-sm">
class="dropdown-item">
{{ 'Edit the event'|trans }}
</a>
</li>
<li>
<a href="{{ path('chill_event_participation_edit', { 'participation_id' : participation.id, 'return_path' : currentPath, 'return_label' : returnLabel }) }}"
class="btn btn-warning btn-sm">
class="dropdown-item">
{{ 'Edit the participation'|trans }}
</a>
</div>
</div>
</li>
</li>
</ul>
</div>
{% else %}
<li class="list-inline-item">
{% if is_granted('CHILL_EVENT_UPDATE', participation.event) %}
<a href="{{ path('chill_event__event_edit', { 'event_id' : participation.event.id, 'return_path' : currentPath, 'return_label' : returnLabel }) }}"
class="btn btn-warning btn-sm">
{{ 'Edit the event'|trans }}
</a>
<a href="{{ path('chill_event__event_edit', { 'event_id' : participation.event.id, 'return_path' : currentPath, 'return_label' : returnLabel }) }}"
class="btn btn-warning btn-sm">
{{ 'Edit the event'|trans }}
</a>
{% endif %}
{% if is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %}
<a href="{{ path('chill_event_participation_edit', { 'participation_id' : participation.id, 'return_path' : currentPath, 'return_label' : returnLabel }) }}"
class="btn btn-warning btn-sm">
{{ 'Edit the participation'|trans }}
</a>
<a href="{{ path('chill_event_participation_edit', { 'participation_id' : participation.id, 'return_path' : currentPath, 'return_label' : returnLabel }) }}"
class="btn btn-warning btn-sm">
{{ 'Edit the participation'|trans }}
</a>
{% endif %}
</li>
{% endif %}
</ul>
</div>
</td>
</tr>
{% endfor %}
@ -108,31 +108,17 @@
{{ chill_pagination(paginator) }}
{% endif %}
<div class="input-group mb-3">
<div class="input-group mt-5">
{{ form_start(form_add_event_participation_by_person) }}
{#
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="button-addon2">
#}
{{ form_widget(form_add_event_participation_by_person.event_id, { 'attr' : { 'class' : 'form-control' } } ) }}
<div class="input-group-append input-group-btn">
{#
<button class="btn btn-outline-secondary" type="button" id="button-addon2">Button</button>
#}
{{ form_widget(form_add_event_participation_by_person.submit, { 'attr' : { 'class' : 'btn btn-success' } } ) }}
{{ form_widget(form_add_event_participation_by_person.event_id, { 'attr' : {
'class' : 'custom-select',
'style': 'min-width: 15em; max-width: 18em; display: inline-block;'
}}) }}
<div class="input-group-append">
{{ form_widget(form_add_event_participation_by_person.submit, { 'attr' : { 'class' : 'btn btn-sm btn-save' } } ) }}
</div>
{{ form_rest(form_add_event_participation_by_person) }}
{{ form_end(form_add_event_participation_by_person) }}
</div>
{#
{{ form(form_add_event_participation_by_person) }}
#}
<div class="input-group mb-3">
<input class="form-control" placeholder="Recipient's username">
<div class="input-group-append">
<button class="btn btn-success">Button</button>
</div>
</div>
{% endblock %}

View File

@ -3,6 +3,7 @@
{% block title 'Event creation'|trans %}
{% block event_content -%}
<div class="col-10">
<h1>{{ 'Event creation'|trans }}</h1>
{{ form_start(form) }}
@ -26,4 +27,5 @@
</ul>
{{ form_end(form) }}
</div>
{% endblock %}

View File

@ -3,6 +3,7 @@
{% block title 'Event creation'|trans %}
{% block event_content -%}
<div class="col-10">
<h1>{{ 'Event creation'|trans }}</h1>
{{ form_start(form) }}
@ -22,5 +23,5 @@
</ul>
{{ form_end(form) }}
</div>
{% endblock %}

View File

@ -5,9 +5,10 @@
{% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %}
{% block event_content -%}
<div class="col-10">
<h1>{{ 'Details of an event'|trans }}</h1>
<table class="record_properties">
<table class="table record_properties">
<tbody>
<tr>
<th>{{ 'Name'|trans }}</th>
@ -69,7 +70,7 @@
<p>{% transchoice count %}%count% participations to this event{% endtranschoice %}</p>
{% if count > 0 %}
<table>
<table class="table">
<thead>
<tr>
<th>{{ 'Person'|trans }}</th>
@ -117,7 +118,7 @@
{% endif %}
</ul>
<div style="margin-bottom: 10em;">
<div class="row" style="margin-bottom: 10em;">
<div class="col-8">
{{ form_start(form_add_participation_by_person) }}
<div class="input-group">
@ -150,5 +151,5 @@
<div class="post_show">
{{ chill_delegated_block('block_footer_show', { 'event': event }) }}
</div>
</div>
{% endblock %}

View File

@ -5,7 +5,7 @@
{% block title 'Remove participation'|trans %}
{% block event_content %}
<div class="col-10">
{{ include('@ChillMain/Util/confirmation_template.html.twig',
{
'title' : 'Remove participation'|trans,
@ -15,6 +15,6 @@
'form' : delete_form
}
) }}
</div>
{% endblock %}

View File

@ -3,9 +3,10 @@
{% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %}
{% block event_content -%}
<div class="col-10">
<h1>{{ 'Participation Edit'|trans }}</h1>
<table>
<table class="table">
<tbody>
<tr>
<th>{{ 'Associated event'|trans }} </th>
@ -18,11 +19,11 @@
</tbody>
</table>
<h2>{{ 'Participations'|trans }}</h2>
<h2 class="mt-5">{{ 'Participations'|trans }}</h2>
{{ form_start(form) }}
<table>
<table class="table">
<thead>
<tr>
<th>{{ 'Person'|trans }}</th>
@ -59,4 +60,5 @@
</ul>
{{ form_end(form) }}
</div>
{% endblock %}

View File

@ -3,6 +3,7 @@
{% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %}
{% block event_content -%}
<div class="col-10">
<h1>{{ 'Participation Edit'|trans }}</h1>
<table>
@ -42,4 +43,5 @@
</ul>
{{ form_end(form) }}
</div>
{% endblock %}

View File

@ -18,7 +18,7 @@
{% block event_content -%}
<h1>{{ 'Participation creation'|trans }}</h1>
<table>
<table class="table">
<tbody>
<tr>
<th>{{ 'Associated event'|trans }} </th>
@ -30,7 +30,7 @@
{% include 'ChillEventBundle:Participation:_ignored_participations.html.twig' with ignored_participations %}
{{ form_start(form) }}
<table>
<table class="table">
<thead>
<tr>
<th>{{ 'Person'|trans }}</th>

View File

@ -5,6 +5,7 @@
{% block title 'Participation creation'|trans %}
{% block event_content -%}
<div class="col-10">
<h1>{{ 'Participation creation'|trans }}</h1>
<table>
@ -43,5 +44,5 @@
</ul>
{{ form_end(form) }}
</div>
{% endblock %}

View File

@ -16,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{% extends "@ChillMain/layoutWithVerticalMenu.html.twig" %}
{% extends "@ChillMain/layout.html.twig" %}
{% block layout_wvm_content %}
{% block content %}
{% block event_content %}<!-- block event content empty -->
<h1>{{ 'Event' |trans }}</h1>
{% endblock %}

View File

@ -148,6 +148,11 @@ class ChillMainExtension extends Extension implements
$config['access_permissions_group_list']
);
$container->setParameter(
'chill_main.add_address',
$config['add_address']
);
$container->setParameter(
'chill_main.routing.resources',
$config['routing']['resources']
@ -223,6 +228,7 @@ class ChillMainExtension extends Extension implements
'installation' => [
'name' => $config['installation_name'], ],
'available_languages' => $config['available_languages'],
'add_address' => $config['add_address'],
],
'form_themes' => ['@ChillMain/Form/fields.html.twig'],
];

View File

@ -276,6 +276,16 @@ class Configuration implements ConfigurationInterface
->end() // end of root
;
$rootNode->children()
->arrayNode('add_address')->addDefaultsIfNotSet()->children()
->scalarNode('default_country')->cannotBeEmpty()->defaultValue('BE')->end()
->arrayNode('map_center')->children()
->scalarNode('x')->cannotBeEmpty()->defaultValue(50.8443)->end()
->scalarNode('y')->cannotBeEmpty()->defaultValue(4.3523)->end()
->scalarNode('z')->cannotBeEmpty()->defaultValue(15)->end()
->end()
->end();
return $treeBuilder;
}
}

View File

@ -136,11 +136,9 @@ trait AddWidgetConfigurationTrait
/**
* add configuration nodes for the widget at the given place.
*
* @param type $place
*
* @return type
* @param string $place
*/
protected function addWidgetsConfiguration($place, ContainerBuilder $containerBuilder)
protected function addWidgetsConfiguration(string $place, ContainerBuilder $containerBuilder)
{
$treeBuilder = new TreeBuilder($place);
$root = $treeBuilder->getRootNode($place)

View File

@ -27,7 +27,6 @@ class ChillDateTimeType extends AbstractType
{
$resolver
->setDefault('date_widget', 'single_text')
->setDefault('date_format', 'dd-MM-yyyy')
->setDefault('time_widget', 'choice')
->setDefault('minutes', range(0, 59, 5))
->setDefault('hours', range(8, 22))

View File

@ -309,8 +309,11 @@ export default {
addressMap: {
// Note: LeafletJs demands [lat, lon]
// cfr https://macwright.com/lonlat/
center : [48.8589, 2.3469],
zoom: 12
center : [
this.context.defaults.map_center.x,
this.context.defaults.map_center.y,
],
zoom: this.context.defaults.map_center.z
},
},
errorMsg: []

View File

@ -8,8 +8,12 @@ import L from 'leaflet';
import markerIconPng from 'leaflet/dist/images/marker-icon.png'
import 'leaflet/dist/leaflet.css';
const lonLatForLeaflet = (coordinates) => {
return [coordinates[1], coordinates[0]];
}
export default {
name: 'AddressMap',
name: 'AddressMap',
props: ['entity'],
data() {
return {
@ -19,12 +23,49 @@ export default {
},
computed: {
center() {
return this.entity.selected.addressMap.center;
return this.entity.addressMap.center;
},
hasAddressPoint() {
if (Object.keys(this.entity.address).length === 0) {
return false;
}
if (null !== this.entity.address.addressReference) {
return true;
}
if (null !== this.entity.address.postcode && null !== this.entity.address.postcode.center) {
return true;
}
return false;
},
/**
*
* @returns {coordinates: [float, float], type: "Point"}
*/
addressPoint() {
if (Object.keys(this.entity.address).length === 0) {
return null;
}
if (null !== this.entity.address.addressReference) {
return this.entity.address.addressReference.point;
}
if (null !== this.entity.address.postcode && null !== this.entity.address.postcode.center) {
return this.entity.address.postcode.center;
}
return null;
},
},
methods:{
init() {
this.map = L.map('address_map').setView([46.67059, -1.42683], 12);
this.map = L.map('address_map');
if (!this.hasAddressPoint) {
this.map.setView(lonLatForLeaflet(this.entity.addressMap.center), this.entity.addressMap.zoom);
} else {
this.map.setView(lonLatForLeaflet(this.addressPoint.coordinates), 15);
}
this.map.scrollWheelZoom.disable();
@ -37,20 +78,22 @@ export default {
iconAnchor: [12, 41],
});
this.marker = L.marker([48.8589, 2.3469], {icon: markerIcon});
if (!this.hasAddressPoint) {
this.marker = L.marker(lonLatForLeaflet(this.entity.addressMap.center), {icon: markerIcon});
} else {
this.marker = L.marker(lonLatForLeaflet(this.addressPoint.coordinates), {icon: markerIcon});
}
this.marker.addTo(this.map);
},
update() {
//console.log('update map with : ', this.entity.addressMap.center)
if (this.marker && this.entity.addressMap.center) {
this.marker.setLatLng(this.entity.addressMap.center);
this.map.setView(this.entity.addressMap.center, 15);
this.marker.setLatLng(lonLatForLeaflet(this.entity.addressMap.center));
this.map.panTo(lonLatForLeaflet(this.entity.addressMap.center));
}
}
},
mounted(){
mounted() {
this.init();
this.update();
}
},
}
</script>

View File

@ -104,7 +104,7 @@ export default {
this.entity.selected.postcode.name = this.value.name;
this.entity.selected.postcode.code = this.value.code;
this.$emit('getReferenceAddresses', this.value);
if (this.value.center) {
if (typeof this.value.center !== 'undefined') {
this.updateMapCenter(this.value.center);
if (this.value.center.coordinates) {
this.entity.selected.postcode.coordinates = this.value.center.coordinates;

View File

@ -30,7 +30,7 @@ export default {
data() {
return {
value: this.selectCountryByCode(
this.context.edit ? this.entity.selected.country.code : 'FR'
this.context.edit ? this.entity.selected.country.code : this.context.defaults.default_country
)
}
},
@ -45,14 +45,12 @@ export default {
},
},
mounted() {
this.init();
console.log('country selection mounted', this.value);
if (this.value !== undefined) {
this.selectCountry(this.value);
}
},
methods: {
init() {
if (this.value !== undefined) {
this.selectCountry(this.value);
}
},
methods: {
selectCountryByCode(countryCode) {
return this.entity.loaded.countries.filter(c => c.countryCode === countryCode)[0];
},

View File

@ -174,8 +174,8 @@ export default {
},
updateMapCenter(point) {
console.log('point', point);
this.addressMap.center[0] = point.coordinates[1]; // TODO use reverse()
this.addressMap.center[1] = point.coordinates[0];
this.addressMap.center[0] = point.coordinates[0];
this.addressMap.center[1] = point.coordinates[1];
this.$refs.addressMap.update(); // cast child methods
}
}

View File

@ -102,7 +102,7 @@ export default {
],
emits: ['openEditPane'],
mounted() {
console.log('context', this.context)
//console.log('context', this.context)
},
computed: {
address() {

View File

@ -20,7 +20,8 @@ containers.forEach((container) => {
},
edit: container.dataset.mode === 'edit', //boolean
addressId: parseInt(container.dataset.addressId) || null,
backUrl: container.dataset.backUrl || null
backUrl: container.dataset.backUrl || null,
defaults: JSON.parse(container.dataset.addressDefaults)
},
options: {
/// Options override default.

View File

@ -19,7 +19,6 @@ const addAddressInput = (inputs) => {
if (container === null) {
throw Error("no container");
}
console.log('useValidFrom', el.dataset.useValidFrom === '1');
const app = createApp({
template: `<app v-bind:addAddress="this.addAddress" @address-created="associateToInput"></app>`,
@ -34,6 +33,7 @@ const addAddressInput = (inputs) => {
},
edit: isEdit,
addressId: addressIdInt,
defaults: window.addaddress,
},
options: {
/// Options override default.

View File

@ -72,6 +72,8 @@
{% if onlyButton is defined and onlyButton == 1 %}
data-hide-address="true"
{% endif %}
data-address-defaults="{{ add_address|json_encode|e('html') }}"
></div>
{{ encore_entry_script_tags('vue_address') }}

View File

@ -9,6 +9,11 @@
{% block head_custom %}{% endblock %}
<link rel="shortcut icon" href="{{ asset('build/images/favicon.ico') }}" type="image/x-icon">
<script type="application/javascript">
{# this is global data, in use for all js app #}
window.addaddress = {{ add_address|json_encode|raw }};
</script>
{{ encore_entry_link_tags('mod_bootstrap') }}
{{ encore_entry_link_tags('mod_forkawesome') }}
{{ encore_entry_link_tags('mod_ckeditor5') }}

View File

@ -1581,7 +1581,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
$this->centerHistory[] = new PersonCenterHistory($this, $center, $modification);
$this->centerHistory[] = new PersonCenterHistory($this, $center, $modification);
return $this;
}

View File

@ -144,7 +144,7 @@ class PickPersonType extends AbstractType
}, $this->user->getGroupCenters()->toArray());
} else {
$centers = $this->authorizationHelper
->getReachableCenters($this->user, $options['role']);
->getReachableCenters($this->user, $options['role']->getRole());
}
if (null === $options['centers']) {

View File

@ -164,7 +164,8 @@ export default {
id: this.accompanyingCourse.id
},
edit: false,
addressId: null
addressId: null,
defaults: window.addaddress
}
if (this.accompanyingCourse.location) {
context['edit'] = true;

View File

@ -5,6 +5,7 @@ import { fetchHouseholdByAddressReference } from 'ChillPersonAssets/lib/househol
import { datetimeToISO, dateToISO, ISOToDate } from 'ChillMainAssets/chill/js/date';
const debug = process.env.NODE_ENV !== 'production';
//console.log('AJAJAJA', window.addaddress);
const concerned = window.household_members_editor_data.persons.map(p => {
return {
@ -115,6 +116,7 @@ const store = createStore({
name: state.household.type,
id: state.household.id
},
defaults: window.addaddress,
suggestions: state.addressesSuggestion
};
} else {
@ -125,6 +127,7 @@ const store = createStore({
name: state.household.type,
id: state.household.id
},
defaults: window.addaddress,
};
}
},

View File

@ -218,7 +218,8 @@ export default {
context: {
target: {}, // boilerplate for getting the address id
edit: false,
addressId: null
addressId: null,
defaults: window.addaddress
}
},
errors: []

View File

@ -232,7 +232,8 @@ export default {
id: this.id
},
edit: false,
addressId: null
addressId: null,
defaults: window.addaddress
};
if ( !(this.thirdparty.address === undefined || this.thirdparty.address === null)
&& this.thirdparty.address.address_id !== null