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 } ) }}
-
+
-
- {{ 'Name'|trans }} |
- {{ 'Date'|trans }} |
- {{ 'Event type'|trans }} |
- |
-
+
+ {{ 'Name'|trans }} |
+ {{ 'Date'|trans }} |
+ {{ 'Event type'|trans }} |
+ |
+
- {% for event in events %}
-
- {{ 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 }} |
+
+
+ -
+ {# {% if is_granted('CHILL_EVENT_SEE_DETAILS', event) %} #}
+
+ {{ 'See'|trans }}
+
+ {# {% endif %} #}
+ {% if is_granted('CHILL_EVENT_UPDATE', event) %}
{{ 'Edit'|trans }}
- {% endif %}
-
-
- |
-
- {% endfor %}
+ {% endif %}
+
+
+ |
+
+ {% endfor %}
-
+
{% 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 }} |
-
+
{% 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) %}
- -
-
+ class="btn btn-primary btn-sm" title="{{ 'See details of the event'|trans }}">
+
+
{% endif %}
{% if is_granted('CHILL_EVENT_UPDATE', participation.event)
and is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %}
- -
-
{% 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 %}
-