diff --git a/CHANGELOG.md b/CHANGELOG.md index 28163b11..8b0ec485 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,19 @@ 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. +## 23/05/2024 + +### Nouvelles fonctionnalités 🚀 + +- Permet d’accéder à un rapport quand l’audit est supprimer ([#662](https://github.com/DISIC/Ara/pull/662)) + ## 26/04/2024 ### Autres changements ⚙️ - Ajoute un lien de retour vers le rapport depuis la page de contexte de l’audit ([#703](https://github.com/DISIC/Ara/pull/703)) + ## 17/04/2024 ### Nouvelles fonctionnalités 🚀 diff --git a/confiture-rest-api/prisma/migrations/20240424124805_add_audit_is_hidden/migration.sql b/confiture-rest-api/prisma/migrations/20240424124805_add_audit_is_hidden/migration.sql new file mode 100644 index 00000000..b40f712a --- /dev/null +++ b/confiture-rest-api/prisma/migrations/20240424124805_add_audit_is_hidden/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Audit" ADD COLUMN "isHidden" BOOLEAN NOT NULL DEFAULT false; diff --git a/confiture-rest-api/prisma/schema.prisma b/confiture-rest-api/prisma/schema.prisma index 130249c8..14f33036 100644 --- a/confiture-rest-api/prisma/schema.prisma +++ b/confiture-rest-api/prisma/schema.prisma @@ -84,6 +84,10 @@ model Audit { sourceAuditId Int? auditCopies Audit[] @relation("AuditDuplicationHistory") + // As of https://github.com/DISIC/Ara/pull/662, when an audit is deleted, its + // data is longer editable, but the report remainn available + isHidden Boolean @default(false) + @@unique([editUniqueId, consultUniqueId]) } diff --git a/confiture-rest-api/src/audits/audit-export.service.ts b/confiture-rest-api/src/audits/audit-export.service.ts index e9a19027..3f8a21a0 100644 --- a/confiture-rest-api/src/audits/audit-export.service.ts +++ b/confiture-rest-api/src/audits/audit-export.service.ts @@ -82,8 +82,12 @@ export class AuditExportService { } async getCsvExport(editUniqueId: string): Promise { - const audit = - await this.auditService.getAuditWithEditUniqueId(editUniqueId); + const audit = (await this.auditService.findAuditWithEditUniqueId( + editUniqueId, + { pages: true } + )) as Audit & { + pages: AuditedPage[]; + }; const results = await this.auditService.getResultsWithEditUniqueId(editUniqueId); diff --git a/confiture-rest-api/src/audits/audit.service.ts b/confiture-rest-api/src/audits/audit.service.ts index 3306ed81..c1ca725f 100644 --- a/confiture-rest-api/src/audits/audit.service.ts +++ b/confiture-rest-api/src/audits/audit.service.ts @@ -78,25 +78,10 @@ export class AuditService { }); } - // getAuditWithConsultUniqueId(uniqueId: string) { - // return this.prisma.audit.findUnique({ - // where: { consultUniqueId: uniqueId }, - // }); - // } - - getAuditWithEditUniqueId(uniqueId: string) { - return this.prisma.audit.findUnique({ - where: { editUniqueId: uniqueId }, - include: { - recipients: true, - environments: true, - pages: true, - sourceAudit: { - select: { - procedureName: true - } - } - } + findAuditWithEditUniqueId(uniqueId: string, include?: Prisma.AuditInclude) { + return this.prisma.audit.findFirst({ + where: { editUniqueId: uniqueId, isHidden: false }, + include }); } @@ -555,10 +540,10 @@ export class AuditService { } /** - * Delete an audit and the data associated with it. + * Completely delete an audit and all the data associated with it. * @returns True if an audit was deleted, false otherwise. */ - async deleteAudit(uniqueId: string): Promise { + async hardDeleteAudit(uniqueId: string): Promise { try { const storedFiles = await this.prisma.storedFile.findMany({ where: { @@ -594,6 +579,30 @@ export class AuditService { } } + /** + * Mark an audit as deleted and remove auditor informations. Its data will be not be deleted. + * @returns True if an audit was deleted, false otherwise. + */ + async softDeleteAudit(uniqueId: string): Promise { + try { + await this.prisma.audit.update({ + where: { editUniqueId: uniqueId }, + data: { + isHidden: true, + auditorEmail: null, + auditorName: null, + auditorOrganisation: null + } + }); + return true; + } catch (e) { + if (e?.code === "P2025") { + return false; + } + throw e; + } + } + /** * Checks if an audit was deleted by checking the presence of an audit trace. * @param uniqueId edit unique id of the checked audit @@ -930,9 +939,8 @@ export class AuditService { } async isAuditComplete(uniqueId: string): Promise { - const audit = await this.prisma.audit.findUnique({ - where: { editUniqueId: uniqueId }, - include: { pages: true } + const audit = await this.findAuditWithEditUniqueId(uniqueId, { + pages: true }); const testedCount = await this.prisma.criterionResult.count({ @@ -959,8 +967,8 @@ export class AuditService { } async duplicateAudit(sourceUniqueId: string, newAuditName: string) { - const originalAudit = await this.prisma.audit.findUnique({ - where: { editUniqueId: sourceUniqueId }, + const originalAudit = await this.prisma.audit.findFirst({ + where: { editUniqueId: sourceUniqueId, isHidden: false }, include: { environments: true, pages: { @@ -1132,7 +1140,8 @@ export class AuditService { async getAuditsByAuditorEmail(email: string) { const audits = await this.prisma.audit.findMany({ where: { - auditorEmail: email + auditorEmail: email, + isHidden: false }, select: { procedureName: true, diff --git a/confiture-rest-api/src/audits/audits.controller.ts b/confiture-rest-api/src/audits/audits.controller.ts index 9e9d0c63..423642d1 100644 --- a/confiture-rest-api/src/audits/audits.controller.ts +++ b/confiture-rest-api/src/audits/audits.controller.ts @@ -86,7 +86,15 @@ export class AuditsController { @ApiNotFoundResponse({ description: "The audit does not exist." }) @ApiGoneResponse({ description: "The audit has been previously deleted." }) async getAudit(@Param("uniqueId") uniqueId: string) { - const audit = await this.auditService.getAuditWithEditUniqueId(uniqueId); + const audit = await this.auditService.findAuditWithEditUniqueId(uniqueId, { + environments: true, + pages: true, + sourceAudit: { + select: { + procedureName: true + } + } + }); if (!audit) { return this.sendAuditNotFoundStatus(uniqueId); @@ -153,7 +161,7 @@ export class AuditsController { file: Express.Multer.File, @Body() body: UploadImageDto ) { - const audit = await this.auditService.getAuditWithEditUniqueId(uniqueId); + const audit = await this.auditService.findAuditWithEditUniqueId(uniqueId); if (!audit) { return this.sendAuditNotFoundStatus(uniqueId); @@ -210,7 +218,7 @@ export class AuditsController { @Param("uniqueId") uniqueId: string, @Body() body: UpdateResultsDto ) { - const audit = await this.auditService.getAuditWithEditUniqueId(uniqueId); + const audit = await this.auditService.findAuditWithEditUniqueId(uniqueId); if (!audit) { return this.sendAuditNotFoundStatus(uniqueId); @@ -247,7 +255,7 @@ export class AuditsController { @ApiNotFoundResponse({ description: "The audit does not exist." }) @ApiGoneResponse({ description: "The audit has been previously deleted." }) async deleteAudit(@Param("uniqueId") uniqueId: string) { - const deleted = await this.auditService.deleteAudit(uniqueId); + const deleted = await this.auditService.softDeleteAudit(uniqueId); if (!deleted) { return this.sendAuditNotFoundStatus(uniqueId); diff --git a/confiture-web-app/src/components/account/settings/Account.vue b/confiture-web-app/src/components/account/settings/Account.vue index 8276887e..74add19a 100644 --- a/confiture-web-app/src/components/account/settings/Account.vue +++ b/confiture-web-app/src/components/account/settings/Account.vue @@ -188,20 +188,4 @@ async function hideAccountDeletionForm() { .wrapper { max-width: 24rem; } - -.danger-button-outline { - color: var(--background-action-high-error); -} - -.danger-button { - background-color: var(--background-action-high-error); -} - -.danger-button:hover { - background-color: var(--background-action-high-error-hover); -} - -.danger-button:focus { - background-color: var(--background-action-high-error-active); -} diff --git a/confiture-web-app/src/components/audit/DeleteModal.vue b/confiture-web-app/src/components/audit/DeleteModal.vue index dc983853..714340e6 100644 --- a/confiture-web-app/src/components/audit/DeleteModal.vue +++ b/confiture-web-app/src/components/audit/DeleteModal.vue @@ -34,12 +34,13 @@ defineExpose({ class="fr-icon-warning-line fr-fi--lg" aria-hidden="true" /> - Vous allez supprimer l’audit + Vous allez supprimer cet audit

