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
21bc472886
11
CHANGELOG.md
11
CHANGELOG.md
@ -11,6 +11,15 @@ and this project adheres to
|
||||
## Unreleased
|
||||
|
||||
<!-- write down unreleased development here -->
|
||||
|
||||
## Test releases
|
||||
|
||||
### 2022-05-30
|
||||
|
||||
* fix creating a new AccompanyingPeriodWorkEvaluationDocument when replacing the document (the workflow was lost)
|
||||
|
||||
### 2022-05-27
|
||||
|
||||
* [storedobject] add title field on StoredObject entity + use it in activity documents (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/604)
|
||||
* [main] add a "read more..." on comment embeddable when overflown (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/604)
|
||||
* [person] add closing motive to closed acc course (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/603)
|
||||
@ -28,8 +37,6 @@ and this project adheres to
|
||||
* [address] can add extra address info even if noAddress (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/576)
|
||||
|
||||
|
||||
## Test releases
|
||||
|
||||
### 2022-05-06
|
||||
|
||||
* [person] add civility when creating a person (with the on-the-fly component or in the php form) (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/557)
|
||||
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Calendar;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20220527234046 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar ALTER COLUMN privateComment_comments DROP NOT NULL');
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar ALTER COLUMN privateComment_comments SET DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('UPDATE chill_calendar.calendar SET privateComment_comments=\'{}\' WHERE privateComment_comments IS NULL');
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar ALTER COLUMN privateComment_comments SET NOT NULL');
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar ALTER COLUMN privateComment_comments SET DEFAULT \'{}\'');
|
||||
}
|
||||
}
|
@ -54,9 +54,9 @@ class PrivateCommentEmbeddable
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCommentForUser(User $user, string $content): self
|
||||
public function setCommentForUser(User $user, ?string $content): self
|
||||
{
|
||||
$this->comments[$user->getId()] = trim($content);
|
||||
$this->comments[$user->getId()] = trim((string) $content);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -692,6 +692,10 @@ class AccompanyingPeriod implements
|
||||
return [[self::STEP_DRAFT, self::STEP_CONFIRMED]];
|
||||
}
|
||||
|
||||
if ($this->getStep() === self::STEP_CLOSED) {
|
||||
return [[self::STEP_DRAFT, self::STEP_CONFIRMED, self::STEP_CLOSED]];
|
||||
}
|
||||
|
||||
throw new LogicException('no validation group permitted with this step: ' . $this->getStep());
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
@ -31,20 +30,20 @@ class Origin
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
* @Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
* @Serializer\Context({"is-translatable": true}, groups={"docgen:read"})
|
||||
*/
|
||||
private array $label = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date_immutable", nullable=true)
|
||||
* @Groups({"read"})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?DateTimeImmutable $noActiveAfter = null;
|
||||
|
||||
|
@ -232,6 +232,14 @@ const store = createStore({
|
||||
return;
|
||||
}
|
||||
|
||||
let doc = evaluation.documents.find(d => d.key === payload.oldDocument.key);
|
||||
|
||||
if (typeof doc === 'undefined') {
|
||||
console.error('doc not found');
|
||||
}
|
||||
|
||||
doc.storedObject = payload.document.storedObject;
|
||||
return;
|
||||
let newDocument = Object.assign(
|
||||
payload.document, {
|
||||
key: evaluation.documents.length + 1,
|
||||
|
@ -121,6 +121,7 @@ class AccompanyingPeriodDocGenNormalizer implements ContextAwareNormalizerInterf
|
||||
'type' => 'accompanying_period',
|
||||
'isNull' => false,
|
||||
'closingDate' => $this->normalizer->normalize($period->getClosingDate(), $format, $dateContext),
|
||||
'closingMotive' => $this->normalizer->normalize($period->getClosingMotive(), $format, array_merge($context, ['docgen:expects' => AccompanyingPeriod\ClosingMotive::class])),
|
||||
'confidential' => $period->isConfidential(),
|
||||
'createdAt' => $this->normalizer->normalize($period->getCreatedAt(), $format, $dateContext),
|
||||
'createdBy' => $this->normalizer->normalize($period->getCreatedBy(), $format, $userContext),
|
||||
|
@ -35,6 +35,6 @@ final class AccompanyingPeriodOriginNormalizer implements NormalizerInterface
|
||||
|
||||
public function supportsNormalization($data, $format = null): bool
|
||||
{
|
||||
return $data instanceof Origin;
|
||||
return $data instanceof Origin && 'json' === $format;
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,6 @@ namespace Chill\PersonBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
@ -35,18 +33,6 @@ class AccompanyingPeriodWorkEvaluationDenormalizer implements ContextAwareDenorm
|
||||
|
||||
use ObjectToPopulateTrait;
|
||||
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
private AccompanyingPeriodWorkRepository $workRepository;
|
||||
|
||||
public function __construct(
|
||||
AccompanyingPeriodWorkRepository $workRepository,
|
||||
EntityManagerInterface $em
|
||||
) {
|
||||
$this->workRepository = $workRepository;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function denormalize($data, $type, $format = null, array $context = [])
|
||||
{
|
||||
$evaluation = $this->denormalizer->denormalize($data, $type, $format, array_merge(
|
||||
|
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Serializer\Normalizer;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
|
||||
use Chill\PersonBundle\Serializer\Normalizer\AccompanyingPeriodWorkEvaluationDenormalizer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionProperty;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AccompanyingPeriodWorkEvaluationDenormalizerTest extends TestCase
|
||||
{
|
||||
private const ENCODED_DATA = ' {
|
||||
"type": "accompanying_period_work_evaluation",
|
||||
"key": 0,
|
||||
"evaluation": {
|
||||
"id": 100,
|
||||
"type": "social_work_evaluation"
|
||||
},
|
||||
"startDate": {
|
||||
"datetime": "2022-04-29T00:00:00+02:00"
|
||||
},
|
||||
"endDate": null,
|
||||
"maxDate": null,
|
||||
"warningInterval": "P0D",
|
||||
"comment": "",
|
||||
"documents": [
|
||||
{
|
||||
"type": "accompanying_period_work_evaluation_document",
|
||||
"id": 1,
|
||||
"storedObject": {
|
||||
"creationDate": {
|
||||
"datetime": "2022-05-30T21:22:47+0200"
|
||||
},
|
||||
"datas": [],
|
||||
"filename": "ZeoWSjqVc2qN1XUHptTV6S",
|
||||
"id": 11,
|
||||
"iv": [
|
||||
89,
|
||||
164,
|
||||
162,
|
||||
48,
|
||||
155,
|
||||
159,
|
||||
69,
|
||||
135,
|
||||
191,
|
||||
241,
|
||||
241,
|
||||
8,
|
||||
17,
|
||||
56,
|
||||
183,
|
||||
224
|
||||
],
|
||||
"keyInfos": {
|
||||
"alg": "A256CBC",
|
||||
"ext": true,
|
||||
"k": "uW4d7si_hi--VQHxi76ZllKQiYzaEJYGN8KBrWXxi7s",
|
||||
"key_ops": [
|
||||
"encrypt",
|
||||
"decrypt"
|
||||
],
|
||||
"kty": "oct"
|
||||
},
|
||||
"title": "",
|
||||
"type": "application/vnd.oasis.opendocument.text",
|
||||
"uuid": "b9dd9eff-a7cf-4a29-89e3-57efc9ed215b"
|
||||
},
|
||||
"title": "test",
|
||||
"key": 2,
|
||||
"workflows_availables": [
|
||||
{
|
||||
"name": "vendee_internal",
|
||||
"text": "Suivi CD85"
|
||||
}
|
||||
],
|
||||
"workflows": []
|
||||
}
|
||||
],
|
||||
"id": 382
|
||||
}';
|
||||
|
||||
public function testAssociatedDocumentIsTheSame()
|
||||
{
|
||||
$this->markTestIncomplete('not yet finished');
|
||||
$evaluation = new AccompanyingPeriodWorkEvaluation();
|
||||
$doc = new AccompanyingPeriodWorkEvaluationDocument();
|
||||
$doc->setStoredObject($storedObject = new StoredObject());
|
||||
$reflectionProperty = new ReflectionProperty(AccompanyingPeriodWorkEvaluationDocument::class, 'id');
|
||||
$reflectionProperty->setAccessible(true);
|
||||
$reflectionProperty->setValue($doc, 1);
|
||||
|
||||
$evaluation->addDocument($doc);
|
||||
|
||||
$data = json_decode(self::ENCODED_DATA);
|
||||
$context =
|
||||
[AbstractNormalizer::OBJECT_TO_POPULATE => $evaluation, 'groups' => ['write']];
|
||||
|
||||
$denormalizer = new AccompanyingPeriodWorkEvaluationDenormalizer();
|
||||
|
||||
/*
|
||||
$this->assertTrue(
|
||||
$denormalizer->supportsDenormalization(
|
||||
$data,
|
||||
AccompanyingPeriodWorkEvaluation::class,
|
||||
'json',
|
||||
$context
|
||||
)
|
||||
);
|
||||
*/
|
||||
|
||||
$denormalizedEvaluation = $denormalizer->denormalize(
|
||||
$data,
|
||||
AccompanyingPeriodWorkEvaluation::class,
|
||||
'json',
|
||||
$context
|
||||
);
|
||||
|
||||
$this->assertSame($evaluation, $denormalizedEvaluation);
|
||||
$this->assertCount(1, $evaluation->getDocuments());
|
||||
$this->assertSame($doc, $evaluation->getDocuments()->first());
|
||||
$this->assertNotSame($storedObject, $evaluation->getDocuments()->first()->getStoredObject());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user