diff --git a/confiture-rest-api/src/audits/dto/entities/page.dto.ts b/confiture-rest-api/src/audits/dto/entities/page.dto.ts index 7ef98303a..4d9d08cce 100644 --- a/confiture-rest-api/src/audits/dto/entities/page.dto.ts +++ b/confiture-rest-api/src/audits/dto/entities/page.dto.ts @@ -1,5 +1,6 @@ export class PageDto { id: number; + slug: string; order: number; name: string; url: string; diff --git a/confiture-rest-api/src/audits/prisma-selects.ts b/confiture-rest-api/src/audits/prisma-selects.ts index f1fa4354b..60bec3cf1 100644 --- a/confiture-rest-api/src/audits/prisma-selects.ts +++ b/confiture-rest-api/src/audits/prisma-selects.ts @@ -4,7 +4,8 @@ export const PAGE_PRISMA_SELECT: Prisma.AuditedPageSelect = { id: true, order: true, name: true, - url: true + url: true, + slug: true }; export const ENVIRONMENT_PRISMA_SELECT: Prisma.TestEnvironmentSelect = { diff --git a/confiture-web-app/src/components/audit/AraTabsTwo.vue b/confiture-web-app/src/components/audit/AraTabsTwo.vue new file mode 100644 index 000000000..71d64a1dd --- /dev/null +++ b/confiture-web-app/src/components/audit/AraTabsTwo.vue @@ -0,0 +1,260 @@ + + + + + diff --git a/confiture-web-app/src/pages/audit/AuditGenerationPage.vue b/confiture-web-app/src/pages/audit/AuditGenerationPage.vue index 93b3983e3..264f9c986 100644 --- a/confiture-web-app/src/pages/audit/AuditGenerationPage.vue +++ b/confiture-web-app/src/pages/audit/AuditGenerationPage.vue @@ -3,10 +3,9 @@ import { useResizeObserver } from "@vueuse/core"; import { computed, nextTick, ref, watch } from "vue"; import { onBeforeRouteLeave } from "vue-router"; -import AraTabs from "../../components/audit/AraTabs.vue"; +import AraTabsTwo, { TabItem } from "../../components/audit/AraTabsTwo.vue"; import AuditGenerationFilters from "../../components/audit/AuditGenerationFilters.vue"; import AuditGenerationHeader from "../../components/audit/AuditGenerationHeader.vue"; -import AuditGenerationPageCriteria from "../../components/audit/AuditGenerationPageCriteria.vue"; import PageMeta from "../../components/PageMeta"; import { SummaryCardThemes } from "../../components/SummaryCard.vue"; import BackLink from "../../components/ui/BackLink.vue"; @@ -14,14 +13,14 @@ import { useAuditStats } from "../../composables/useAuditStats"; import { useWrappedFetch } from "../../composables/useWrappedFetch"; import rgaa from "../../criteres.json"; import { CRITERIA_BY_AUDIT_TYPE } from "../../criteria"; -import { REFERENTIAL, StaticTabLabel } from "../../enums"; +import { REFERENTIAL, StaticTabLabel, TabSlug } from "../../enums"; import { useAccountStore, useAuditStore, useFiltersStore, useResultsStore } from "../../store"; -import { AuditType, CriteriumResultStatus, TabData } from "../../types"; +import { AuditType, CriteriumResultStatus } from "../../types"; import { pluralize } from "../../utils"; const props = defineProps<{ @@ -192,33 +191,57 @@ const pageTitle = computed(() => { return titleParts.join(" - "); }); -const tabsData = computed((): TabData[] => { - const transversePage = auditStore.currentAudit?.transverseElementsPage; +// const tabsData = computed((): TabData[] => { +// const transversePage = auditStore.currentAudit?.transverseElementsPage; +// return [ +// ...(transversePage +// ? [ +// { +// label: StaticTabLabel.AUDIT_COMMON_ELEMENTS_TAB_LABEL, +// diplayLabelSuffix: " (optionnel)", +// icon: "fr-icon-layout-3-line", +// component: AuditGenerationPageCriteria, +// componentParams: { +// page: transversePage, +// auditUniqueId: props.uniqueId +// } +// } +// ] +// : []), +// ...(auditStore.currentAudit?.pages.map((p) => ({ +// label: p.name, +// hiddenLabelSuffix: resultsStore.isPageCompleted(p.id) ? " (entièrement évalué)" : undefined, +// id: p.id, +// icon: resultsStore.isPageCompleted(p.id) ? "fr-icon-check-line" : undefined, +// component: AuditGenerationPageCriteria, +// componentParams: { +// page: p, +// auditUniqueId: props.uniqueId +// } +// })) ?? []) +// ]; +// }); + +const tabsTwo = computed((): TabItem[] => { return [ - ...(transversePage + ...(auditStore.currentAudit?.transverseElementsPage ? [ { label: StaticTabLabel.AUDIT_COMMON_ELEMENTS_TAB_LABEL, - diplayLabelSuffix: " (optionnel)", icon: "fr-icon-layout-3-line", - component: AuditGenerationPageCriteria, - componentParams: { - page: transversePage, - auditUniqueId: props.uniqueId - } + to: `/audits/${props.uniqueId}/generation/${TabSlug.AUDIT_COMMON_ELEMENTS_SLUG}` } ] : []), ...(auditStore.currentAudit?.pages.map((p) => ({ label: p.name, - hiddenLabelSuffix: resultsStore.isPageCompleted(p.id) ? " (entièrement évalué)" : undefined, - id: p.id, - icon: resultsStore.isPageCompleted(p.id) ? "fr-icon-check-line" : undefined, - component: AuditGenerationPageCriteria, - componentParams: { - page: p, - auditUniqueId: props.uniqueId - } + hiddenLabelSuffix: resultsStore.isPageCompleted(p.id) + ? " (entièrement évalué)" + : undefined, + to: `/audits/${props.uniqueId}/generation/${p.slug}`, + icon: resultsStore.isPageCompleted(p.id) + ? "fr-icon-check-line" + : undefined })) ?? []) ]; }); @@ -249,30 +272,33 @@ function toggleFilters(doShow: boolean) { } // Note: here useWrappedFetch uses onMounted callback -useWrappedFetch(async () => { - resultsStore.$reset(); - - await Promise.all([ - auditStore.fetchAuditIfNeeded(props.uniqueId), - resultsStore.fetchResults(props.uniqueId) - ]); - - // wait for rerender before getting ref - await nextTick(); - stickyIndicator.value = auditGenerationHeaderRef.value?.stickyIndicator; - - // if the user navigated away during fetching, it’s possible the stickyIndicator is not in the DOM anymore - if (stickyIndicator.value) { - useResizeObserver(stickyIndicator.value, () => { - stickyTop.value = `calc(${getComputedStyle(stickyIndicator!.value).top} + ${ - stickyIndicator!.value.clientHeight - }px)`; - }); +useWrappedFetch( + async () => { + resultsStore.$reset(); + + await Promise.all([ + auditStore.fetchAuditIfNeeded(props.uniqueId) + // resultsStore.fetchResults(props.uniqueId) + ]); + + // wait for rerender before getting ref + await nextTick(); + stickyIndicator.value = auditGenerationHeaderRef.value?.stickyIndicator; + + // if the user navigated away during fetching, it’s possible the stickyIndicator is not in the DOM anymore + if (stickyIndicator.value) { + useResizeObserver(stickyIndicator.value, () => { + stickyTop.value = `calc(${getComputedStyle(stickyIndicator!.value).top} + ${ + stickyIndicator!.value.clientHeight + }px)`; + }); + } + }, + (newParams, oldParams) => { + // Only fetch data if uniqueId changes + return newParams.uniqueId !== oldParams.uniqueId; } -}, (newParams, oldParams) => { - // Only fetch data if uniqueId changes - return newParams.uniqueId !== oldParams.uniqueId; -}); +); onBeforeRouteLeave(() => { auditStore.showAuditEmailAlert = false; @@ -293,7 +319,10 @@ filterStore.$reset();