mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge branch 'master' into issue433_email_addPerson
This commit is contained in:
@@ -12,6 +12,8 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
@@ -19,7 +21,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
*/
|
||||
class LocationApiController extends ApiController
|
||||
{
|
||||
public function customizeQuery(string $action, Request $request, $query): void
|
||||
protected function customizeQuery(string $action, Request $request, $query): void
|
||||
{
|
||||
$query
|
||||
->leftJoin('e.locationType', 'lt')
|
||||
@@ -31,4 +33,14 @@ class LocationApiController extends ApiController
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param QueryBuilder $query
|
||||
* @param mixed $_format
|
||||
*/
|
||||
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator, $_format)
|
||||
{
|
||||
return $query
|
||||
->addOrderBy('e.name', 'ASC');
|
||||
}
|
||||
}
|
||||
|
@@ -236,6 +236,10 @@ class NotificationController extends AbstractController
|
||||
'_fragment' => 'comment-' . $commentId,
|
||||
]);
|
||||
}
|
||||
|
||||
if ($editedCommentForm->isSubmitted() && !$editedCommentForm->isValid()) {
|
||||
$this->addFlash('error', $this->translator->trans('This form contains errors'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,6 +261,10 @@ class NotificationController extends AbstractController
|
||||
'id' => $notification->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($appendCommentForm->isSubmitted() && !$appendCommentForm->isValid()) {
|
||||
$this->addFlash('error', $this->translator->trans('This form contains errors'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ use DateTimeInterface;
|
||||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||
use Doctrine\ORM\Event\PreFlushEventArgs;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
@@ -28,6 +29,7 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
* @Assert\NotBlank(message="notification.Comment content might not be blank")
|
||||
*/
|
||||
private string $content = '';
|
||||
|
||||
@@ -136,9 +138,9 @@ class NotificationComment implements TrackCreationInterface, TrackUpdateInterfac
|
||||
$this->recentlyPersisted = true;
|
||||
}
|
||||
|
||||
public function setContent(string $content): self
|
||||
public function setContent(?string $content): self
|
||||
{
|
||||
$this->content = $content;
|
||||
$this->content = (string) $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@@ -79,11 +79,8 @@ class NotificationMailer
|
||||
continue;
|
||||
}
|
||||
|
||||
$email = new Email();
|
||||
$email
|
||||
->subject($notification->getTitle());
|
||||
|
||||
if ($notification->isSystem()) {
|
||||
$email = new Email();
|
||||
$email
|
||||
->text($notification->getMessage());
|
||||
} else {
|
||||
@@ -96,7 +93,9 @@ class NotificationMailer
|
||||
]);
|
||||
}
|
||||
|
||||
$email->to($addressee->getEmail());
|
||||
$email
|
||||
->subject($notification->getTitle())
|
||||
->to($addressee->getEmail());
|
||||
|
||||
try {
|
||||
$this->mailer->send($email);
|
||||
|
@@ -47,7 +47,8 @@ export default {
|
||||
console.log('goToGenerateWorkflow', event, workflowName);
|
||||
|
||||
if (!this.$props.preventDefaultMoveToGenerate) {
|
||||
event.target.click();
|
||||
console.log('to go generate');
|
||||
window.location.assign(this.makeLink(workflowName));
|
||||
}
|
||||
|
||||
this.$emit('goToGenerateWorkflow', {event, workflowName, link: this.makeLink(workflowName)});
|
||||
|
@@ -91,11 +91,11 @@ export const multiSelectMessages = {
|
||||
multiselect: {
|
||||
placeholder: 'Choisir',
|
||||
tag_placeholder: 'Créer un nouvel élément',
|
||||
select_label: 'Appuyer sur "Entrée" pour sélectionner',
|
||||
deselect_label: 'Appuyer sur "Entrée" pour désélectionner',
|
||||
select_label: '"Entrée" ou cliquez pour sélectionner',
|
||||
deselect_label: '"Entrée" ou cliquez pour désélectionner',
|
||||
select_group_label: 'Appuyer sur "Entrée" pour sélectionner ce groupe',
|
||||
deselect_group_label: 'Appuyer sur "Entrée" pour désélectionner ce groupe',
|
||||
selected_label: 'Sélectionné'
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@@ -15,11 +15,11 @@
|
||||
|
||||
<div class="notification-comment-list my-5">
|
||||
<h2 class="chill-blue">{{ 'notification.comments_list'|trans }}</h2>
|
||||
|
||||
|
||||
{% if notification.comments|length > 0 %}
|
||||
<div class="flex-table">
|
||||
{% for comment in notification.comments %}
|
||||
|
||||
|
||||
{% if editedCommentForm is null or editedCommentId != comment.id %}
|
||||
{{ m.show_comment(comment, {
|
||||
'recordAction': _self.recordAction(comment)
|
||||
@@ -28,10 +28,11 @@
|
||||
<div class="item-bloc">
|
||||
<div class="item-row row">
|
||||
<a id="comment-{{ comment.id }}"></a>
|
||||
|
||||
|
||||
{{ form_start(editedCommentForm) }}
|
||||
{{ form_errors(editedCommentForm) }}
|
||||
{{ form_widget(editedCommentForm.content) }}
|
||||
{{ form_errors(editedCommentForm.content) }}
|
||||
<input type="hidden" name="form" value="edit" />
|
||||
<ul class="record_actions">
|
||||
<li class="cancel">
|
||||
@@ -46,24 +47,25 @@
|
||||
</li>
|
||||
</ul>
|
||||
{{ form_end(editedCommentForm) }}
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<span class="chill-no-data-statement">{{ 'No comments'|trans }}</span>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if appendCommentForm is not null %}
|
||||
<div class="new-comment my-5">
|
||||
<h2 class="chill-blue mb-4">{{ 'Write a new comment'|trans }}</h2>
|
||||
|
||||
|
||||
{{ form_start(appendCommentForm) }}
|
||||
{{ form_errors(appendCommentForm) }}
|
||||
{{ form_widget(appendCommentForm.content) }}
|
||||
{{ form_errors(appendCommentForm.content) }}
|
||||
<input type="hidden" name="form" value="append" />
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
@@ -71,7 +73,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
{{ form_end(appendCommentForm) }}
|
||||
|
||||
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -16,16 +16,16 @@ use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||
use Chill\MainBundle\Repository\Workflow\EntityWorkflowStepRepository;
|
||||
use Chill\MainBundle\Templating\UI\NotificationCounterInterface;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Workflow\Event\Event;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
final class WorkflowByUserCounter implements NotificationCounterInterface, EventSubscriberInterface
|
||||
{
|
||||
private EntityWorkflowStepRepository $workflowStepRepository;
|
||||
|
||||
private CacheItemPoolInterface $cacheItemPool;
|
||||
|
||||
private EntityWorkflowStepRepository $workflowStepRepository;
|
||||
|
||||
public function __construct(EntityWorkflowStepRepository $workflowStepRepository, CacheItemPoolInterface $cacheItemPool)
|
||||
{
|
||||
$this->workflowStepRepository = $workflowStepRepository;
|
||||
@@ -54,14 +54,21 @@ final class WorkflowByUserCounter implements NotificationCounterInterface, Event
|
||||
return $nb;
|
||||
}
|
||||
|
||||
public static function generateCacheKeyWorkflowByUser(User $user): string
|
||||
{
|
||||
return 'chill_main_workflow_by_u_' . $user->getId();
|
||||
}
|
||||
|
||||
public function getCountUnreadByUser(User $user): int
|
||||
{
|
||||
return $this->workflowStepRepository->countUnreadByUser($user);
|
||||
}
|
||||
|
||||
public static function generateCacheKeyWorkflowByUser(User $user): string
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return 'chill_main_workflow_by_u_'.$user->getId();
|
||||
return [
|
||||
'workflow.leave' => 'resetWorkflowCache',
|
||||
];
|
||||
}
|
||||
|
||||
public function resetWorkflowCache(Event $event): void
|
||||
@@ -74,11 +81,12 @@ final class WorkflowByUserCounter implements NotificationCounterInterface, Event
|
||||
$entityWorkflow = $event->getSubject();
|
||||
$step = $entityWorkflow->getCurrentStep();
|
||||
|
||||
if ($step === null) {
|
||||
if (null === $step) {
|
||||
return;
|
||||
}
|
||||
|
||||
$keys = [];
|
||||
|
||||
foreach ($step->getDestUser() as $user) {
|
||||
$keys[] = self::generateCacheKeyWorkflowByUser($user);
|
||||
}
|
||||
@@ -86,15 +94,5 @@ final class WorkflowByUserCounter implements NotificationCounterInterface, Event
|
||||
if ([] !== $keys) {
|
||||
$this->cacheItemPool->deleteItems($keys);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
'workflow.leave' => 'resetWorkflowCache',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -27,4 +27,4 @@ address:
|
||||
notification:
|
||||
At least one addressee: Indiquez au moins un destinataire
|
||||
Title must be defined: Un titre doit être indiqué
|
||||
|
||||
Comment content might not be blank: Le commentaire ne peut pas être vide
|
||||
|
Reference in New Issue
Block a user