mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'master' of gitlab.com:Chill-Projet/chill-bundles
This commit is contained in:
commit
16d5f121db
@ -18,6 +18,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
|
|
||||||
#[ORM\Entity]
|
#[ORM\Entity]
|
||||||
#[ORM\Table('chill_doc.accompanyingcourse_document')]
|
#[ORM\Table('chill_doc.accompanyingcourse_document')]
|
||||||
|
#[ORM\UniqueConstraint(name: 'acc_course_document_unique_stored_object', columns: ['object_id'])]
|
||||||
class AccompanyingCourseDocument extends Document implements HasScopesInterface, HasCentersInterface
|
class AccompanyingCourseDocument extends Document implements HasScopesInterface, HasCentersInterface
|
||||||
{
|
{
|
||||||
#[ORM\ManyToOne(targetEntity: AccompanyingPeriod::class)]
|
#[ORM\ManyToOne(targetEntity: AccompanyingPeriod::class)]
|
||||||
|
@ -40,6 +40,7 @@ class Document implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
#[Assert\Valid]
|
#[Assert\Valid]
|
||||||
#[Assert\NotNull(message: 'Upload a document')]
|
#[Assert\NotNull(message: 'Upload a document')]
|
||||||
#[ORM\ManyToOne(targetEntity: StoredObject::class, cascade: ['persist'])]
|
#[ORM\ManyToOne(targetEntity: StoredObject::class, cascade: ['persist'])]
|
||||||
|
#[ORM\JoinColumn(name: 'object_id', referencedColumnName: 'id')]
|
||||||
private ?StoredObject $object = null;
|
private ?StoredObject $object = null;
|
||||||
|
|
||||||
#[ORM\ManyToOne(targetEntity: DocGeneratorTemplate::class)]
|
#[ORM\ManyToOne(targetEntity: DocGeneratorTemplate::class)]
|
||||||
|
@ -19,6 +19,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
|
|
||||||
#[ORM\Entity]
|
#[ORM\Entity]
|
||||||
#[ORM\Table('chill_doc.person_document')]
|
#[ORM\Table('chill_doc.person_document')]
|
||||||
|
#[ORM\UniqueConstraint(name: 'person_document_unique_stored_object', columns: ['object_id'])]
|
||||||
class PersonDocument extends Document implements HasCenterInterface, HasScopeInterface
|
class PersonDocument extends Document implements HasCenterInterface, HasScopeInterface
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\Migrations\DocStore;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
final class Version20241118151618 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Force no duplicated object_id within person_document and accompanyingcourse_document';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
WITH ranked AS (
|
||||||
|
SELECT id, rank() OVER (PARTITION BY object_id ORDER BY id ASC) FROM chill_doc.accompanyingcourse_document
|
||||||
|
)
|
||||||
|
DELETE FROM chill_doc.accompanyingcourse_document WHERE id IN (SELECT id FROM ranked where "rank" <> 1)
|
||||||
|
SQL);
|
||||||
|
$this->addSql('CREATE UNIQUE INDEX acc_course_document_unique_stored_object ON chill_doc.accompanyingcourse_document (object_id)');
|
||||||
|
$this->addSql('CREATE UNIQUE INDEX person_document_unique_stored_object ON chill_doc.person_document (object_id)');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('DROP INDEX acc_course_document_unique_stored_object');
|
||||||
|
$this->addSql('DROP INDEX person_document_unique_stored_object');
|
||||||
|
}
|
||||||
|
}
|
@ -441,6 +441,8 @@ class EntityWorkflow implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
$newStep = new EntityWorkflowStep();
|
$newStep = new EntityWorkflowStep();
|
||||||
$newStep->setCurrentStep($step);
|
$newStep->setCurrentStep($step);
|
||||||
|
|
||||||
|
$newStep->setComment($transitionContextDTO->comment);
|
||||||
|
|
||||||
foreach ($transitionContextDTO->futureCcUsers as $user) {
|
foreach ($transitionContextDTO->futureCcUsers as $user) {
|
||||||
$newStep->addCcUser($user);
|
$newStep->addCcUser($user);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
<div class="mb-5">
|
<div class="mb-5">
|
||||||
<h2>{{ handler.entityTitle(entity_workflow) }}</h2>
|
<h2>{{ handler.entityTitle(entity_workflow) }}</h2>
|
||||||
|
|
||||||
{{ macro.breadcrumb({'entity_workflow': entity_workflow}) }}
|
{{ macro.breadcrumb(entity_workflow) }}
|
||||||
{% if entity_workflow.isOnHoldAtCurrentStep %}
|
{% if entity_workflow.isOnHoldAtCurrentStep %}
|
||||||
<span class="badge bg-success rounded-pill" title="{{ 'workflow.On hold'|trans|escape('html_attr') }}">{{ 'workflow.On hold'|trans }}</span>
|
<span class="badge bg-success rounded-pill" title="{{ 'workflow.On hold'|trans|escape('html_attr') }}">{{ 'workflow.On hold'|trans }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
|
|
||||||
</button>
|
</button>
|
||||||
<div>
|
<div>
|
||||||
{{ macro.breadcrumb(l) }}
|
{{ macro.breadcrumb(l.entity_workflow) }}
|
||||||
{% if l.entity_workflow.isOnHoldAtCurrentStep %}
|
{% if l.entity_workflow.isOnHoldAtCurrentStep %}
|
||||||
<span class="badge bg-success rounded-pill" title="{{ 'workflow.On hold'|trans|escape('html_attr') }}">{{ 'workflow.On hold'|trans }}</span>
|
<span class="badge bg-success rounded-pill" title="{{ 'workflow.On hold'|trans|escape('html_attr') }}">{{ 'workflow.On hold'|trans }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -52,10 +52,10 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro breadcrumb(_ctx) %}
|
{% macro breadcrumb(entity_workflow) %}
|
||||||
<div class="breadcrumb">
|
<div class="breadcrumb">
|
||||||
{% for step in _ctx.entity_workflow.stepsChained %}
|
{% for step in entity_workflow.stepsChained %}
|
||||||
{% set labels = workflow_metadata(_ctx.entity_workflow, 'label', step.currentStep, _ctx.entity_workflow.workflowName) %}
|
{% set labels = workflow_metadata(entity_workflow, 'label', step.currentStep, entity_workflow.workflowName) %}
|
||||||
{% set label = labels is null ? step.currentStep : labels|localize_translatable_string %}
|
{% set label = labels is null ? step.currentStep : labels|localize_translatable_string %}
|
||||||
{% set popTitle = _self.popoverTitle(step) %}
|
{% set popTitle = _self.popoverTitle(step) %}
|
||||||
{% set popContent = _self.popoverContent(step) %}
|
{% set popContent = _self.popoverContent(step) %}
|
||||||
|
@ -74,12 +74,14 @@ class DateNormalizer implements ContextAwareNormalizerInterface, DenormalizerInt
|
|||||||
$formatterLong = \IntlDateFormatter::create(
|
$formatterLong = \IntlDateFormatter::create(
|
||||||
$locale,
|
$locale,
|
||||||
\IntlDateFormatter::LONG,
|
\IntlDateFormatter::LONG,
|
||||||
$hasTime ? \IntlDateFormatter::SHORT : \IntlDateFormatter::NONE
|
$hasTime ? \IntlDateFormatter::SHORT : \IntlDateFormatter::NONE,
|
||||||
|
$date->getTimezone(),
|
||||||
);
|
);
|
||||||
$formatterShort = \IntlDateFormatter::create(
|
$formatterShort = \IntlDateFormatter::create(
|
||||||
$locale,
|
$locale,
|
||||||
\IntlDateFormatter::SHORT,
|
\IntlDateFormatter::SHORT,
|
||||||
$hasTime ? \IntlDateFormatter::SHORT : \IntlDateFormatter::NONE
|
$hasTime ? \IntlDateFormatter::SHORT : \IntlDateFormatter::NONE,
|
||||||
|
$date->getTimezone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -16,6 +16,8 @@ use Chill\MainBundle\Entity\User;
|
|||||||
use Chill\MainBundle\Entity\UserGroup;
|
use Chill\MainBundle\Entity\UserGroup;
|
||||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStep;
|
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStep;
|
||||||
|
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
|
||||||
|
use Chill\MainBundle\Workflow\EntityWorkflowManager;
|
||||||
use Chill\MainBundle\Workflow\EventSubscriber\NotificationOnTransition;
|
use Chill\MainBundle\Workflow\EventSubscriber\NotificationOnTransition;
|
||||||
use Chill\MainBundle\Workflow\Helper\MetadataExtractor;
|
use Chill\MainBundle\Workflow\Helper\MetadataExtractor;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
@ -91,12 +93,18 @@ final class NotificationOnTransitionTest extends TestCase
|
|||||||
$security = $this->prophesize(Security::class);
|
$security = $this->prophesize(Security::class);
|
||||||
$security->getUser()->willReturn($currentUser);
|
$security->getUser()->willReturn($currentUser);
|
||||||
|
|
||||||
|
$entityWorkflowHandler = $this->prophesize(EntityWorkflowHandlerInterface::class);
|
||||||
|
$entityWorkflowHandler->getEntityTitle($entityWorkflow)->willReturn('workflow title');
|
||||||
|
$entityWorkflowManager = $this->prophesize(EntityWorkflowManager::class);
|
||||||
|
$entityWorkflowManager->getHandler($entityWorkflow)->willReturn($entityWorkflowHandler->reveal());
|
||||||
|
|
||||||
$notificationOnTransition = new NotificationOnTransition(
|
$notificationOnTransition = new NotificationOnTransition(
|
||||||
$em->reveal(),
|
$em->reveal(),
|
||||||
$engine->reveal(),
|
$engine->reveal(),
|
||||||
$extractor->reveal(),
|
$extractor->reveal(),
|
||||||
$security->reveal(),
|
$security->reveal(),
|
||||||
$registry->reveal()
|
$registry->reveal(),
|
||||||
|
$entityWorkflowManager->reveal(),
|
||||||
);
|
);
|
||||||
|
|
||||||
$event = new Event($entityWorkflow, new Marking(), new Transition('dummy_transition', ['from_state'], ['to_state']), $workflow);
|
$event = new Event($entityWorkflow, new Marking(), new Transition('dummy_transition', ['from_state'], ['to_state']), $workflow);
|
||||||
|
@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\Notification;
|
|||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Entity\UserGroup;
|
use Chill\MainBundle\Entity\UserGroup;
|
||||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||||
|
use Chill\MainBundle\Workflow\EntityWorkflowManager;
|
||||||
use Chill\MainBundle\Workflow\Helper\MetadataExtractor;
|
use Chill\MainBundle\Workflow\Helper\MetadataExtractor;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
@ -30,6 +31,7 @@ class NotificationOnTransition implements EventSubscriberInterface
|
|||||||
private readonly MetadataExtractor $metadataExtractor,
|
private readonly MetadataExtractor $metadataExtractor,
|
||||||
private readonly Security $security,
|
private readonly Security $security,
|
||||||
private readonly Registry $registry,
|
private readonly Registry $registry,
|
||||||
|
private EntityWorkflowManager $entityWorkflowManager,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public static function getSubscribedEvents(): array
|
public static function getSubscribedEvents(): array
|
||||||
@ -62,6 +64,8 @@ class NotificationOnTransition implements EventSubscriberInterface
|
|||||||
/** @var array<string, User> $dests array of unique values, where keys is the object's hash */
|
/** @var array<string, User> $dests array of unique values, where keys is the object's hash */
|
||||||
$dests = [];
|
$dests = [];
|
||||||
|
|
||||||
|
$title = $this->entityWorkflowManager->getHandler($entityWorkflow)->getEntityTitle($entityWorkflow);
|
||||||
|
|
||||||
foreach (array_merge(
|
foreach (array_merge(
|
||||||
// the subscriber to each step
|
// the subscriber to each step
|
||||||
$entityWorkflow->getSubscriberToStep()->toArray(),
|
$entityWorkflow->getSubscriberToStep()->toArray(),
|
||||||
@ -112,6 +116,7 @@ class NotificationOnTransition implements EventSubscriberInterface
|
|||||||
static fn (User $u) => $u->getId(),
|
static fn (User $u) => $u->getId(),
|
||||||
$entityWorkflow->getCurrentStep()->getDestUser()->toArray()
|
$entityWorkflow->getCurrentStep()->getDestUser()->toArray()
|
||||||
), true),
|
), true),
|
||||||
|
'title' => $title,
|
||||||
];
|
];
|
||||||
|
|
||||||
$notification = new Notification();
|
$notification = new Notification();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user