mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
allow to edit notification
This commit is contained in:
parent
478c3b3247
commit
9d638fe897
@ -120,6 +120,36 @@ class NotificationController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/{id}/edit", name="chill_main_notification_edit")
|
||||||
|
*/
|
||||||
|
public function editAction(Notification $notification, Request $request): Response
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted(NotificationVoter::UPDATE, $notification);
|
||||||
|
|
||||||
|
$form = $this->createForm(NotificationType::class, $notification);
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
$this->em->flush();
|
||||||
|
|
||||||
|
$this->addFlash('success', $this->translator->trans('notification.Notification updated'));
|
||||||
|
|
||||||
|
if ($request->query->has('returnPath')) {
|
||||||
|
return new RedirectResponse($request->query->get('returnPath'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->redirectToRoute('chill_main_notification_my');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('@ChillMain/Notification/edit.html.twig', [
|
||||||
|
'form' => $form->createView(),
|
||||||
|
'handler' => $this->notificationHandlerManager->getHandler($notification),
|
||||||
|
'notification' => $notification,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/inbox", name="chill_main_notification_my")
|
* @Route("/inbox", name="chill_main_notification_my")
|
||||||
*/
|
*/
|
||||||
|
@ -12,7 +12,6 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\Entity;
|
namespace Chill\MainBundle\Entity;
|
||||||
|
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
{% extends "@ChillMain/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-10">
|
||||||
|
{% include handler.template(notification) with handler.templateData(notification) %}
|
||||||
|
|
||||||
|
{{ form_start(form, { 'attr': { 'id': 'notification' }}) }}
|
||||||
|
|
||||||
|
{{ form_row(form.addressees) }}
|
||||||
|
{{ form_row(form.message) }}
|
||||||
|
|
||||||
|
{{ form_end(form) }}
|
||||||
|
<ul class="record_actions sticky-form-buttons">
|
||||||
|
<li class="cancel">
|
||||||
|
<a href="{{ chill_return_path_or('chill_main_homepage') }}" class="btn btn-cancel">{{ 'Cancel'|trans|chill_return_path_label }}</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button type="submit" form="notification" class="btn btn-save">{{ 'Save'|trans }}</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
@ -66,9 +66,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="item-row">
|
<div class="item-row">
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
{% if is_granted('CHILL_MAIN_NOTIFICATION_UPDATE', notification) %}
|
||||||
<a href="{{ chill_path_add_return_path('chill_main_notification_show', {'id': notification.id}) }}" class="btn btn-show"></a>
|
<li>
|
||||||
</li>
|
<a href="{{ chill_path_add_return_path('chill_main_notification_edit', {'id': notification.id}) }}" class="btn btn-edit"></a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if is_granted('CHILL_MAIN_NOTIFICATION_SEE', notification) %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ chill_path_add_return_path('chill_main_notification_show', {'id': notification.id}) }}" class="btn btn-show"></a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -22,9 +22,9 @@ final class NotificationVoter extends Voter
|
|||||||
{
|
{
|
||||||
public const COMMENT_EDIT = 'CHILL_MAIN_NOTIFICATION_COMMENT_EDIT';
|
public const COMMENT_EDIT = 'CHILL_MAIN_NOTIFICATION_COMMENT_EDIT';
|
||||||
|
|
||||||
public const SEE = 'chill_main_notification_see';
|
public const SEE = 'CHILL_MAIN_NOTIFICATION_SEE';
|
||||||
|
|
||||||
public const UPDATE = 'chill_main_notification_update';
|
public const UPDATE = 'CHILL_MAIN_NOTIFICATION_UPDATE';
|
||||||
|
|
||||||
protected function supports($attribute, $subject): bool
|
protected function supports($attribute, $subject): bool
|
||||||
{
|
{
|
||||||
@ -48,6 +48,9 @@ final class NotificationVoter extends Voter
|
|||||||
case self::SEE:
|
case self::SEE:
|
||||||
return $subject->getSender() === $user || $subject->getAddressees()->contains($user);
|
return $subject->getSender() === $user || $subject->getAddressees()->contains($user);
|
||||||
|
|
||||||
|
case self::UPDATE:
|
||||||
|
return $subject->getSender() === $user;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new UnexpectedValueException("this subject {$attribute} is not implemented");
|
throw new UnexpectedValueException("this subject {$attribute} is not implemented");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user