-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Affiche les critères conformes dans le rapport (#732)
* update errors tab * display improvements on new tab * conditionnally display improvements tab * add improvement criterium component * create layout component for report criteria * split functions to fetch report data * create ReportErrorCriterium * lint imports * update changelog * refacto active menu condition Co-authored-by: Adrien Boutigny <[email protected]> * fix current active link in side menu + type report criteria props * remove log Co-authored-by: Adrien Boutigny <[email protected]> * remove sticky class --------- Co-authored-by: Adrien Boutigny <[email protected]>
- Loading branch information
1 parent
2e91379
commit 2a94132
Showing
12 changed files
with
847 additions
and
669 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
confiture-web-app/src/components/report/ReportCriteria.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<script setup lang="ts"> | ||
import { computed } from "vue"; | ||
import { useRoute } from "vue-router"; | ||
import { pluralize } from "../../utils"; | ||
import { ReportErrors, ReportTransverseError } from "./getReportErrors"; | ||
const props = defineProps<{ | ||
pagesData: ReportErrors[]; | ||
transverseData: ReportTransverseError[]; | ||
showFilters?: boolean; | ||
}>(); | ||
const dataCount = computed(() => { | ||
return ( | ||
props.pagesData | ||
.map((page: any) => page.topics.map((topic: any) => topic.improvements)) | ||
.flat(2).length + props.transverseData.length | ||
); | ||
}); | ||
// Set active side menu link | ||
const route = useRoute(); | ||
function isActive(id: string) { | ||
return route.hash && route.hash === id; | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="main"> | ||
<div class="sidebar"> | ||
<nav class="fr-sidemenu fr-mb-3w" aria-label="Liste des pages"> | ||
<div class="fr-sidemenu__inner"> | ||
<button | ||
class="fr-sidemenu__btn" | ||
hidden | ||
aria-controls="fr-sidemenu-wrapper" | ||
aria-expanded="false" | ||
> | ||
Pages | ||
</button> | ||
<div id="fr-sidemenu-wrapper" class="fr-collapse"> | ||
<div class="fr-sidemenu__title fr-mb-2w">Pages</div> | ||
<ul class="fr-sidemenu__list"> | ||
<li | ||
v-if="transverseData.length" | ||
:class="[ | ||
'fr-sidemenu__item', | ||
{ | ||
'fr-sidemenu__item--active': | ||
!route.hash || isActive('#all-pages') | ||
} | ||
]" | ||
> | ||
<a | ||
class="fr-sidemenu__link" | ||
href="#all-pages" | ||
:aria-current=" | ||
route.hash | ||
? isActive('#all-pages') | ||
? 'true' | ||
: undefined | ||
: 'true' | ||
" | ||
>Toutes les pages</a | ||
> | ||
</li> | ||
<li | ||
v-for="page in pagesData" | ||
:key="page.name" | ||
class="fr-sidemenu__item" | ||
:class="{ | ||
'fr-sidemenu__item--active': isActive(`#${page.id}`) | ||
}" | ||
> | ||
<a | ||
class="fr-sidemenu__link" | ||
:href="`#${page.id}`" | ||
:aria-current="isActive(`#${page.id}`) ? 'true' : undefined" | ||
> | ||
{{ page.name }} | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</nav> | ||
<slot name="filter" /> | ||
</div> | ||
|
||
<div> | ||
<div class="fr-mb-6w header"> | ||
<div role="alert" aria-live="polite"> | ||
<p class="fr-mb-0 fr-text--xl fr-text--bold"> | ||
{{ dataCount }} | ||
{{ pluralize("résultat", "résultats", dataCount) }} | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<slot v-if="transverseData.length" name="transverse-data" /> | ||
|
||
<slot name="pages-data" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.header { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
gap: 1rem; | ||
} | ||
.main { | ||
display: grid; | ||
grid-template-columns: 20rem 1fr; | ||
gap: 2rem; | ||
} | ||
.sidebar { | ||
box-shadow: inset -1px 0 0 0 var(--border-default-grey); | ||
} | ||
.page-title { | ||
color: var(--text-active-blue-france); | ||
} | ||
.page-url { | ||
word-break: break-all; | ||
} | ||
.fr-sidemenu__inner { | ||
box-shadow: none !important; | ||
} | ||
@media (width < 48rem) { | ||
.main { | ||
grid-template-columns: 1fr; | ||
} | ||
.sidebar { | ||
box-shadow: none; | ||
} | ||
} | ||
</style> |
107 changes: 107 additions & 0 deletions
107
confiture-web-app/src/components/report/ReportErrorCriterium.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<script setup lang="ts"> | ||
import { chunk } from "lodash-es"; | ||
import { marked } from "marked"; | ||
import rgaa from "../../criteres.json"; | ||
import { CriterionResultUserImpact, ReportCriteriumResult } from "../../types"; | ||
import { formatStatus, formatUserImpact, getUploadUrl } from "../../utils"; | ||
import CriteriumTestsAccordion from "../audit/CriteriumTestsAccordion.vue"; | ||
import LazyAccordion from "../audit/LazyAccordion.vue"; | ||
import MarkdownRenderer from "../ui/MarkdownRenderer.vue"; | ||
defineProps<{ | ||
error: ReportCriteriumResult; | ||
}>(); | ||
function getCriterium(topicNumber: number, criteriumNumber: number) { | ||
// FIXME: "any everywhere" : The criteria properties of each topic do not have the same signature. See: https://github.com/microsoft/TypeScript/issues/33591#issuecomment-786443978 | ||
const criterium = (rgaa.topics as any) | ||
.find((t: any) => t.number === topicNumber) | ||
?.criteria.find((c: any) => c.criterium.number === criteriumNumber) | ||
.criterium; | ||
return criterium; | ||
} | ||
function getCriteriumTitle(topicNumber: number, criteriumNumber: number) { | ||
return marked.parseInline(getCriterium(topicNumber, criteriumNumber).title); | ||
} | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<p class="fr-text--lg fr-text--bold criterium-title"> | ||
{{ error.topic }}.{{ error.criterium }} | ||
<span v-html="getCriteriumTitle(error.topic, error.criterium)" /> | ||
</p> | ||
|
||
<ul class="fr-badges-group fr-mb-2w"> | ||
<li> | ||
<p class="fr-badge fr-badge--sm fr-badge--error fr-badge--no-icon"> | ||
{{ formatStatus(error.status) }} | ||
</p> | ||
</li> | ||
<li v-if="error.userImpact"> | ||
<p | ||
class="fr-badge fr-badge--sm" | ||
:class="{ | ||
'fr-badge--yellow-moutarde': | ||
error.userImpact === CriterionResultUserImpact.MAJOR, | ||
'fr-badge--error fr-badge--no-icon': | ||
error.userImpact === CriterionResultUserImpact.BLOCKING | ||
}" | ||
> | ||
Impact {{ formatUserImpact(error.userImpact) }} | ||
</p> | ||
</li> | ||
<li v-if="error.quickWin"> | ||
<p class="fr-badge fr-badge--sm">Facile à corriger</p> | ||
</li> | ||
</ul> | ||
|
||
<!-- Error --> | ||
<LazyAccordion | ||
v-if="error.notCompliantComment || error.exampleImages.length > 0" | ||
title="Erreur et recommandation" | ||
data-accordion | ||
> | ||
<MarkdownRenderer | ||
v-if="error.notCompliantComment" | ||
class="fr-mb-3w" | ||
:markdown="error.notCompliantComment" | ||
/> | ||
<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"> | ||
<div | ||
v-for="(line, k) in chunk(error.exampleImages, 2)" | ||
:key="k" | ||
class="fr-grid-row fr-grid-row--gutters" | ||
> | ||
<a | ||
v-for="example in line" | ||
:key="example.key" | ||
class="fr-col-md-6 fr-col-12 image-link" | ||
:href="getUploadUrl(example.key)" | ||
target="_blank" | ||
> | ||
<span class="sr-only"> | ||
Ouvrir l’image dans une nouvelle fenêtre | ||
</span> | ||
<img style="width: 100%" :src="getUploadUrl(example.key)" alt="" /> | ||
</a> | ||
</div> | ||
</div> | ||
</LazyAccordion> | ||
|
||
<!-- Tests --> | ||
<CriteriumTestsAccordion | ||
:topic-number="error.topic" | ||
:criterium="getCriterium(error.topic, error.criterium)" | ||
/> | ||
</div> | ||
</template> |
Oops, something went wrong.