Skip to content

Commit

Permalink
Renomme la colonne "description" en "title" (#1087)
Browse files Browse the repository at this point in the history
* change form title

* points 10 & 11

* sup point 5

* change description en untitled

* change entitled en title

* Update tests/Integration/Infrastructure/Controller/Regulation/Fragments/GetRegulationGeneralInfoControllerTest.php

Co-authored-by: Mathieu MARCHOIS <[email protected]>

---------

Co-authored-by: Mathieu MARCHOIS <[email protected]>
  • Loading branch information
Lealefoulon and mmarchois authored Nov 26, 2024
1 parent f2cc008 commit 3eb3382
Show file tree
Hide file tree
Showing 39 changed files with 131 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<option name="max">100</option>
</constraint>
</property>
<property name="description">
<property name="title">
<constraint name="NotBlank" />
<constraint name="Length">
<option name="max">255</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private function duplicateRegulationOrderRecord(
$generalInfo->otherCategoryText = $originalRegulationOrder->getOtherCategoryText();
$generalInfo->organization = $organization;
$generalInfo->identifier = $identifier;
$generalInfo->description = $originalRegulationOrder->getDescription();
$generalInfo->title = $originalRegulationOrder->getTitle();
$generalInfo->additionalVisas = $originalRegulationOrder->getAdditionalVisas();
$generalInfo->additionalReasons = $originalRegulationOrder->getAdditionalReasons();
$generalInfo->visaModelUuid = $originalRegulationOrder->getVisaModel()?->getUuid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class SaveRegulationGeneralInfoCommand implements CommandInterface
public string $source = RegulationOrderRecordSourceEnum::DIALOG->value;
public ?string $category;
public ?string $otherCategoryText = null;
public ?string $description;
public ?string $title;
public ?Organization $organization;
public array $additionalVisas = [];
public array $additionalReasons = [];
Expand All @@ -38,7 +38,7 @@ public static function create(
$command->source = $regulationOrderRecord?->getSource() ?? RegulationOrderRecordSourceEnum::DIALOG->value;
$command->category = $regulationOrder?->getCategory();
$command->otherCategoryText = $regulationOrder?->getOtherCategoryText();
$command->description = $regulationOrder?->getDescription();
$command->title = $regulationOrder?->getTitle();
$command->additionalVisas = $regulationOrder?->getAdditionalVisas() ?? [];
$command->additionalReasons = $regulationOrder?->getAdditionalReasons() ?? [];
$command->visaModelUuid = $regulationOrder?->getVisaModel()?->getUuid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __invoke(SaveRegulationGeneralInfoCommand $command): RegulationO
uuid: $this->idFactory->make(),
identifier: $command->identifier,
category: $command->category,
description: $command->description,
title: $command->title,
otherCategoryText: $command->otherCategoryText,
additionalVisas: $command->additionalVisas,
additionalReasons: $command->additionalReasons,
Expand All @@ -64,7 +64,7 @@ public function __invoke(SaveRegulationGeneralInfoCommand $command): RegulationO
$command->regulationOrderRecord->getRegulationOrder()->update(
identifier: $command->identifier,
category: $command->category,
description: $command->description,
title: $command->title,
otherCategoryText: $command->otherCategoryText,
additionalVisas: $command->additionalVisas,
additionalReasons: $command->additionalReasons,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __invoke(GetGeneralInfoQuery $query): GeneralInfoView
regulationOrderUuid: $row['regulationOrderUuid'],
category: $row['category'],
otherCategoryText: $row['otherCategoryText'],
description: $row['description'],
title: $row['title'],
startDate: $row['overallStartDate'] ? new \DateTimeImmutable($row['overallStartDate']) : null,
endDate: $row['overallEndDate'] ? new \DateTimeImmutable($row['overallEndDate']) : null,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function __invoke(GetRegulationOrdersToDatexFormatQuery $query): array
regulationId: $regulationOrder->getIdentifier() . '#' . $regulationOrderRecord->getOrganizationUuid(),
organization: $regulationOrderRecord->getOrganizationName(),
source: $regulationOrderRecord->getSource(),
description: $regulationOrder->getDescription(),
title: $regulationOrder->getTitle(),
startDate: $overallDates[$uuid]['overallStartDate'],
endDate: $overallDates[$uuid]['overallEndDate'],
trafficRegulations: $trafficRegulations,
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Regulation/View/GeneralInfoView.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(
public readonly string $regulationOrderUuid,
public readonly string $category,
public readonly ?string $otherCategoryText,
public readonly string $description,
public readonly string $title,
public readonly ?\DateTimeInterface $startDate,
public readonly ?\DateTimeInterface $endDate,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function __construct(
public string $regulationId,
public string $organization,
public string $source,
public string $description,
public string $title,
public ?\DateTimeInterface $startDate,
public ?\DateTimeInterface $endDate,
public array $trafficRegulations,
Expand Down
10 changes: 5 additions & 5 deletions src/Domain/Regulation/RegulationOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(
private string $uuid,
private string $identifier,
private string $category,
private string $description,
private string $title,
private ?string $otherCategoryText = null,
private ?VisaModel $visaModel = null,
private ?array $additionalVisas = [],
Expand Down Expand Up @@ -47,9 +47,9 @@ public function getOtherCategoryText(): ?string
return $this->otherCategoryText;
}

public function getDescription(): string
public function getTitle(): string
{
return $this->description;
return $this->title;
}

public function getMeasures(): iterable
Expand Down Expand Up @@ -92,15 +92,15 @@ public function getAdditionalReasons(): array
public function update(
string $identifier,
string $category,
string $description,
string $title,
?string $otherCategoryText = null,
array $additionalVisas = [],
array $additionalReasons = [],
?VisaModel $visaModel = null,
): void {
$this->identifier = $identifier;
$this->category = $category;
$this->description = $description;
$this->title = $title;
$this->otherCategoryText = $otherCategoryText;
$this->additionalVisas = $additionalVisas;
$this->additionalReasons = $additionalReasons;
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/BacIdf/BacIdfTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function transform(array $row): BacIdfTransformerResult
$generalInfo = new SaveRegulationGeneralInfoCommand();
$generalInfo->identifier = $row['ARR_REF'];
$generalInfo->category = RegulationOrderCategoryEnum::PERMANENT_REGULATION->value;
$generalInfo->description = $row['ARR_NOM'];
$generalInfo->title = $row['ARR_NOM'];

$date = $row['ARR_DUREE']['PERIODE_DEBUT']['$date'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private function buildGeneralInfoCommand(array $row, Organization $organization)
$command->otherCategoryText = $type;

// Adhere to character limit
$command->description = mb_substr($row['fields'][EudonetParisExtractor::ARRETE_COMPLEMENT_DE_TITRE], 0, 255);
$command->title = mb_substr($row['fields'][EudonetParisExtractor::ARRETE_COMPLEMENT_DE_TITRE], 0, 255);

$command->organization = $organization;

Expand Down
6 changes: 3 additions & 3 deletions src/Infrastructure/Form/Regulation/GeneralInfoFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
],
)
->add(
'description',
'title',
TextareaType::class,
options: [
'label' => 'regulation.general_info.description',
'help' => 'regulation.general_info.description.help',
'label' => 'regulation.general_info.title',
'help' => 'regulation.general_info.title.help',
],
)
->add(
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/JOP/JOPTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function transform(array $geoJSON, Organization $organization): ImportJOP
$generalInfoCommand->identifier = self::JOP_REGULATION_ORDER_IDENTIFIER;
$generalInfoCommand->organization = $organization;
$generalInfoCommand->category = RegulationOrderCategoryEnum::EVENT->value;
$generalInfoCommand->description = $this->translator->trans('jop.regulation_order.description');
$generalInfoCommand->title = $this->translator->trans('jop.regulation_order.title');

$measureCommands = [];
$tz = new \DateTimeZone('Europe/Paris');
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/Litteralis/LitteralisTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function transform(
$generalInfoCommand = new SaveRegulationGeneralInfoCommand();
$generalInfoCommand->identifier = $identifier;
$this->setCategory($generalInfoCommand, $properties);
$generalInfoCommand->description = $this->buildDescription($properties);
$generalInfoCommand->title = $this->buildDescription($properties);
$generalInfoCommand->organization = $organization;

// (2) Parsing des mesures et leur contenu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,71 +23,71 @@ public function load(ObjectManager $manager): void
uuid: '54eacea0-e1e0-4823-828d-3eae72b76da8',
identifier: self::TYPICAL_IDENTIFIER,
category: RegulationOrderCategoryEnum::EVENT->value,
description: 'Description 1',
title: 'Title 1',
);

$publishedRegulationOrder = new RegulationOrder(
uuid: '2e5eb289-90c8-4c3f-8e7c-2e9e7de8948c',
identifier: 'FO2/2023',
category: RegulationOrderCategoryEnum::ROAD_MAINTENANCE->value,
description: 'Description 2',
title: 'Title 2',
);

$regulationOrderPermanent = new RegulationOrder(
uuid: 'c147cc20-ed02-4bd9-9f6b-91b67df296bd',
identifier: 'FO3/2023',
category: RegulationOrderCategoryEnum::PERMANENT_REGULATION->value,
description: 'Description 3',
title: 'Title 3',
);

$fullCityRegulationOrder = new RegulationOrder(
uuid: '0658c568-dfbe-7c64-8000-303f7e2ae9b3',
identifier: 'F2023/full-city',
category: RegulationOrderCategoryEnum::ROAD_MAINTENANCE->value,
description: 'Description 2',
title: 'Title 2',
);

$regulationOrderNoLocations = new RegulationOrder(
uuid: 'e589f277-ccd4-4364-967a-7e9db80e6d34',
identifier: 'F2023/no-locations',
description: 'Description 5 that is very long and will be truncated',
title: 'Title 5 that is very long and will be truncated',
category: RegulationOrderCategoryEnum::OTHER->value,
otherCategoryText: 'Dérogation préfectorale',
);

$regulationOrderNoMeasures = new RegulationOrder(
uuid: '0650037e-8f8e-7f66-8000-c8ebe51493b9',
identifier: 'FO14/2023',
description: 'No measures',
title: 'No measures',
category: RegulationOrderCategoryEnum::ROAD_MAINTENANCE->value,
);

$regulationOrderCifs = new RegulationOrder(
uuid: '06549047-db9d-74bb-8000-754a6f2ff4c3',
identifier: self::IDENTIFIER_CIFS,
category: RegulationOrderCategoryEnum::ROAD_MAINTENANCE->value,
description: 'Arrêté exporté vers CIFS',
title: 'Arrêté exporté vers CIFS',
);

$outDatedRegulationOrderCifs = new RegulationOrder(
uuid: 'edc8dd18-5f56-4684-b2ba-d18658d53518',
identifier: 'F/OUTDATED/CIFS/2021',
category: RegulationOrderCategoryEnum::ROAD_MAINTENANCE->value,
description: 'Arrêté exporté vers CIFS',
title: 'Arrêté exporté vers CIFS',
);

$rawGeoJSONRegulationOrder = new RegulationOrder(
uuid: '06672e5f-f248-785b-8000-5f4ee64ca094',
identifier: 'F2024/RAWGEOJSON',
category: RegulationOrderCategoryEnum::ROAD_MAINTENANCE->value,
description: 'Arrêté avec données brutes GeoJSON',
title: 'Arrêté avec données brutes GeoJSON',
);

$litteralisRegulationOrder = new RegulationOrder(
uuid: '066e9849-f802-7a4c-8000-845f47c4b0de',
identifier: '117374#24-A-0473',
category: RegulationOrderCategoryEnum::ROAD_MAINTENANCE->value,
description: 'Arrêté de voirie (URL : https://dl.sogelink.fr/?iX5UN3GL)',
title: 'Arrêté de voirie (URL : https://dl.sogelink.fr/?iX5UN3GL)',
);

$manager->persist($typicalRegulationOrder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<field name="identifier" type="string" column="identifier" length="60" nullable="false"/>
<field name="category" type="string" column="category" length="50" nullable="false"/>
<field name="otherCategoryText" type="string" column="other_category_text" length="100" nullable="true"/>
<field name="description" type="text" column="description" nullable="false"/>
<field name="title" type="text" column="title" nullable="false"/>
<field name="additionalVisas" type="array" nullable="true"/>
<field name="additionalReasons" type="array" nullable="true"/>
<one-to-many field="measures" target-entity="App\Domain\Regulation\Measure" mapped-by="regulationOrder"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace App\Infrastructure\Persistence\Doctrine\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241126131536 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE regulation_order RENAME COLUMN description TO title');
}

public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE regulation_order RENAME COLUMN title TO description');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ public function findAllRegulations(
->addSelect(\sprintf('(%s) as nbLocations', self::COUNT_LOCATIONS_QUERY))
->addSelect(\sprintf('(%s) as namedStreet', self::GET_NAMED_STREET_QUERY))
->addSelect(\sprintf('(%s) as numberedRoad', self::GET_NUMBERED_ROAD_QUERY))
->addSelect(\sprintf('(%s) as rawGeoJSON', self::GET_RAW_GEOJSON_QUERY))
;
->addSelect(\sprintf('(%s) as rawGeoJSON', self::GET_RAW_GEOJSON_QUERY));

$parameters = [];

Expand Down Expand Up @@ -185,8 +184,7 @@ public function findOneUuidByIdentifierInOrganization(string $identifier, Organi
'organization' => $organization,
])
->getQuery()
->getOneOrNullResult()
;
->getOneOrNullResult();

return $row ? $row['uuid'] : null;
}
Expand All @@ -208,7 +206,7 @@ public function findGeneralInformation(string $uuid): ?array
ro.uuid as regulationOrderUuid,
ro.category,
ro.otherCategoryText,
ro.description,
ro.title,
(%s) as overallStartDate,
(%s) as overallEndDate
',
Expand All @@ -233,8 +231,7 @@ public function findOrganizationUuid(string $uuid): ?string
->where('roc.uuid = :uuid')
->setParameter('uuid', $uuid)
->getQuery()
->getOneOrNullResult()
;
->getOneOrNullResult();

return $row ? $row['uuid'] : null;
}
Expand Down Expand Up @@ -275,8 +272,7 @@ public function getOverallDatesByRegulationUuids(array $uuids): array
->where('roc.uuid IN (:uuids)')
->setParameter('uuids', $uuids, ArrayParameterType::STRING)
->getQuery()
->getResult()
;
->getResult();

// Return array of $uuid => {overallStartDate, overallEndDate}
$result = [];
Expand Down
2 changes: 1 addition & 1 deletion templates/api/regulations.xml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<trafficRegulationOrder id="{{ regulationOrder.uuid }}" version="1">
<description>
<com:values>
<com:value>{{ regulationOrder.description }}</com:value>
<com:value>{{ regulationOrder.title }}</com:value>
</com:values>
</description>
<issuingAuthority>
Expand Down
2 changes: 1 addition & 1 deletion templates/regulation/_general_info_form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
{{ form_row(form.otherCategoryText, { group_class: 'fr-input-group', widget_class: 'fr-input', attr: { 'data-form-reveal-target': 'form-control' } }) }}
</div>
</div>
{{ form_row(form.description, {group_class: 'fr-input-group', attr: {class: 'fr-input'}, help_attr: {class: 'fr-hint-text'}}) }}
{{ form_row(form.title, {group_class: 'fr-input-group', attr: {class: 'fr-input'}, help_attr: {class: 'fr-hint-text'}}) }}
</div>
<div id="reasons-panel" class="fr-tabs__panel" role="tabpanel" aria-labelledby="reasons" tabindex="0">
<p>{{ 'regulation.general_info.visas_and_reasons.description'|trans }}</p>
Expand Down
2 changes: 1 addition & 1 deletion templates/regulation/export.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Arrếté n°[{{ generalInfo.identifier }}]{custom-style="Dialog_Variable"}
:::

::: {custom-style="Dialog_Description"}
[{{ generalInfo.description }}]{custom-style="Dialog_Variable"}
[{{ generalInfo.title }}]{custom-style="Dialog_Variable"}
:::

{% if signingAuthority %}
Expand Down
4 changes: 2 additions & 2 deletions templates/regulation/fragments/_general_info.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="app-card__header">
<span class="app-card__img fr-icon-article-line fr-x-icon-decorative--blue-france fr-x-icon--xl" aria-hidden="true"></span>
<h3 class="app-card__title fr-h4 fr-mb-0">
{{ generalInfo.description|u.truncate(36, '...', false) }}
{{ generalInfo.title|u.truncate(36, '...', false) }}
</h3>
</div>
<div class="app-card__content" style="--card-content-margin-desktop: var(--6w)">
Expand All @@ -16,7 +16,7 @@
{{ ('regulation.category.' ~ generalInfo.category)|trans }}
{% endif %}
</li>
<li>{{ generalInfo.description }}</li>
<li>{{ generalInfo.title }}</li>
<li>
{% include 'regulation/_overall_period.html.twig' with { generalInfo } only %}
</li>
Expand Down
Loading

0 comments on commit 3eb3382

Please sign in to comment.