Skip to content

Commit

Permalink
fix spacing + get id of transverse page
Browse files Browse the repository at this point in the history
  • Loading branch information
bellangerq committed Sep 13, 2024
1 parent 60a4cbe commit b4e512b
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 36 deletions.
4 changes: 2 additions & 2 deletions confiture-web-app/src/components/audit/AraTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useUniqueId } from "../../composables/useUniqueId";
import LayoutIcon from "../icons/LayoutIcon.vue";
const props = defineProps<{
tabs: { label: string; data: T; isTransverse?: boolean }[];
tabs: { label: string; data: T }[];
stickyTop: string;
}>();
Expand Down Expand Up @@ -81,7 +81,7 @@ watch(currentTab, (currentTab) => {
@keydown.home.prevent="selectFirstTab"
@keydown.end.prevent="selectLastTab"
>
<LayoutIcon v-if="tab.isTransverse" class="fr-mr-2v" />
<LayoutIcon v-if="i === 0" class="fr-mr-2v" />
{{ tab.label }}
</button>
</li>
Expand Down
35 changes: 22 additions & 13 deletions confiture-web-app/src/components/audit/AuditGenerationCriterium.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,35 @@ const result = computed(
)!
);
const transversePageId = computed(() => {
return auditStore.currentAudit?.transverseElementsPage.id;
});
const transverseStatus = computed((): CriteriumResultStatus | null => {
if (store.data) {
return store.data?.[-1][props.topicNumber][props.criterium.number].status;
if (store.data && transversePageId.value) {
return store.data?.[transversePageId.value][props.topicNumber][
props.criterium.number
].status;
}
return null;
});
const transverseComment = computed((): string | null => {
if (store.data) {
if (store.data && transversePageId.value) {
switch (transverseStatus.value) {
case CriteriumResultStatus.COMPLIANT:
return store.data?.[-1][props.topicNumber][props.criterium.number]
.compliantComment;
return store.data?.[transversePageId.value][props.topicNumber][
props.criterium.number
].compliantComment;
case CriteriumResultStatus.NOT_COMPLIANT:
return store.data?.[-1][props.topicNumber][props.criterium.number]
.notCompliantComment;
return store.data?.[transversePageId.value][props.topicNumber][
props.criterium.number
].notCompliantComment;
case CriteriumResultStatus.NOT_APPLICABLE:
return store.data?.[-1][props.topicNumber][props.criterium.number]
.notApplicableComment;
return store.data?.[transversePageId.value][props.topicNumber][
props.criterium.number
].notApplicableComment;
default:
return null;
}
Expand Down Expand Up @@ -236,7 +245,7 @@ const isOffline = useIsOffline();
</div>

<!-- STATUS -->
<div class="fr-ml-6w fr-mb-1w criterium-radios-container">
<div class="fr-ml-6w fr-mb-2w criterium-radios-container">
<RadioGroup
:disabled="isOffline"
:model-value="result.status"
Expand All @@ -251,14 +260,14 @@ const isOffline = useIsOffline();
<!-- TRANSVERSE STATUS -->
<div
v-if="
page.id !== -1 &&
page.id !== transversePageId &&
transverseStatus &&
transverseStatus !== CriteriumResultStatus.NOT_TESTED
"
class="fr-ml-5w fr-mb-2w fr-p-1w"
class="fr-ml-5w fr-mb-4w fr-p-1w"
:class="{ 'criterium-transverse-is-open': showTransverseComment }"
>
<div class="fr-mb-9v criterium-transverse-notice">
<div class="criterium-transverse-notice">
<span class="fr-icon-information-line fr-icon--sm" aria-hidden="true" />
<p class="fr-text--sm fr-m-0">
Vous avez déjà évalué ce critère à
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed } from "vue";
import { useFiltersStore } from "../../store";
import { useAuditStore, useFiltersStore } from "../../store";
import { AuditPage } from "../../types";
import TopLink from "../ui/TopLink.vue";
import AuditGenerationCriterium from "./AuditGenerationCriterium.vue";
Expand All @@ -13,6 +13,11 @@ defineProps<{
}>();
const store = useFiltersStore();
const auditStore = useAuditStore();
const transversePageId = computed(() => {
return auditStore.currentAudit?.transverseElementsPage.id;
});
const noResults = computed(() => {
if (store.hasNoResultsFromEvaluated) {
Expand Down Expand Up @@ -45,7 +50,7 @@ const noResults = computed(() => {

<template>
<!-- TODO: handle empty state -->
<div v-if="page.id !== -1" class="fr-mb-2w page-url">
<div v-if="page.id !== transversePageId" class="fr-mb-2w page-url">
<a class="fr-link fr-link--sm" :href="page.url" target="_blank">
{{ page.url }} <span class="fr-sr-only">(nouvelle fenêtre)</span>
</a>
Expand Down
7 changes: 2 additions & 5 deletions confiture-web-app/src/components/audit/AuditSettingsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const accountStore = useAccountStore();
const auditType = ref(props.audit?.auditType);
const procedureName = ref(props.audit?.procedureName);
const pages = ref(props.audit?.pages.slice(1));
const pages = ref(props.audit?.pages);
const auditorEmail = ref(props.audit?.auditorEmail);
const auditorName = ref(props.audit?.auditorName ?? "");
Expand All @@ -80,10 +80,7 @@ function onSubmit() {
emit("submit", {
auditType: auditType.value!,
procedureName: procedureName.value,
pages: [
props.audit.pages[0],
...pages.value.map((p) => ({ ...p, url: p.url }))
],
pages: pages.value.map((p) => ({ ...p, url: p.url })),
auditorName: auditorName.value,
auditorEmail: formatEmail(auditorEmail.value)
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ const isOffline = useIsOffline();
const auditStore = useAuditStore();
const transversePageId = computed(() => {
return auditStore.currentAudit?.transverseElementsPage.id;
});
const title = computed(() => {
return `Point d’amélioration${
auditStore.currentPageId === -1 ? " sur toutes les pages" : ""
auditStore.currentPageId === transversePageId.value
? " sur toutes les pages"
: ""
}`;
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ const isOffline = useIsOffline();
const auditStore = useAuditStore();
const transversePageId = computed(() => {
return auditStore.currentAudit?.transverseElementsPage.id;
});
const title = computed(() => {
return `Commentaire${
auditStore.currentPageId === -1 ? " sur toutes les pages" : ""
auditStore.currentPageId === transversePageId.value
? " sur toutes les pages"
: ""
}`;
});
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref } from "vue";
import { computed, ref } from "vue";
import { useIsOffline } from "../../composables/useIsOffline";
import { FileErrorMessage } from "../../enums";
Expand Down Expand Up @@ -94,13 +94,19 @@ function lazyAccordionOpened() {
hasJustBeenSetAsNotCompliant = false;
}
const auditStore = useAuditStore();
const transversePageId = computed(() => {
return auditStore.currentAudit?.transverseElementsPage.id;
});
</script>

<template>
<LazyAccordion
ref="lazyAccordionRef"
:title="`Erreur et recommandation${
auditStore.currentPageId === -1 ? ' sur toutes les pages' : ''
auditStore.currentPageId === transversePageId
? ' sur toutes les pages'
: ''
}`"
disclose-color="var(--background-default-grey)"
@opened="lazyAccordionOpened"
Expand All @@ -109,7 +115,7 @@ const auditStore = useAuditStore();
<div class="fr-input-group fr-mb-1w">
<label class="fr-label" :for="`criterum-comment-field-${id}`">
Description des erreurs et recommandations
<template v-if="auditStore.currentPageId === -1">
<template v-if="auditStore.currentPageId === transversePageId">
sur toutes les pages</template
>
</label>
Expand Down
2 changes: 1 addition & 1 deletion confiture-web-app/src/components/report/ReportResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const pageDistributionTableData = {
data: [
["Pages", "Critères conformes", "Critères non conformes"],
...(report.data
? report.data.pageDistributions.slice(1).map((p) => {
? report.data.pageDistributions.map((p) => {
return [
p.name,
Math.round(p.compliant.raw),
Expand Down
21 changes: 13 additions & 8 deletions confiture-web-app/src/pages/audit/AuditGenerationPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,19 @@ const pageTitle = computed(() => {
type TabData = { label: string; data: AuditPage };
const tabsData = computed((): TabData[] => {
return sortBy(
auditStore.currentAudit?.pages.map((p) => ({
label: p.name,
data: p,
isTransverse: p.id === -1
})) ?? [],
(p) => p.data.order
);
const transversePage = auditStore.currentAudit?.transverseElementsPage;
return [
...(transversePage
? [{ label: transversePage?.name, data: transversePage }]
: []),
...sortBy(
auditStore.currentAudit?.pages.map((p) => ({
label: p.name,
data: p
})) ?? [],
(p) => p.data.order
)
];
});
</script>

Expand Down
1 change: 1 addition & 0 deletions confiture-web-app/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface Audit {
// Audit creation
auditType: AuditType;
procedureName: string;
transverseElementsPage: AuditPage;
pages: AuditPage[];
auditorEmail: string;
auditorName: string | null;
Expand Down

0 comments on commit b4e512b

Please sign in to comment.