mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge branch 'master' into 'issue378_normalize_requestor'
# Conflicts: # CHANGELOG.md
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'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -167,6 +167,7 @@ class WorkflowController extends AbstractController
|
||||
|
||||
$handler = $this->entityWorkflowManager->getHandler($entityWorkflow);
|
||||
$workflow = $this->registry->get($entityWorkflow, $entityWorkflow->getWorkflowName());
|
||||
$errors = [];
|
||||
|
||||
if (count($workflow->getEnabledTransitions($entityWorkflow)) > 0) {
|
||||
// possible transition
|
||||
@@ -245,7 +246,7 @@ class WorkflowController extends AbstractController
|
||||
'handler_template_data' => $handler->getTemplateData($entityWorkflow),
|
||||
'transition_form' => isset($transitionForm) ? $transitionForm->createView() : null,
|
||||
'entity_workflow' => $entityWorkflow,
|
||||
'transition_form_errors' => $errors ?? [],
|
||||
'transition_form_errors' => $errors,
|
||||
//'comment_form' => $commentForm->createView(),
|
||||
]
|
||||
);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -135,6 +135,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
|
||||
if (!$this->steps->contains($step)) {
|
||||
$this->steps[] = $step;
|
||||
$step->setEntityWorkflow($this);
|
||||
$this->stepsChainedCache = null;
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -332,32 +333,26 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
public function isFinal(): bool
|
||||
{
|
||||
$steps = $this->getStepsChained();
|
||||
|
||||
if (1 === count($steps)) {
|
||||
// the initial step cannot be finalized
|
||||
return false;
|
||||
foreach ($this->getStepsChained() as $step) {
|
||||
if ($step->isFinal()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/** @var EntityWorkflowStep $last */
|
||||
$last = end($steps);
|
||||
|
||||
return $last->isFinal();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isFreeze(): bool
|
||||
{
|
||||
$steps = $this->getStepsChained();
|
||||
|
||||
if (1 === count($steps)) {
|
||||
// the initial step cannot be finalized
|
||||
return false;
|
||||
foreach ($this->getStepsChained() as $step) {
|
||||
if ($step->isFreezeAfter()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/** @var EntityWorkflowStep $last */
|
||||
$last = end($steps);
|
||||
|
||||
return $last->getPrevious()->isFreezeAfter();
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isUserSubscribedToFinal(User $user): bool
|
||||
@@ -434,7 +429,7 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
|
||||
$newStep->setCurrentStep($step);
|
||||
|
||||
// copy the freeze
|
||||
if ($this->getCurrentStep()->isFreezeAfter()) {
|
||||
if ($this->isFreeze()) {
|
||||
$newStep->setFreezeAfter(true);
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -56,7 +56,7 @@ class EntityWorkflowStepRepository implements ObjectRepository
|
||||
|
||||
public function getClassName()
|
||||
{
|
||||
return EntityWorkflow::class;
|
||||
return EntityWorkflowStep::class;
|
||||
}
|
||||
|
||||
private function buildQueryByUser(User $user): QueryBuilder
|
||||
|
@@ -17,7 +17,12 @@ function loadDynamicPicker(element) {
|
||||
isMultiple = parseInt(el.dataset.multiple) === 1,
|
||||
uniqId = el.dataset.uniqid,
|
||||
input = element.querySelector('[data-input-uniqid="'+ el.dataset.uniqid +'"]'),
|
||||
picked = (isMultiple) ? (JSON.parse(input.value)) : ((input.value === '[]') ? (null) : ([JSON.parse(input.value)]));
|
||||
picked = isMultiple ?
|
||||
JSON.parse(input.value) : (
|
||||
(input.value === '[]' || input.value === '') ?
|
||||
null : [ JSON.parse(input.value) ]
|
||||
)
|
||||
;
|
||||
|
||||
if (!isMultiple) {
|
||||
if (input.value === '[]'){
|
||||
|
@@ -32,7 +32,7 @@
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span v-if="c.emergency" class="badge rounded-pill bg-danger">{{ $t('emergency') }}</span>
|
||||
<span v-if="c.emergency" class="badge rounded-pill bg-danger me-1">{{ $t('emergency') }}</span>
|
||||
<span v-if="c.confidential" class="badge rounded-pill bg-danger">{{ $t('confidential') }}</span>
|
||||
</td>
|
||||
<td>
|
||||
@@ -80,5 +80,7 @@ export default {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
span.badge.rounded-pill.bg-danger {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
</style>
|
@@ -50,7 +50,9 @@ const appMessages = {
|
||||
assignated_evaluations: "{n} évaluation assignée | {n} évaluations assignées",
|
||||
alert_tasks: "{n} tâche en rappel | {n} tâches en rappel",
|
||||
warning_tasks: "{n} tâche à échéance | {n} tâches à échéance",
|
||||
}
|
||||
},
|
||||
emergency: "Urgent",
|
||||
confidential: "Confidentiel",
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -90,7 +90,7 @@ export default {
|
||||
OnTheFlyThirdparty,
|
||||
OnTheFlyCreate
|
||||
},
|
||||
props: ['type', 'id', 'action', 'buttonText', 'displayBadge', 'isDead', 'parent', 'canCloseModal'],
|
||||
props: ['type', 'id', 'action', 'buttonText', 'displayBadge', 'isDead', 'parent'],
|
||||
emits: ['saveFormOnTheFly'],
|
||||
data() {
|
||||
return {
|
||||
@@ -160,17 +160,10 @@ export default {
|
||||
},
|
||||
badgeType() {
|
||||
return 'entity-' + this.type + ' badge-' + this.type;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
canCloseModal: {
|
||||
handler: function(val, oldVal) {
|
||||
if (val) {
|
||||
this.closeModal();
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
getReturnPath() {
|
||||
return `?returnPath=${window.location.pathname}${window.location.search}${window.location.hash}`;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
closeModal() {
|
||||
@@ -217,9 +210,9 @@ export default {
|
||||
buildLocation(id, type) {
|
||||
if (type === 'person') {
|
||||
// TODO i18n
|
||||
return `/fr/person/${id}/general`;
|
||||
return encodeURI(`/fr/person/${id}/general${this.getReturnPath}`);
|
||||
} else if (type === 'thirdparty') {
|
||||
return `/fr/3party/3party/${id}/view`;
|
||||
return encodeURI(`/fr/3party/3party/${id}/view${this.getReturnPath}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,7 @@
|
||||
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n';
|
||||
import { thirdpartyMessages } from 'ChillThirdPartyAssets/vuejs/_js/i18n';
|
||||
import { addressMessages } from 'ChillMainAssets/vuejs/Address/i18n';
|
||||
import { ontheflyMessages } from 'ChillMainAssets/vuejs/OnTheFly/i18n';
|
||||
|
||||
const appMessages = {
|
||||
fr: {
|
||||
@@ -12,6 +15,6 @@ const appMessages = {
|
||||
}
|
||||
}
|
||||
|
||||
Object.assign(appMessages.fr, personMessages.fr);
|
||||
Object.assign(appMessages.fr, personMessages.fr, thirdpartyMessages.fr, addressMessages.fr, ontheflyMessages.fr );
|
||||
|
||||
export { appMessages };
|
||||
|
@@ -42,57 +42,11 @@
|
||||
class="street">
|
||||
{{ address.text }}
|
||||
</p>
|
||||
<p v-if="address.postcode"
|
||||
class="postcode">
|
||||
{{ address.postcode.code }} {{ address.postcode.name }}
|
||||
</p>
|
||||
<p v-if="address.country"
|
||||
class="country">
|
||||
{{ address.country.name.fr }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</component>
|
||||
|
||||
<!-- <div v-if="isMultiline === true" class="address-more">
|
||||
<div v-if="address.floor">
|
||||
<span class="floor">
|
||||
<b>{{ $t('floor') }}</b>: {{ address.floor }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.corridor">
|
||||
<span class="corridor">
|
||||
<b>{{ $t('corridor') }}</b>: {{ address.corridor }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.steps">
|
||||
<span class="steps">
|
||||
<b>{{ $t('steps') }}</b>: {{ address.steps }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.flat">
|
||||
<span class="flat">
|
||||
<b>{{ $t('flat') }}</b>: {{ address.flat }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.buildingName">
|
||||
<span class="buildingName">
|
||||
<b>{{ $t('buildingName') }}</b>: {{ address.buildingName }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.extra">
|
||||
<span class="extra">
|
||||
<b>{{ $t('extra') }}</b>: {{ address.extra }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="address.distribution">
|
||||
<span class="distribution">
|
||||
<b>{{ $t('distribution') }}</b>: {{ address.distribution }}
|
||||
</span>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div v-if="useDatePane === true" class="address-more">
|
||||
<div v-if="address.validFrom">
|
||||
<span class="validFrom">
|
||||
|
@@ -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>
|
||||
|
@@ -64,7 +64,7 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
|
||||
if ($address instanceof Address) {
|
||||
$data = [
|
||||
'address_id' => $address->getId(),
|
||||
'text' => $address->isNoAddress() ? null : $this->addressRender->renderStreetLine($address, []),
|
||||
'text' => $this->addressRender->renderString($address, []),
|
||||
'street' => $address->getStreet(),
|
||||
'streetNumber' => $address->getStreetNumber(),
|
||||
'postcode' => [
|
||||
|
@@ -124,7 +124,7 @@ class AddressRender implements ChillEntityRenderInterface
|
||||
*/
|
||||
public function renderString($addr, array $options): string
|
||||
{
|
||||
return implode(' - ', $this->renderLines($addr));
|
||||
return implode(' — ', $this->renderLines($addr));
|
||||
}
|
||||
|
||||
public function supports($entity, array $options): bool
|
||||
|
@@ -24,30 +24,30 @@ final class EntityWorkflowTest extends TestCase
|
||||
{
|
||||
$entityWorkflow = new EntityWorkflow();
|
||||
|
||||
$entityWorkflow->getCurrentStep()->setFinalizeAfter(true);
|
||||
$entityWorkflow->setStep('final');
|
||||
$entityWorkflow->getCurrentStep()->setIsFinal(true);
|
||||
|
||||
$this->assertTrue($entityWorkflow->isFinalize());
|
||||
$this->assertTrue($entityWorkflow->isFinal());
|
||||
}
|
||||
|
||||
public function testIsFinalizeWith4Steps()
|
||||
{
|
||||
$entityWorkflow = new EntityWorkflow();
|
||||
|
||||
$this->assertFalse($entityWorkflow->isFinalize());
|
||||
$this->assertFalse($entityWorkflow->isFinal());
|
||||
|
||||
$entityWorkflow->setStep('two');
|
||||
|
||||
$this->assertFalse($entityWorkflow->isFinalize());
|
||||
$this->assertFalse($entityWorkflow->isFinal());
|
||||
|
||||
$entityWorkflow->setStep('previous_final');
|
||||
|
||||
$this->assertFalse($entityWorkflow->isFinalize());
|
||||
$this->assertFalse($entityWorkflow->isFinal());
|
||||
|
||||
$entityWorkflow->getCurrentStep()->setFinalizeAfter(true);
|
||||
$entityWorkflow->getCurrentStep()->setIsFinal(true);
|
||||
$entityWorkflow->setStep('final');
|
||||
|
||||
$this->assertTrue($entityWorkflow->isFinalize());
|
||||
$this->assertTrue($entityWorkflow->isFinal());
|
||||
}
|
||||
|
||||
public function testIsFreeze()
|
||||
@@ -64,11 +64,8 @@ final class EntityWorkflowTest extends TestCase
|
||||
|
||||
$this->assertFalse($entityWorkflow->isFreeze());
|
||||
|
||||
$entityWorkflow->getCurrentStep()->setFreezeAfter(true);
|
||||
|
||||
$this->assertFalse($entityWorkflow->isFreeze());
|
||||
|
||||
$entityWorkflow->setStep('freezed');
|
||||
$entityWorkflow->getCurrentStep()->setFreezeAfter(true);
|
||||
|
||||
$this->assertTrue($entityWorkflow->isFreeze());
|
||||
|
||||
|
@@ -48,7 +48,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
|
||||
$addr->setBuildingName('Résidence "Les Bleuets"');
|
||||
|
||||
yield [$addr, 'Résidence "Les Bleuets" - Rue ABC, 5 - 012345 Locality - Belgium'];
|
||||
yield [$addr, 'Résidence "Les Bleuets" — Rue ABC, 5 — 012345 Locality — Belgium'];
|
||||
}
|
||||
|
||||
public function addressDataProviderBEWithSteps(): Iterator
|
||||
@@ -68,7 +68,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
|
||||
$addr->setSteps('4');
|
||||
|
||||
yield [$addr, 'esc 4 - Rue ABC, 5 - 012345 Locality - Belgium'];
|
||||
yield [$addr, 'esc 4 — Rue ABC, 5 — 012345 Locality — Belgium'];
|
||||
}
|
||||
|
||||
public function addressDataProviderFRWithBuilding(): Iterator
|
||||
@@ -88,7 +88,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
|
||||
$addr->setBuildingName('Résidence "Les Bleuets"');
|
||||
|
||||
yield [$addr, 'Résidence "Les Bleuets" - 5, Rue ABC - 012345 Locality - France'];
|
||||
yield [$addr, 'Résidence "Les Bleuets" — 5, Rue ABC — 012345 Locality — France'];
|
||||
}
|
||||
|
||||
public function addressDataProviderFRWithSteps(): Iterator
|
||||
@@ -108,7 +108,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
|
||||
$addr->setSteps('4');
|
||||
|
||||
yield [$addr, 'esc 4 - 5, Rue ABC - 012345 Locality - France'];
|
||||
yield [$addr, 'esc 4 — 5, Rue ABC — 012345 Locality — France'];
|
||||
}
|
||||
|
||||
public function complexAddressDataProviderBE(): Iterator
|
||||
@@ -132,7 +132,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
$addr->setCorridor('3');
|
||||
$addr->setSteps('4');
|
||||
|
||||
yield [$addr, 'Résidence "Les Bleuets" - appart 1 - ét 2 - coul 3 - esc 4 - Rue ABC, 5 - 012345 Locality - Belgium'];
|
||||
yield [$addr, 'Résidence "Les Bleuets" - appart 1 - ét 2 - coul 3 - esc 4 — Rue ABC, 5 — 012345 Locality — Belgium'];
|
||||
}
|
||||
|
||||
public function complexAddressDataProviderFR(): Iterator
|
||||
@@ -158,7 +158,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
$addr->setExtra('A droite de la porte');
|
||||
$addr->setDistribution('CEDEX');
|
||||
|
||||
yield [$addr, 'appart 1 - ét 2 - coul 3 - esc 4 - Résidence "Les Bleuets" - 5, Rue ABC - A droite de la porte - 012345 Locality CEDEX - France'];
|
||||
yield [$addr, 'appart 1 - ét 2 - coul 3 - esc 4 — Résidence "Les Bleuets" — 5, Rue ABC — A droite de la porte — 012345 Locality CEDEX — France'];
|
||||
}
|
||||
|
||||
public function noFullAddressDataProviderBE(): Iterator
|
||||
@@ -175,7 +175,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
$addr->setPostcode($postCode)
|
||||
->setIsNoAddress(true);
|
||||
|
||||
yield [$addr, '012345 Locality - Belgium'];
|
||||
yield [$addr, '012345 Locality — Belgium'];
|
||||
}
|
||||
|
||||
public function simpleAddressDataProviderBE(): Iterator
|
||||
@@ -193,7 +193,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
->setStreetNumber('5')
|
||||
->setPostcode($postCode);
|
||||
|
||||
yield [$addr, 'Rue ABC, 5 - 012345 Locality - Belgium'];
|
||||
yield [$addr, 'Rue ABC, 5 — 012345 Locality — Belgium'];
|
||||
}
|
||||
|
||||
public function simpleAddressDataProviderFR(): Iterator
|
||||
@@ -211,7 +211,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
->setStreetNumber('5')
|
||||
->setPostcode($postCode);
|
||||
|
||||
yield [$addr, '5, Rue ABC - 012345 Locality - France'];
|
||||
yield [$addr, '5, Rue ABC — 012345 Locality — France'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -16,36 +16,36 @@ 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;
|
||||
$this->cacheItemPool = $cacheItemPool;
|
||||
}
|
||||
|
||||
public function addNotification(UserInterface $user): int
|
||||
public function addNotification(UserInterface $u): int
|
||||
{
|
||||
if (!$user instanceof User) {
|
||||
if (!$u instanceof User) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$key = self::generateCacheKeyWorkflowByUser($user);
|
||||
$key = self::generateCacheKeyWorkflowByUser($u);
|
||||
$item = $this->cacheItemPool->getItem($key);
|
||||
|
||||
if ($item->isHit()) {
|
||||
return $item->get();
|
||||
}
|
||||
|
||||
$nb = $this->getCountUnreadByUser($user);
|
||||
$nb = $this->getCountUnreadByUser($u);
|
||||
|
||||
$item->set($nb)
|
||||
->expiresAfter(60 * 15);
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -72,17 +72,18 @@ class MetadataExtractor
|
||||
|
||||
foreach ($transitions as $transition) {
|
||||
if ($transition->getName() === $transitionName) {
|
||||
break;
|
||||
$metadata = $workflow->getMetadataStore()->getTransitionMetadata($transition);
|
||||
|
||||
return [
|
||||
'name' => $transition->getName(),
|
||||
'text' => array_key_exists('label', $metadata) ?
|
||||
$this->translatableStringHelper->localize($metadata['label']) : $transition->getName(),
|
||||
'isForward' => $metadata['isForward'] ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
$metadata = $workflow->getMetadataStore()->getTransitionMetadata($transition);
|
||||
|
||||
return [
|
||||
'name' => $transition->getName(),
|
||||
'text' => array_key_exists('label', $metadata) ?
|
||||
$this->translatableStringHelper->localize($metadata['label']) : $transition->getName(),
|
||||
'isForward' => $metadata['isForward'] ?? null,
|
||||
];
|
||||
return [];
|
||||
}
|
||||
|
||||
public function buildArrayPresentationForWorkflow(WorkflowInterface $workflow): array
|
||||
|
@@ -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