Merge branch 'issue569_display_time' into 'master'

Display time for evaluation documents

See merge request Chill-Projet/chill-bundles!421
This commit is contained in:
Julien Fastré 2022-04-29 14:56:37 +00:00
commit df4abd6661
5 changed files with 61 additions and 90 deletions

View File

@ -49,6 +49,7 @@ and this project adheres to
* [list with period] use "sameas" test operator to introduce requestor in list * [list with period] use "sameas" test operator to introduce requestor in list
* [notification email on course designation] allow raw string in email content generation * [notification email on course designation] allow raw string in email content generation
* [Accompanying period work] list evaluations associated to a work by startDate, and then by id, from the most recent to older * [Accompanying period work] list evaluations associated to a work by startDate, and then by id, from the most recent to older
* [evaluation_document] changing date to datetime in order to display the time at which document was created (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/569)
### 2021-04-13 ### 2021-04-13

View File

@ -16,17 +16,20 @@ use DateTime;
use DateTimeImmutable; use DateTimeImmutable;
use DateTimeInterface; use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
trait TrackCreationTrait trait TrackCreationTrait
{ {
/** /**
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": NULL}) * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": NULL})
* @Serializer\Groups({"read"})
*/ */
private ?DateTimeImmutable $createdAt = null; private ?DateTimeImmutable $createdAt = null;
/** /**
* @ORM\ManyToOne(targetEntity=User::class) * @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=true) * @ORM\JoinColumn(nullable=true)
* @Serializer\Groups({"read"})
*/ */
private ?User $createdBy = null; private ?User $createdBy = null;

View File

@ -16,17 +16,20 @@ use DateTime;
use DateTimeImmutable; use DateTimeImmutable;
use DateTimeInterface; use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
trait TrackUpdateTrait trait TrackUpdateTrait
{ {
/** /**
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": NULL}) * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": NULL})
* @Serializer\Groups({"read"})
*/ */
private ?DateTimeImmutable $updatedAt = null; private ?DateTimeImmutable $updatedAt = null;
/** /**
* @ORM\ManyToOne(targetEntity=User::class) * @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=true) * @ORM\JoinColumn(nullable=true)
* @Serializer\Groups({"read"})
*/ */
private ?User $updatedBy = null; private ?User $updatedBy = null;

View File

@ -13,10 +13,8 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface; use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Chill\MainBundle\Entity\User;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use RuntimeException; use RuntimeException;
use Symfony\Component\Serializer\Annotation as Serializer; use Symfony\Component\Serializer\Annotation as Serializer;
@ -31,6 +29,10 @@ use Symfony\Component\Validator\Constraints as Assert;
*/ */
class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doctrine\Model\TrackCreationInterface, \Chill\MainBundle\Doctrine\Model\TrackUpdateInterface class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doctrine\Model\TrackCreationInterface, \Chill\MainBundle\Doctrine\Model\TrackUpdateInterface
{ {
use TrackCreationTrait;
use TrackUpdateTrait;
/** /**
* @ORM\ManyToOne( * @ORM\ManyToOne(
* targetEntity=AccompanyingPeriodWorkEvaluation::class, * targetEntity=AccompanyingPeriodWorkEvaluation::class,
@ -39,22 +41,6 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
*/ */
private ?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation = null; private ?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation = null;
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?\DateTimeImmutable $createdAt = null;
/**
* @ORM\ManyToOne(
* targetEntity=User::class
* )
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?User $createdBy = null;
/** /**
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue * @ORM\GeneratedValue
@ -110,40 +96,11 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
*/ */
private ?string $title = ''; private ?string $title = '';
/**
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?\DateTimeImmutable $updatedAt = null;
/**
* @ORM\ManyToOne(
* targetEntity=User::class
* )
* @Serializer\Groups({"read"})
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
*/
private ?User $updatedBy = null;
public function getAccompanyingPeriodWorkEvaluation(): ?AccompanyingPeriodWorkEvaluation public function getAccompanyingPeriodWorkEvaluation(): ?AccompanyingPeriodWorkEvaluation
{ {
return $this->accompanyingPeriodWorkEvaluation; return $this->accompanyingPeriodWorkEvaluation;
} }
/**
* @return \DateTimeImmutable|null
*/
public function getCreatedAt(): ?DateTimeInterface
{
return $this->createdAt;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;
}
public function getId(): ?int public function getId(): ?int
{ {
return $this->id; return $this->id;
@ -172,19 +129,6 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
return $this->title; return $this->title;
} }
/**
* @return DateTimeImmutable|null
*/
public function getUpdatedAt(): ?DateTimeInterface
{
return $this->updatedAt;
}
public function getUpdatedBy(): ?User
{
return $this->updatedBy;
}
public function setAccompanyingPeriodWorkEvaluation(?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation): AccompanyingPeriodWorkEvaluationDocument public function setAccompanyingPeriodWorkEvaluation(?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation): AccompanyingPeriodWorkEvaluationDocument
{ {
// if an evaluation is already associated, we cannot change the association (removing the association, // if an evaluation is already associated, we cannot change the association (removing the association,
@ -202,20 +146,6 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
return $this; return $this;
} }
public function setCreatedAt(DateTimeInterface $datetime): TrackCreationInterface
{
$this->createdAt = $datetime;
return $this;
}
public function setCreatedBy(User $user): TrackCreationInterface
{
$this->createdBy = $user;
return $this;
}
/** /**
* @param mixed $key * @param mixed $key
* *
@ -248,18 +178,4 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct
return $this; return $this;
} }
public function setUpdatedAt(DateTimeInterface $datetime): TrackUpdateInterface
{
$this->updatedAt = $datetime;
return $this;
}
public function setUpdatedBy(User $user): TrackUpdateInterface
{
$this->updatedBy = $user;
return $this;
}
} }

View File

@ -0,0 +1,48 @@
<?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\Person;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220427150431 extends AbstractMigration
{
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER createdAt TYPE DATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER createdAt DROP DEFAULT');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER updatedAt TYPE DATE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER updatedAt DROP DEFAULT');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.createdat IS \'(DC2Type:date_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.updatedat IS \'(DC2Type:date_immutable)\'');
}
public function getDescription(): string
{
return 'change date to datetime for evaluation documents';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER createdat TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER createdat DROP DEFAULT');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER updatedat TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
$this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER updatedat DROP DEFAULT');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.createdAt IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.updatedAt IS \'(DC2Type:datetime_immutable)\'');
}
}