- Toutes les informations saisies seront effacées (cela comprend - l’audit, le rapport et toute donnée personnelle associée). Cette - action est irréversible. Souhaitez-vous supprimer l’audit ? + Cet audit sera définitivement supprimé. Le rapport de cet audit + restera disponible mais toutes vos informations personnelles + seront supprimées : prénom, nom, nom de la structure et adresse + e-mail.

- - diff --git a/confiture-web-app/src/components/audit/LeaveModal.vue b/confiture-web-app/src/components/audit/LeaveModal.vue index 67e09cd7..3e583b96 100644 --- a/confiture-web-app/src/components/audit/LeaveModal.vue +++ b/confiture-web-app/src/components/audit/LeaveModal.vue @@ -76,17 +76,3 @@ defineExpose({ - - diff --git a/confiture-web-app/src/pages/report/ContextPage.vue b/confiture-web-app/src/pages/report/ContextPage.vue index c2e15074..2fab511a 100644 --- a/confiture-web-app/src/pages/report/ContextPage.vue +++ b/confiture-web-app/src/pages/report/ContextPage.vue @@ -103,11 +103,9 @@ useWrappedFetch(() => report.fetchReport(uniqueId));

Auditeur ou auditrice

- + Cet audit a été réalisé par + {{ report.data.context.auditorName }}.

diff --git a/confiture-web-app/src/pages/report/ReportPage.vue b/confiture-web-app/src/pages/report/ReportPage.vue index e869ab7d..70b5d606 100644 --- a/confiture-web-app/src/pages/report/ReportPage.vue +++ b/confiture-web-app/src/pages/report/ReportPage.vue @@ -224,7 +224,7 @@ const siteUrl = computed(() => {

Référentiel : {{ report.data.context.referencial }}

-

+

Auditeur ou auditrice : {{ report.data.context.auditorName }}

diff --git a/confiture-web-app/src/styles/main.css b/confiture-web-app/src/styles/main.css index b3007e1a..ec02432b 100644 --- a/confiture-web-app/src/styles/main.css +++ b/confiture-web-app/src/styles/main.css @@ -55,3 +55,22 @@ from DSFR links with `target="_blank"` */ [target="_blank"].no-external-icon::after { content: none !important; } + +/* DSFR-style primary button with "danger" variant */ +.danger-button { + background-color: var(--background-action-high-error) !important; + color: var(--grey-950-125) !important; +} + +.danger-button:hover { + background-color: var(--background-action-high-error-hover) !important; +} + +.danger-button:focus { + background-color: var(--background-action-high-error-active) !important; +} + +/* DSFR-style outline button with "danger" variant */ +.danger-button-outline { + color: var(--background-action-high-error) !important; +}