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) { if ($person instanceof Person) {
$entity->setPerson($person); $entity->setPerson($person);
$entity->getPersons()->add($person);
} }
if ($accompanyingPeriod instanceof AccompanyingPeriod) { if ($accompanyingPeriod instanceof AccompanyingPeriod) {

View File

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

View File

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

View File

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

View File

@ -11,8 +11,8 @@ declare(strict_types=1);
namespace Chill\BudgetBundle\Entity; namespace Chill\BudgetBundle\Entity;
use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\HasCentersInterface;
use Chill\MainBundle\Entity\HasCenterInterface; use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable; use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -22,7 +22,7 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Table(name="chill_budget.charge") * @ORM\Table(name="chill_budget.charge")
* @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ChargeRepository") * @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ChargeRepository")
*/ */
class Charge extends AbstractElement implements HasCenterInterface class Charge extends AbstractElement implements HasCentersInterface
{ {
public const HELP_ASKED = 'running'; public const HELP_ASKED = 'running';
@ -46,22 +46,24 @@ class Charge extends AbstractElement implements HasCenterInterface
private $help = self::HELP_NOT_RELEVANT; private $help = self::HELP_NOT_RELEVANT;
/** /**
* @var int
*
* @ORM\Column(name="id", type="integer") * @ORM\Column(name="id", type="integer")
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO") * @ORM\GeneratedValue(strategy="AUTO")
*/ */
private $id; private ?int $id = null;
public function __construct() public function __construct()
{ {
$this->setStartDate(new DateTimeImmutable('today')); $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() public function getHelp()

View File

@ -11,8 +11,8 @@ declare(strict_types=1);
namespace Chill\BudgetBundle\Entity; namespace Chill\BudgetBundle\Entity;
use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\HasCentersInterface;
use Chill\MainBundle\Entity\HasCenterInterface; use Chill\PersonBundle\Entity\Person;
use DateTimeImmutable; use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -22,25 +22,27 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Table(name="chill_budget.resource") * @ORM\Table(name="chill_budget.resource")
* @ORM\Entity(repositoryClass="Chill\BudgetBundle\Repository\ResourceRepository") * @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\Column(name="id", type="integer")
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO") * @ORM\GeneratedValue(strategy="AUTO")
*/ */
private $id; private ?int $id = null;
public function __construct() public function __construct()
{ {
$this->setStartDate(new DateTimeImmutable('today')); $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 Chill\PersonBundle\Entity\Person;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use function in_array; use UnexpectedValueException;
class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
{ {
@ -68,12 +68,29 @@ class BudgetElementVoter extends AbstractChillVoter implements ProvideRoleHierar
protected function supports($attribute, $subject) protected function supports($attribute, $subject)
{ {
return (in_array($attribute, self::ROLES, true) && $subject instanceof AbstractElement) return $this->voter->supports($attribute, $subject);
|| (($subject instanceof Person || $subject instanceof Household) && in_array($attribute, [self::SEE, self::CREATE], true));
} }
protected function voteOnAttribute($attribute, $subject, TokenInterface $token) 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 { } else {
$centers = $this->authorizationHelper->getReachableCenters( $centers = $this->authorizationHelper->getReachableCenters(
$this->user, $this->user,
(string) $options['role'] (string) $options['role']->getRole()
); );
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * 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 --> {% block event_content %}<!-- block event content empty -->
<h1>{{ 'Event' |trans }}</h1> <h1>{{ 'Event' |trans }}</h1>
{% endblock %} {% endblock %}

View File

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

View File

@ -276,6 +276,16 @@ class Configuration implements ConfigurationInterface
->end() // end of root ->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; return $treeBuilder;
} }
} }

View File

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

View File

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

View File

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

View File

@ -8,8 +8,12 @@ import L from 'leaflet';
import markerIconPng from 'leaflet/dist/images/marker-icon.png' import markerIconPng from 'leaflet/dist/images/marker-icon.png'
import 'leaflet/dist/leaflet.css'; import 'leaflet/dist/leaflet.css';
const lonLatForLeaflet = (coordinates) => {
return [coordinates[1], coordinates[0]];
}
export default { export default {
name: 'AddressMap', name: 'AddressMap',
props: ['entity'], props: ['entity'],
data() { data() {
return { return {
@ -19,12 +23,49 @@ export default {
}, },
computed: { computed: {
center() { 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:{ methods:{
init() { 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(); this.map.scrollWheelZoom.disable();
@ -37,20 +78,22 @@ export default {
iconAnchor: [12, 41], 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); this.marker.addTo(this.map);
}, },
update() { update() {
//console.log('update map with : ', this.entity.addressMap.center)
if (this.marker && this.entity.addressMap.center) { if (this.marker && this.entity.addressMap.center) {
this.marker.setLatLng(this.entity.addressMap.center); this.marker.setLatLng(lonLatForLeaflet(this.entity.addressMap.center));
this.map.setView(this.entity.addressMap.center, 15); this.map.panTo(lonLatForLeaflet(this.entity.addressMap.center));
} }
} }
}, },
mounted(){ mounted() {
this.init(); this.init();
this.update(); },
}
} }
</script> </script>

View File

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

View File

@ -30,7 +30,7 @@ export default {
data() { data() {
return { return {
value: this.selectCountryByCode( 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() { mounted() {
this.init(); console.log('country selection mounted', this.value);
if (this.value !== undefined) {
this.selectCountry(this.value);
}
}, },
methods: { methods: {
init() {
if (this.value !== undefined) {
this.selectCountry(this.value);
}
},
selectCountryByCode(countryCode) { selectCountryByCode(countryCode) {
return this.entity.loaded.countries.filter(c => c.countryCode === countryCode)[0]; return this.entity.loaded.countries.filter(c => c.countryCode === countryCode)[0];
}, },

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,6 +9,11 @@
{% block head_custom %}{% endblock %} {% block head_custom %}{% endblock %}
<link rel="shortcut icon" href="{{ asset('build/images/favicon.ico') }}" type="image/x-icon"> <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_bootstrap') }}
{{ encore_entry_link_tags('mod_forkawesome') }} {{ encore_entry_link_tags('mod_forkawesome') }}
{{ encore_entry_link_tags('mod_ckeditor5') }} {{ encore_entry_link_tags('mod_ckeditor5') }}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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