diff --git a/.env.test b/.env.test index c9ff04a55..914deb541 100644 --- a/.env.test +++ b/.env.test @@ -3,4 +3,3 @@ # Run tests from root to adapt your own environment KERNEL_CLASS='App\Kernel' APP_SECRET='$ecretf0rt3st' -DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres?serverVersion=12&charset=utf8 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1037d8f86..85c3d476c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,6 +20,8 @@ variables: # Configure postgres environment variables (https://hub.docker.com/r/_/postgres/) POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres + # configure database access + DATABASE_URL: postgresql://postgres:postgres@db:5432/postgres?serverVersion=12&charset=utf8 # fetch the chill-app using git submodules GIT_SUBMODULE_STRATEGY: recursive REDIS_HOST: redis diff --git a/CHANGELOG.md b/CHANGELOG.md index 02e71d901..88ca41243 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ and this project adheres to * [notification] new notification interface, can be associated to AccompanyingCourse/Period, Activities. * List notifications, show, and comment in User section * Notify button and contextual notification box on associated objects pages +* [accompanyingCourse] add a comment for each resource associated. A modal allow to save comment. Comment is displayed in on-the-fly show modal of the accompanyingCourse context (edit page + resume page). ### test release 2021-12-14 diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/_list_item.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/_list_item.html.twig index bb4c6fd16..09a7ab2a3 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/_list_item.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/_list_item.html.twig @@ -66,7 +66,7 @@ {% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with { 'context': context, - 'with_display': 'wrap-list', + 'render': 'wrap-list', 'entity': activity, 'badge_person': true } %} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig index d6d0ed43d..70280d714 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/concernedGroups.html.twig @@ -3,11 +3,12 @@ {{ path(pathname, parms) }} {% endmacro %} -{% macro insert_onthefly(type, entity) %} +{% macro insert_onthefly(type, entity, parent = null) %} {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { action: 'show', displayBadge: true, targetEntity: { name: type, id: entity.id }, - buttonText: entity|chill_entity_render_string + buttonText: entity|chill_entity_render_string, + parent: parent } %} {% endmacro %} @@ -59,7 +60,7 @@ }]) %} {% endif %} -{% if (with_display == 'bloc') %} +{% if (render == 'bloc') %}
{% for bloc in blocks %} @@ -90,7 +91,7 @@
{% endif %} -{% if (with_display == 'row') %} +{% if (render == 'row') %}
{% for bloc in blocks %}
@@ -115,7 +116,7 @@
{% endif %} -{% if (with_display == 'wrap-list') %} +{% if (render == 'wrap-list') %}
{% for bloc in blocks %}
diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig index 633493104..b67ff08ef 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig @@ -85,7 +85,7 @@ {% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with { 'context': context, - 'with_display': 'bloc', + 'render': 'bloc', 'badge_person': 'true' } %} diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig index 215b7bb55..6cf97a58d 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/listByAccompanyingCourse.html.twig @@ -94,7 +94,7 @@
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with { 'context': accompanyingCourse, - 'with_display': 'row', + 'render': 'row', 'entity': calendar } %}
diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig index 7c59996d2..3a1bf03d5 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig @@ -6,7 +6,7 @@

{{ 'Concerned groups'|trans }}

-{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'bloc' } %} +{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'render': 'bloc' } %}

{{ 'Calendar data'|trans }}

