diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 11db2dcb3..e67e0f3c2 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -363,6 +363,7 @@ final class ActivityController extends AbstractController if ($person instanceof Person) { $entity->setPerson($person); + $entity->getPersons()->add($person); } if ($accompanyingPeriod instanceof AccompanyingPeriod) { diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue index 6a6289875..568c8747a 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/Location/NewLocation.vue @@ -117,7 +117,8 @@ export default { target: { //name, id }, edit: false, - addressId: null + addressId: null, + defaults: window.addaddress } } } diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js index ca56a5dae..9f710abeb 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.js @@ -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 = [ diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js index 056dc129d..7a216f628 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/store.locations.js @@ -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', diff --git a/src/Bundle/ChillBudgetBundle/Entity/Charge.php b/src/Bundle/ChillBudgetBundle/Entity/Charge.php index dc03eef80..eab153b2e 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/Charge.php +++ b/src/Bundle/ChillBudgetBundle/Entity/Charge.php @@ -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() diff --git a/src/Bundle/ChillBudgetBundle/Entity/Resource.php b/src/Bundle/ChillBudgetBundle/Entity/Resource.php index 949872d6c..bed9f23c3 100644 --- a/src/Bundle/ChillBudgetBundle/Entity/Resource.php +++ b/src/Bundle/ChillBudgetBundle/Entity/Resource.php @@ -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(); } /** diff --git a/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php b/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php index 0a428d324..5203f9092 100644 --- a/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php +++ b/src/Bundle/ChillBudgetBundle/Security/Authorization/BudgetElementVoter.php @@ -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'); } } diff --git a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php index 782bd7628..4e8179f10 100644 --- a/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php +++ b/src/Bundle/ChillEventBundle/Form/Type/PickEventType.php @@ -151,7 +151,7 @@ class PickEventType extends AbstractType } else { $centers = $this->authorizationHelper->getReachableCenters( $this->user, - (string) $options['role'] + (string) $options['role']->getRole() ); } diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/confirm_delete.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/confirm_delete.html.twig index 86b7c6fd2..c3a13b55a 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/confirm_delete.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/confirm_delete.html.twig @@ -5,6 +5,7 @@ {% block title 'Delete event'|trans %} {% block event_content %} +
{{ include('@ChillMain/Util/confirmation_template.html.twig', { @@ -15,6 +16,6 @@ 'form' : delete_form } ) }} - +
{% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig index 288c81edd..a528f1f5c 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/edit.html.twig @@ -3,6 +3,7 @@ {% block title 'Event edit'|trans %} {% block event_content -%} +

{{ 'Event edit'|trans }}

{{ form_start(edit_form) }} @@ -28,6 +29,8 @@ {{ form_widget(edit_form.submit, { 'attr' : { 'class' : 'btn btn-update' } }) }} - + {{ form_end(edit_form) }} + +
{% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig index 6e77b6df8..8d5f49da8 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/list.html.twig @@ -6,42 +6,42 @@

{{ 'Results %start%-%end% of %total%'|trans({ '%start%' : start, '%end%': start + events|length, '%total%' : total } ) }}

- +
- - - - - - + + + + + + - {% for event in events %} - - - - - + + + + - - {% endfor %} + {% endif %} + + + + + {% endfor %}
{{ 'Name'|trans }}{{ 'Date'|trans }}{{ 'Event type'|trans }} 
{{ 'Name'|trans }}{{ 'Date'|trans }}{{ 'Event type'|trans }} 
{{ event.name }}{{ event.date|format_date('long') }}{{ event.type.name|localize_translatable_string }} -
    -
  • - {# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #} - - {{ 'See'|trans }} - - {# {% endif %} #} - {% if is_granted('CHILL_EVENT_UPDATE', event) %} + {% for event in events %} +
{{ event.name }}{{ event.date|format_date('long') }}{{ event.type.name|localize_translatable_string }} + -
- + {% endif %} {% if preview == false %} -{{ chill_pagination(paginator) }} + {{ chill_pagination(paginator) }} {% endif %} + diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig index 53e97c3c4..ef2dae85c 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/listByPerson.html.twig @@ -44,59 +44,59 @@ {{ participation.role.name|localize_translatable_string }} {{ participation.status.name|localize_translatable_string }} - + {% else %} -
  • {% if is_granted('CHILL_EVENT_UPDATE', participation.event) %} - - {{ 'Edit the event'|trans }} - + + {{ 'Edit the event'|trans }} + {% endif %} {% if is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %} - - {{ 'Edit the participation'|trans }} - + + {{ 'Edit the participation'|trans }} + {% endif %} -
  • {% endif %} - + {% endfor %} @@ -108,31 +108,17 @@ {{ chill_pagination(paginator) }} {% endif %} -
    +
    {{ form_start(form_add_event_participation_by_person) }} - {# - - #} - {{ form_widget(form_add_event_participation_by_person.event_id, { 'attr' : { 'class' : 'form-control' } } ) }} -
    - {# - - #} - {{ 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;' + }}) }} +
    + {{ form_widget(form_add_event_participation_by_person.submit, { 'attr' : { 'class' : 'btn btn-sm btn-save' } } ) }}
    {{ form_rest(form_add_event_participation_by_person) }} {{ form_end(form_add_event_participation_by_person) }}
    -{# -{{ form(form_add_event_participation_by_person) }} -#} - -
    - -
    - -
    -
    - {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig index 44d24040b..f0d1b0ea2 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/new.html.twig @@ -3,6 +3,7 @@ {% block title 'Event creation'|trans %} {% block event_content -%} +

    {{ 'Event creation'|trans }}

    {{ form_start(form) }} @@ -26,4 +27,5 @@ {{ form_end(form) }} +
    {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig index c4fb4aacd..a10d754e6 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/newPickCenter.html.twig @@ -3,6 +3,7 @@ {% block title 'Event creation'|trans %} {% block event_content -%} +

    {{ 'Event creation'|trans }}

    {{ form_start(form) }} @@ -22,5 +23,5 @@ {{ form_end(form) }} - +
    {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig index 6af5dd80a..4ce92a200 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Event/show.html.twig @@ -5,9 +5,10 @@ {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} {% block event_content -%} +

    {{ 'Details of an event'|trans }}

    - +
    @@ -69,7 +70,7 @@

    {% transchoice count %}%count% participations to this event{% endtranschoice %}

    {% if count > 0 %} -
    {{ 'Name'|trans }}
    +
    @@ -117,7 +118,7 @@ {% endif %} -
    +
    {{ form_start(form_add_participation_by_person) }}
    @@ -150,5 +151,5 @@
    {{ chill_delegated_block('block_footer_show', { 'event': event }) }}
    - +
    {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/confirm_delete.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/confirm_delete.html.twig index 9b023a915..0d993b075 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/confirm_delete.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/confirm_delete.html.twig @@ -5,7 +5,7 @@ {% block title 'Remove participation'|trans %} {% block event_content %} - +
    {{ include('@ChillMain/Util/confirmation_template.html.twig', { 'title' : 'Remove participation'|trans, @@ -15,6 +15,6 @@ 'form' : delete_form } ) }} - +
    {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/edit-multiple.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/edit-multiple.html.twig index a50615414..f0f522a3d 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/edit-multiple.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/edit-multiple.html.twig @@ -3,9 +3,10 @@ {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} {% block event_content -%} +

    {{ 'Participation Edit'|trans }}

    -
    {{ 'Person'|trans }}
    +
    @@ -18,11 +19,11 @@
    {{ 'Associated event'|trans }}
    -

    {{ 'Participations'|trans }}

    +

    {{ 'Participations'|trans }}

    {{ form_start(form) }} - +
    @@ -59,4 +60,5 @@ {{ form_end(form) }} + {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/edit.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/edit.html.twig index 19592526e..db716b3dc 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/edit.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/edit.html.twig @@ -3,6 +3,7 @@ {% import 'ChillPersonBundle:Person:macro.html.twig' as person_macro %} {% block event_content -%} +

    {{ 'Participation Edit'|trans }}

    {{ 'Person'|trans }}
    @@ -42,4 +43,5 @@ {{ form_end(form) }} + {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/new-multiple.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/new-multiple.html.twig index a0551ff1a..224b7265f 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/new-multiple.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/new-multiple.html.twig @@ -18,7 +18,7 @@ {% block event_content -%}

    {{ 'Participation creation'|trans }}

    -
    +
    @@ -30,7 +30,7 @@ {% include 'ChillEventBundle:Participation:_ignored_participations.html.twig' with ignored_participations %} {{ form_start(form) }} -
    {{ 'Associated event'|trans }}
    +
    diff --git a/src/Bundle/ChillEventBundle/Resources/views/Participation/new.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Participation/new.html.twig index 33f7bc213..3fbea8b68 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/Participation/new.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/Participation/new.html.twig @@ -5,6 +5,7 @@ {% block title 'Participation creation'|trans %} {% block event_content -%} +

    {{ 'Participation creation'|trans }}

    {{ 'Person'|trans }}
    @@ -43,5 +44,5 @@ {{ form_end(form) }} - + {% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/layout.html.twig b/src/Bundle/ChillEventBundle/Resources/views/layout.html.twig index 45eb6e481..e34a10e18 100644 --- a/src/Bundle/ChillEventBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillEventBundle/Resources/views/layout.html.twig @@ -16,9 +16,9 @@ * along with this program. If not, see . #} -{% extends "@ChillMain/layoutWithVerticalMenu.html.twig" %} +{% extends "@ChillMain/layout.html.twig" %} -{% block layout_wvm_content %} +{% block content %} {% block event_content %}

    {{ 'Event' |trans }}

    {% endblock %} diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 2a785af42..9c2148a14 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -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'], ]; diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php index 3f09f8181..2f622878a 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Configuration.php @@ -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; } } diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php index 468314159..ea2a66c13 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/Widget/AddWidgetConfigurationTrait.php @@ -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) diff --git a/src/Bundle/ChillMainBundle/Form/Type/ChillDateTimeType.php b/src/Bundle/ChillMainBundle/Form/Type/ChillDateTimeType.php index 639848d9a..0063ee7d9 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/ChillDateTimeType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/ChillDateTimeType.php @@ -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)) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue index fcd64ed70..30a240938 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue @@ -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: [] diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue index 80d2ca01a..d3c04260f 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/AddressMap.vue @@ -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(); - } + }, } diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue index 292b0de16..ca10285d1 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CitySelection.vue @@ -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; diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue index 6e64b2985..1b220ff00 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress/CountrySelection.vue @@ -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]; }, diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue index 9636a173f..4ab117395 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/EditPane.vue @@ -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 } } diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue index 7f7b1b529..bc246d542 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/ShowPane.vue @@ -102,7 +102,7 @@ export default { ], emits: ['openEditPane'], mounted() { - console.log('context', this.context) + //console.log('context', this.context) }, computed: { address() { diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js index 9241aa29d..ab0fb0bd4 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/index.js @@ -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. diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js index cb7da6e07..6e9fd917c 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/mod_input_address_index.js @@ -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: ``, @@ -34,6 +33,7 @@ const addAddressInput = (inputs) => { }, edit: isEdit, addressId: addressIdInt, + defaults: window.addaddress, }, options: { /// Options override default. diff --git a/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig index 571f4257f..70780eb90 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Address/_insert_vue_address.html.twig @@ -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') }}" > {{ encore_entry_script_tags('vue_address') }} diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index 5543809fc..319adad81 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -9,6 +9,11 @@ {% block head_custom %}{% endblock %} + + {{ encore_entry_link_tags('mod_bootstrap') }} {{ encore_entry_link_tags('mod_forkawesome') }} {{ encore_entry_link_tags('mod_ckeditor5') }} diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 3843a960f..4e2bd4e89 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -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; } diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php index 9e7938675..501af5b9d 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php @@ -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']) { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue index 42f974dd1..99e3519f4 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue @@ -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; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js index 63c2aba19..bfd684fce 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/store/index.js @@ -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, }; } }, diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue index 8694da651..34eddad5b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/OnTheFly/Person.vue @@ -218,7 +218,8 @@ export default { context: { target: {}, // boilerplate for getting the address id edit: false, - addressId: null + addressId: null, + defaults: window.addaddress } }, errors: [] diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue index 0ea011dc4..765d67fe8 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -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