mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'issue566_commentaire_fonctionnalites' into 'master'
Issue566 commentaire fonctionnalites See merge request Chill-Projet/chill-bundles!416
This commit is contained in:
commit
86a7bb5880
@ -35,7 +35,8 @@ and this project adheres to
|
||||
* [Accompanying period work evaluations] list documents associated to a work by creation date, and then by id, from the most recent to older
|
||||
* [Course comment] add validationConstraint NotNull and NotBlank on comment content, to avoid sql error
|
||||
* [Notifications] delay the sending of notificaiton to kernel.terminate
|
||||
* [Notifications / Period user change] fix the sending of notification when user changes
|
||||
* [Notifications / Period user change] fix the sending of notification when user changes
|
||||
* [parcours]: Comments can be unpinned + edit/delete for all users that are allowed to edit parcours (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/566)
|
||||
* [Activity form] invert 'incoming' and 'receiving' in Activity form
|
||||
* [Activity form] keep the same order for 'attendee' field in new and edit form
|
||||
* [list with period] use "sameas" test operator to introduce requestor in list
|
||||
|
@ -186,6 +186,24 @@ class AccompanyingCourseCommentController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/parcours/comment/{id}/unpin", name="chill_person_accompanying_period_comment_unpin")
|
||||
*/
|
||||
public function unpinComment(AccompanyingPeriod\Comment $comment): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $comment->getAccompanyingPeriod());
|
||||
|
||||
$comment->getAccompanyingPeriod()->setPinnedComment(null);
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator->trans('accompanying_course.comment is unpinned'));
|
||||
|
||||
return $this->redirectToRoute('chill_person_accompanying_period_comment_list', [
|
||||
'accompanying_period_id' => $comment->getAccompanyingPeriod()->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
private function createCommentForm(AccompanyingPeriod\Comment $comment, string $step): FormInterface
|
||||
{
|
||||
return $this->formFactory->createNamed($step, AccompanyingCourseCommentType::class, $comment);
|
||||
|
@ -1258,10 +1258,6 @@ class AccompanyingPeriod implements
|
||||
*/
|
||||
public function setPinnedComment(?Comment $comment = null): self
|
||||
{
|
||||
if (null !== $this->pinnedComment) {
|
||||
$this->removeComment($this->pinnedComment);
|
||||
}
|
||||
|
||||
if (null !== $this->pinnedComment) {
|
||||
$this->addComment($this->pinnedComment);
|
||||
}
|
||||
|
@ -8,6 +8,17 @@
|
||||
|
||||
{% macro recordAction(comment, isPinned) %}
|
||||
{% if isPinned is defined and isPinned == true %}
|
||||
<li>
|
||||
<form method="post" action="{{ chill_path_forward_return_path('chill_person_accompanying_period_comment_unpin', {'id': comment.id}) }}">
|
||||
<button class="btn btn-sm btn-misc" type="submit">
|
||||
<span class="fa-stack">
|
||||
<i class="fa fa-flag fa-stack-1x"></i>
|
||||
<i class="fa fa-ban fa-stack-2x text-danger"></i>
|
||||
</span>
|
||||
{{ 'Unpin comment'|trans }}
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<form method="post" action="{{ chill_path_forward_return_path('chill_person_accompanying_period_comment_pin', {'id': comment.id}) }}">
|
||||
@ -17,7 +28,7 @@
|
||||
</form>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_EDIT', comment) %}
|
||||
{% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE', comment.accompanyingPeriod) %}
|
||||
<li>
|
||||
<a class="btn btn-sm btn-edit" title="{{ 'Edit'|trans }}" href="{{ path('chill_person_accompanying_period_comment_list', {
|
||||
'_fragment': 'comment-' ~ comment.id,
|
||||
@ -26,7 +37,7 @@
|
||||
}) }}"></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_DELETE', comment) %}
|
||||
{% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE', comment.accompanyingPeriod) %}
|
||||
<li>
|
||||
<a class="btn btn-sm btn-delete" title="{{ 'Delete'|trans }}" href="{{ path('chill_person_accompanying_period_comment_delete', {'id': comment.id}) }}"></a>
|
||||
</li>
|
||||
|
@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Security\Authorization;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use UnexpectedValueException;
|
||||
|
||||
class AccompanyingPeriodCommentVoter extends Voter
|
||||
@ -22,6 +23,13 @@ class AccompanyingPeriodCommentVoter extends Voter
|
||||
|
||||
public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_EDIT';
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
{
|
||||
return $subject instanceof Comment;
|
||||
@ -32,8 +40,10 @@ class AccompanyingPeriodCommentVoter extends Voter
|
||||
/** @var Comment $subject */
|
||||
switch ($attribute) {
|
||||
case self::EDIT:
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod());
|
||||
|
||||
case self::DELETE:
|
||||
return $subject->getCreator() === $token->getUser();
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod());
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("This attribute {$attribute} is not supported");
|
||||
|
@ -465,6 +465,7 @@ fix it: Compléter
|
||||
accompanying_course:
|
||||
administrative_location: Localisation administrative
|
||||
comment is pinned: Le commentaire est épinglé
|
||||
comment is unpinned: Le commentaire est désépinglé
|
||||
show: Montrer
|
||||
hide: Masquer
|
||||
closed periods: parcours clôturer
|
||||
@ -474,6 +475,7 @@ Accompanying Course Comment: Commentaire
|
||||
Accompanying Course Comment list: Commentaires du parcours
|
||||
pinned: épinglé
|
||||
Pin comment: Épingler
|
||||
Unpin comment: Désépingler
|
||||
Post a new comment: Poster un nouveau commentaire
|
||||
Write a new comment: Écrire un nouveau commentaire
|
||||
Edit a comment: Modifier le commentaire
|
||||
|
Loading…
x
Reference in New Issue
Block a user