@@ -108,13 +108,13 @@ {# TODO {% if is_granted('CHILL_ACTIVITY_DELETE', entity) %} #} - +
  • {{ 'Delete'|trans }}
  • - + {# {% endif %} #} 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 76979b7aa..1f62269de 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/Address/components/AddAddress.vue @@ -365,8 +365,8 @@ export default { //console.log('validFrom', this.validFrom); //console.log('validTo', this.validTo); //console.log('useDatePane', this.useDatePane); + //console.log('Mounted now !'); - console.log('Mounted now !'); if (this.context.edit) { console.log('getInitialAddress', this.context.addressId); this.getInitialAddress(this.context.addressId); @@ -386,7 +386,7 @@ export default { this.openEditPane(); } else { this.flag.showPane = true; - console.log('step0: open the Show Panel'); + //console.log('step0: open the Show Panel'); } }, closeShowPane() { diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue index 48f68380b..05fed6671 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue @@ -5,6 +5,7 @@ :action="context.action" :buttonText="options.buttonText" :displayBadge="options.displayBadge === 'true'" + :parent="options.parent" @saveFormOnTheFly="saveFormOnTheFly"> diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue index d64ae274e..d4342fdee 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -23,25 +23,37 @@ @@ -78,18 +90,25 @@ export default { OnTheFlyThirdparty, OnTheFlyCreate }, - props: ['type', 'id', 'action', 'buttonText', 'displayBadge'], + props: ['type', 'id', 'action', 'buttonText', 'displayBadge', 'parent'], emits: ['saveFormOnTheFly'], data() { return { modal: { showModal: false, modalDialogClass: "modal-dialog-scrollable modal-xl" - }, - //action: this.action + } } }, computed: { + hasResourceComment() { + //console.log('hasResourceComment', this.parent); + return (typeof this.parent !== 'undefined' && this.parent !== null) + && this.action === 'show' + && this.parent.type === 'accompanying_period_resource' + && (this.parent.comment !== null && this.parent.comment !== '') + ; + }, classAction() { switch (this.action) { case 'show': @@ -145,8 +164,8 @@ export default { }, methods: { openModal() { - console.log('## OPEN ON THE FLY MODAL'); - console.log('## type:', this.type, ', action:', this.action); + //console.log('## OPEN ON THE FLY MODAL'); + //console.log('## type:', this.type, ', action:', this.action); this.modal.showModal = true; this.$nextTick(function() { //this.$refs.search.focus(); diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/i18n.js index 3cba67149..c619ef96b 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/i18n.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/i18n.js @@ -17,6 +17,7 @@ const ontheflyMessages = { person: "un nouvel usager", thirdparty: "un nouveau tiers professionnel" }, + resource_comment_title: "Un commentaire est associé à cet interlocuteur" } } } diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/index.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/index.js index 88e6aad5e..479cc1248 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/index.js @@ -21,7 +21,8 @@ containers.forEach((container) => { }, options: { buttonText: container.dataset.buttonText || null, - displayBadge: container.dataset.displayBadge || false + displayBadge: container.dataset.displayBadge || false, + parent: JSON.parse(container.dataset.parent) || null, } } } diff --git a/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig b/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig index e63fd9ee0..666743fb2 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/OnTheFly/_insert_vue_onthefly.html.twig @@ -10,6 +10,7 @@ * action string 'show', 'edit', 'create' * buttonText string * displayBadge boolean (default: false) replace button by badge, need to define buttonText for content + * parent object (optional) pass parent context of the targetEntity (used for course resource comment) #} {{ encore_entry_script_tags('vue_onthefly') }} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Util/confirmation_template.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Util/confirmation_template.html.twig index 1da31cfc7..119e213ef 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Util/confirmation_template.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Util/confirmation_template.html.twig @@ -6,7 +6,7 @@

    {{ confirm_question }}

    {% endif %} -{% if display_content is not empty %} +{% if display_content is defined and display_content is not empty %} {{ display_content|raw }} {% endif %} diff --git a/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php b/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php index 6bf966bbb..8110fa11d 100644 --- a/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Entity/NotificationTest.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\Notification; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Repository\UserRepository; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use DateTimeImmutable; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use function count; @@ -98,6 +99,7 @@ final class NotificationTest extends KernelTestCase ->setSender($em->find(User::class, $senderId)) ->setRelatedEntityId(0) ->setRelatedEntityClass(AccompanyingPeriod::class) + ->setUpdatedAt(new DateTimeImmutable()) ->setMessage('Fake message'); foreach ($addressesIds as $addresseeId) { diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 000720a7f..5982fcebe 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\DependencyInjection; use Chill\MainBundle\DependencyInjection\MissingBundleException; use Chill\MainBundle\Security\Authorization\ChillExportVoter; use Chill\PersonBundle\Doctrine\DQL\AddressPart; +use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodResourceVoter; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Exception; @@ -413,6 +414,25 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac ], ], ], + [ + 'class' => \Chill\PersonBundle\Entity\AccompanyingPeriod\Resource::class, + 'name' => 'accompanying_period_resource', + 'base_path' => '/api/1.0/person/accompanying-period/resource', + 'base_role' => 'ROLE_USER', + 'actions' => [ + '_entity' => [ + 'methods' => [ + Request::METHOD_GET => false, + Request::METHOD_PATCH => true, + Request::METHOD_HEAD => false, + Request::METHOD_DELETE => false, + ], + 'roles' => [ + Request::METHOD_PATCH => AccompanyingPeriodResourceVoter::EDIT, + ], + ], + ], + ], [ 'class' => \Chill\PersonBundle\Entity\AccompanyingPeriod\Origin::class, 'name' => 'accompanying_period_origin', diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php index a11dc9b3d..8f84f319a 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php @@ -20,6 +20,8 @@ use Symfony\Component\Serializer\Annotation\Groups; use UnexpectedValueException; /** + * **About denormalization**: this operation is operated by @see{AccompanyingPeriodResourdeNormalizer}. + * * @ORM\Entity * @ORM\Table( * name="chill_person_accompanying_period_resource", @@ -44,9 +46,10 @@ class Resource private ?AccompanyingPeriod $accompanyingPeriod = null; /** - * @ORM\ManyToOne(targetEntity=Comment::class) + * @ORM\Column(type="text", nullable=true) + * @Groups({"read"}) */ - private $comment; + private ?string $comment = ''; /** * @ORM\Id @@ -75,7 +78,7 @@ class Resource return $this->accompanyingPeriod; } - public function getComment(): ?Comment + public function getComment(): ?string { return $this->comment; } @@ -92,7 +95,7 @@ class Resource /** * @return Person|ThirdParty - * @Groups({"read", "write"}) + * @Groups({"read"}) */ public function getResource() { @@ -111,9 +114,9 @@ class Resource return $this; } - public function setComment(?Comment $comment): self + public function setComment(?string $comment = null): self { - $this->comment = $comment; + $this->comment = (string) $comment; return $this; } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss index 46c13d152..e8a98bc80 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss +++ b/src/Bundle/ChillPersonBundle/Resources/public/chill/scss/badge.scss @@ -184,5 +184,9 @@ div[class*='activity-'] { background-color: $chill-ll-gray; color: $chill-blue; } + &.bg-confidential { + background-color: $chill-ll-gray; + color: $chill-red; + } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue index e17555c6a..e7bc18371 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources/ResourceItem.vue @@ -14,8 +14,15 @@ }">