Skip to content

Commit

Permalink
Fusionne la recommandation et la description de l'erreur (#720)
Browse files Browse the repository at this point in the history
* remove recommandation textarea in audit and render in report

* add migration

* rename errorDescription to notCompliantComment

* fix migration

* update changelog

---------

Co-authored-by: Adrien Boutigny <[email protected]>
  • Loading branch information
bellangerq and hissalht authored Jun 12, 2024
1 parent d11f385 commit 5e59a0d
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 105 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Tous les changements notables de Ara sont documentés ici avec leur date, leur catégorie (nouvelle fonctionnalité, correction de bug ou autre changement) et leur pull request (PR) associée.

## 12/06/2024

### Autres changements ⚙️

- Fusionne les champs "Recommandation" et "Description de l'erreur" ([#720](https://github.com/DISIC/Ara/pull/720))

## 06/06/2024

### Corrections 🐛
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- Merge recommandation and errorDescription into errorDescription
UPDATE
"CriterionResult"
SET
"errorDescription" =
CASE
WHEN "errorDescription" IS NULL OR LENGTH(BTRIM("errorDescription", E' \t\r\n')) = 0
THEN BTRIM("recommandation", E' \t\r\n')
ELSE
BTRIM(COALESCE("errorDescription", ''), E' \t\r\n') || E'\n\n---\n\n' || BTRIM("recommandation", E' \t\r\n')
END
WHERE
"recommandation" IS NOT NULL
AND LENGTH(BTRIM("recommandation", E' \t\r\n')) > 0;

/*
Warnings:
- You are about to drop the column `recommandation` on the `CriterionResult` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "CriterionResult" DROP COLUMN "recommandation";
13 changes: 6 additions & 7 deletions confiture-rest-api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ generator client {
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
provider = "postgresql"
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}

Expand Down Expand Up @@ -127,11 +127,10 @@ model CriterionResult {
compliantComment String?
errorDescription String?
userImpact CriterionResultUserImpact?
recommandation String?
exampleImages StoredFile[]
quickWin Boolean @default(false)
notCompliantComment String? @map("errorDescription")
userImpact CriterionResultUserImpact?
exampleImages StoredFile[]
quickWin Boolean @default(false)
notApplicableComment String?
Expand Down
12 changes: 4 additions & 8 deletions confiture-rest-api/src/audits/audit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@ export class AuditService {
return {
status: CriterionResultStatus.NOT_TESTED,
compliantComment: null,
errorDescription: null,
notCompliantComment: null,
userImpact: null,
recommandation: null,
notApplicableComment: null,
exampleImages: [],
transverse: false,
Expand Down Expand Up @@ -362,9 +361,8 @@ export class AuditService {

status: item.status,
compliantComment: item.compliantComment,
errorDescription: item.errorDescription,
notCompliantComment: item.notCompliantComment,
notApplicableComment: item.notApplicableComment,
recommandation: item.recommandation,
userImpact: item.userImpact,
quickWin: item.quickWin,
transverse: item.transverse
Expand Down Expand Up @@ -411,8 +409,7 @@ export class AuditService {
}),

...(item.status === CriterionResultStatus.NOT_COMPLIANT && {
errorDescription: item.errorDescription,
recommandation: item.recommandation,
notCompliantComment: item.notCompliantComment,
userImpact: item.userImpact,
quickWin: item.quickWin
}),
Expand Down Expand Up @@ -917,9 +914,8 @@ export class AuditService {
transverse: r.transverse,

compliantComment: r.compliantComment,
errorDescription: r.errorDescription,
notCompliantComment: r.notCompliantComment,
notApplicableComment: r.notApplicableComment,
recommandation: r.recommandation,
userImpact: r.userImpact,
quickWin: r.quickWin,
exampleImages: r.exampleImages.map((img) => ({
Expand Down
8 changes: 2 additions & 6 deletions confiture-rest-api/src/audits/dto/audit-report.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,15 @@ class ReportCriterionResult {
compliantComment: string | null;

/**
* @example "There is an accessibility error there."
* @example "There is an accessibility error there. You should do this and that."
*/
errorDescription: string | null;
notCompliantComment: string | null;
exampleImages: ExampleImage[];
/**
* @example "MAJOR"
*/
@ApiProperty({ enum: CriterionResultUserImpact })
userImpact: CriterionResultUserImpact | null;
/**
* @example "You could do this or do that."
*/
recommandation: string | null;

notApplicableComment: string | null;
}
Expand Down
9 changes: 1 addition & 8 deletions confiture-rest-api/src/audits/dto/update-results.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class UpdateResultsItem {
*/
@IsString()
@IsOptional()
errorDescription?: string;
notCompliantComment?: string;

/**
* @example "MAJOR"
Expand All @@ -113,13 +113,6 @@ class UpdateResultsItem {
@IsOptional()
userImpact?: CriterionResultUserImpact;

/**
* @example "Quis do mollit eu incididunt duis et cillum ullamco laborum tempor laboris deserunt."
*/
@IsString()
@IsOptional()
recommandation?: string;

/**
* Whether the result is easy to fix
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,18 +311,16 @@ const isOffline = useIsOffline();
<CriteriumNotCompliantAccordion
v-else-if="result.status === CriteriumResultStatus.NOT_COMPLIANT"
:id="`not-compliant-accordion-${uniqueId}`"
:comment="result.errorDescription"
:comment="result.notCompliantComment"
:user-impact="result.userImpact"
:example-images="result.exampleImages"
:recommandation="result.recommandation"
:quick-win="result.quickWin"
:show-file-format-error="showFileFormatError"
:show-file-size-error="showFileSizeError"
@update:comment="updateResultComment($event, 'errorDescription')"
@update:comment="updateResultComment($event, 'notCompliantComment')"
@update:user-impact="updateResultImpact($event)"
@upload-example="handleUploadExample"
@delete-example="handleDeleteExample"
@update:recommandation="updateResultComment($event, 'recommandation')"
@update:quick-win="updateQuickWin"
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const props = defineProps<{
comment: string | null;
userImpact: CriterionResultUserImpact | null;
exampleImages: ExampleImage[];
recommandation: string | null;
quickWin?: boolean;
showFileFormatError: boolean;
Expand All @@ -26,7 +25,6 @@ const emit = defineEmits<{
(e: "update:userImpact", payload: CriterionResultUserImpact | null): void;
(e: "upload-example", payload: File): void;
(e: "delete-example", payload: ExampleImage): void;
(e: "update:recommandation", payload: string): void;
(e: "update:quickWin", payload: boolean): void;
}>();
Expand Down Expand Up @@ -81,7 +79,7 @@ const isOffline = useIsOffline();

<template>
<LazyAccordion
title="Description et recommandation"
title="Erreur et recommandation"
disclose-color="var(--background-default-grey)"
>
<!-- COMMENT -->
Expand All @@ -90,7 +88,7 @@ const isOffline = useIsOffline();
class="fr-label fr-text--bold"
:for="`criterum-comment-field-${id}`"
>
Description de la ou des erreurs
Description des erreurs et recommandations
</label>
<textarea
:id="`criterum-comment-field-${id}`"
Expand Down Expand Up @@ -197,32 +195,6 @@ const isOffline = useIsOffline();
@update:model-value="$emit('update:userImpact', $event)"
/>

<!-- RECOMMANDATION -->
<div class="fr-input-group fr-mb-1w">
<label
class="fr-label fr-text--bold"
:for="`criterum-comment-field-recommendation-${id}`"
>
Recommandation de correction
</label>
<textarea
:id="`criterum-comment-field-recommendation-${id}`"
:value="recommandation ?? ''"
class="fr-input"
rows="5"
:disabled="isOffline"
:aria-describedby="`markdown-notice-${id}`"
@input="
$emit(
'update:recommandation',
($event.target as HTMLTextAreaElement).value
)
"
></textarea>
</div>

<MarkdownHelpButton :id="`markdown-notice-${id}`" class="fr-mb-3w" />

<!-- QUICK WIN -->
<div class="fr-fieldset__element fr-fieldset__element--inline">
<div class="fr-checkbox-group">
Expand Down
54 changes: 20 additions & 34 deletions confiture-web-app/src/components/report/ReportErrors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -497,16 +497,21 @@ function getPage(pageId: number | string) {

<!-- Error -->
<LazyAccordion
v-if="error.errorDescription || error.exampleImages.length > 0"
title="Description de la ou des erreurs"
v-if="
error.notCompliantComment || error.exampleImages.length > 0
"
title="Erreur et recommandation"
data-accordion
>
<MarkdownRenderer
v-if="error.errorDescription"
v-if="error.notCompliantComment"
class="fr-mb-3w"
:markdown="error.errorDescription"
:markdown="error.notCompliantComment"
/>
<p class="fr-text--xs fr-mb-1w error-accordion-subtitle">
<p
v-if="chunk(error.exampleImages, 2).length"
class="fr-text--xs fr-mb-1w error-accordion-subtitle"
>
Exemple(s) d’erreur(s)
</p>
<div class="fr-container--fluid">
Expand Down Expand Up @@ -535,18 +540,6 @@ function getPage(pageId: number | string) {
</div>
</LazyAccordion>

<!-- Recommendation -->
<LazyAccordion
v-if="error.recommandation"
title="Recommandation de correction"
data-accordion
>
<MarkdownRenderer
class="fr-mb-0"
:markdown="error.recommandation"
/>
</LazyAccordion>

<!-- Tests -->
<CriteriumTestsAccordion
:topic-number="error.topic"
Expand Down Expand Up @@ -621,16 +614,21 @@ function getPage(pageId: number | string) {

<!-- Error -->
<LazyAccordion
v-if="error.errorDescription || error.exampleImages.length > 0"
title="Description de la ou des erreurs"
v-if="
error.notCompliantComment || error.exampleImages.length > 0
"
title="Erreur et recommandation"
data-accordion
>
<MarkdownRenderer
v-if="error.errorDescription"
v-if="error.notCompliantComment"
class="fr-mb-3w"
:markdown="error.errorDescription"
:markdown="error.notCompliantComment"
/>
<p class="fr-text--xs fr-mb-1w error-accordion-subtitle">
<p
v-if="chunk(error.exampleImages, 2).length"
class="fr-text--xs fr-mb-1w error-accordion-subtitle"
>
Exemple(s) d’erreur(s)
</p>
<div class="fr-container--fluid">
Expand Down Expand Up @@ -659,18 +657,6 @@ function getPage(pageId: number | string) {
</div>
</LazyAccordion>

<!-- Recommendation -->
<LazyAccordion
v-if="error.recommandation"
title="Recommandation de correction"
data-accordion
>
<MarkdownRenderer
class="fr-mb-0"
:markdown="error.recommandation"
/>
</LazyAccordion>

<!-- Tests -->
<CriteriumTestsAccordion
:topic-number="error.topic"
Expand Down
4 changes: 2 additions & 2 deletions confiture-web-app/src/pages/error/ErrorPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const errorTitle =
// TODO: get default content
}[statusCode] ?? "Erreur inconnue";
const errorDescription =
const notCompliantComment =
{
404: "La page que vous cherchez est introuvable. Excusez-nous pour la gêne occasionnée.",
408: "Désolé, la page n'a pa pu être affichée, le serveur a mis trop de temps à répondre.",
Expand Down Expand Up @@ -68,7 +68,7 @@ const route = useRoute();
<h1>{{ errorTitle }}</h1>
<p class="fr-text--sm">Erreur {{ statusCode }}</p>
<p class="fr-text--xl fr-mb-5w">
{{ errorDescription }}
{{ notCompliantComment }}
</p>
<div
v-if="statusCode !== 410"
Expand Down
6 changes: 2 additions & 4 deletions confiture-web-app/src/store/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ export const useResultsStore = defineStore("results", {
}

if (update.status === CriteriumResultStatus.NOT_COMPLIANT) {
target.errorDescription = update.errorDescription;
target.recommandation = update.recommandation;
target.notCompliantComment = update.notCompliantComment;
target.userImpact = update.userImpact;
target.quickWin = update.quickWin;
}
Expand Down Expand Up @@ -449,9 +448,8 @@ export const useResultsStore = defineStore("results", {
CriteriumResultStatus.NOT_APPLICABLE
])!,
compliantComment: sample(["Commentaire conforme", "Rien"])!,
errorDescription: sample(["Commentaire non conforme", "Rien"])!,
notCompliantComment: sample(["Commentaire non conforme", "Rien"])!,
notApplicableComment: sample(["Commentaire non-applicable", "Rien"])!,
recommandation: sample(["Recommandation", "Rien"])!,
userImpact: sample(CriterionResultUserImpact)!
/* eslint-enable @typescript-eslint/no-non-null-assertion */
})) ?? [];
Expand Down
3 changes: 1 addition & 2 deletions confiture-web-app/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ export interface CriteriumResult {
transverse: boolean;

compliantComment: string | null;
errorDescription: string | null;
notCompliantComment: string | null;
userImpact: CriterionResultUserImpact | null;
recommandation: string | null;
notApplicableComment: string | null;
exampleImages: ExampleImage[];
quickWin: boolean;
Expand Down

0 comments on commit 5e59a0d

Please sign in to comment.