Skip to content

Commit 012556a

Browse files
authored
Masquer une thématique lorsquelle est non applicable sur la page (#1135)
* hide topic criteria if topic is not applicable * focus na switch when setting last topic criterion as na and closing topic section * update e2e test * add topic title in na switch label * improve responsive behaviour of topic header * update wording * update changelog
1 parent 4515f3a commit 012556a

6 files changed

Lines changed: 99 additions & 31 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,17 @@
44

55
<h2 class="fr-sr-only" id="2025">2025</h2>
66

7-
<<<<<<< 1136-message-de-lindicateur-denregistrement-incohérent
8-
### 17/06/2025
7+
### 18/06/2025
98

10-
#### <span aria-hidden="true">🐛</span> Corrections
9+
#### <span aria-hidden="true">🚀</span> Nouvelles fonctionnalités
1110

12-
- Cache le temps relative du dernier enregistrement s’il n’y en a pas ([#1138](https://github.com/DISIC/Ara/pull/1138))
13-
=======
14-
### 18/06/2025
11+
- Cache les critères d’une thématique définie comme "Non applicable" ([#1135](https://github.com/DISIC/Ara/pull/1135))
1512

1613
#### <span aria-hidden="true">🐛</span> Corrections
1714

15+
- Cache le temps relative du dernier enregistrement s’il n’y en a pas ([#1138](https://github.com/DISIC/Ara/pull/1138))
1816
- Corrige la mise en page de la modale "Observations" ([#1133](https://github.com/DISIC/Ara/pull/1133))
1917
- Cache l'onglet Point d'amélioration correctement lorsque les commentaires sont vides ([#1130](https://github.com/DISIC/Ara/pull/1130))
20-
>>>>>>> main
2118

2219
### 28/05/2025
2320

confiture-web-app/src/components/audit/AuditGenerationCriterium.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ function updateResultStatus(status: CriteriumResultStatus) {
218218
});
219219
}
220220
})
221+
.then(() => {
222+
store.lastUpdatedTopic = result.value.topic;
223+
})
221224
.catch(handleUpdateResultError);
222225
}
223226

confiture-web-app/src/components/audit/AuditGenerationPageCriteria.vue

Lines changed: 65 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
<script setup lang="ts">
2-
import { computed } from "vue";
2+
import { computed, ref, watch } from "vue";
33
4-
import { useAuditStore, useFiltersStore } from "../../store";
4+
import { useAuditStore, useFiltersStore, useResultsStore } from "../../store";
55
import { AuditPage } from "../../types";
66
import TopLink from "../ui/TopLink.vue";
77
import AuditGenerationCriterium from "./AuditGenerationCriterium.vue";
88
import NotApplicableSwitch from "./NotApplicableSwitch.vue";
99
import TransverseElementsList from "./TransverseElementsList.vue";
1010
11-
defineProps<{
11+
const props = defineProps<{
1212
page: AuditPage;
1313
auditUniqueId: string;
1414
}>();
1515
1616
const store = useFiltersStore();
1717
const auditStore = useAuditStore();
18+
const resultsStore = useResultsStore();
1819
1920
const transversePageId = computed(() => {
2021
return auditStore.currentAudit?.transverseElementsPage.id;
@@ -49,6 +50,26 @@ const noResults = computed(() => {
4950
};
5051
}
5152
});
53+
54+
const notApplicableSwitchRefs = ref<InstanceType<typeof NotApplicableSwitch>[]>(
55+
[]
56+
);
57+
58+
// Focus topic NA switch when setting last topic criterion as NA
59+
watch(
60+
() =>
61+
resultsStore.topicIsNotApplicable(
62+
props.page.id,
63+
resultsStore.lastUpdatedTopic
64+
),
65+
(newValue) => {
66+
if (newValue) {
67+
notApplicableSwitchRefs.value[
68+
resultsStore.lastUpdatedTopic - 1
69+
].focusInput();
70+
}
71+
}
72+
);
5273
</script>
5374

5475
<template>
@@ -72,28 +93,45 @@ const noResults = computed(() => {
7293
<div class="fr-mb-3w topic-header">
7394
<h3
7495
:id="`topic_${topic.number}`"
75-
class="fr-m-0 topic-heading"
96+
:class="[
97+
'fr-m-0 topic-heading',
98+
{
99+
'topic-heading--hidden': resultsStore.topicIsNotApplicable(
100+
page.id,
101+
topic.number
102+
)
103+
}
104+
]"
76105
tabindex="-1"
77106
>
78107
{{ topic.number }}. {{ topic.topic }}
79108
</h3>
80-
<NotApplicableSwitch :page-id="page.id" :topic-number="topic.number" />
81-
</div>
82-
<ol class="fr-p-0 fr-m-0">
83-
<AuditGenerationCriterium
84-
v-for="criterium in topic.criteria"
85-
:key="criterium.criterium.number"
86-
:page="page"
87-
class="fr-mb-3w"
88-
:criterium="criterium.criterium"
109+
<NotApplicableSwitch
110+
ref="notApplicableSwitchRefs"
111+
:page-id="page.id"
89112
:topic-number="topic.number"
90-
:audit-unique-id="auditUniqueId"
113+
:topic-title="topic.topic"
91114
/>
92-
</ol>
93-
94-
<div class="fr-grid-row fr-grid-row--right">
95-
<TopLink target="audit-tabs" />
96115
</div>
116+
<template
117+
v-if="!resultsStore.topicIsNotApplicable(page.id, topic.number)"
118+
>
119+
<ol class="fr-p-0 fr-m-0">
120+
<AuditGenerationCriterium
121+
v-for="criterium in topic.criteria"
122+
:key="criterium.criterium.number"
123+
:page="page"
124+
class="fr-mb-3w"
125+
:criterium="criterium.criterium"
126+
:topic-number="topic.number"
127+
:audit-unique-id="auditUniqueId"
128+
/>
129+
</ol>
130+
131+
<div class="fr-grid-row fr-grid-row--right">
132+
<TopLink target="audit-tabs" />
133+
</div>
134+
</template>
97135
</section>
98136
</template>
99137

@@ -143,11 +181,19 @@ const noResults = computed(() => {
143181
align-items: center;
144182
display: flex;
145183
justify-content: space-between;
146-
flex-wrap: wrap;
184+
gap: 1rem;
185+
186+
@media (width < 62rem) {
187+
flex-wrap: wrap;
188+
}
147189
}
148190
149191
.topic-heading {
150192
color: var(--text-action-high-blue-france);
151193
scroll-margin: 7.5rem;
194+
195+
&.topic-heading--hidden {
196+
color: var(--grey-625-425);
197+
}
152198
}
153199
</style>

confiture-web-app/src/components/audit/NotApplicableSwitch.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ import { CriteriumResultStatus } from "../../types";
99
const props = defineProps<{
1010
pageId: number;
1111
topicNumber: number;
12+
topicTitle: string;
1213
}>();
1314
15+
defineExpose({ focusInput });
16+
1417
const isOffline = useIsOffline();
1518
1619
const resultsStore = useResultsStore();
@@ -50,18 +53,26 @@ watch(switchValue, (switchValue) => {
5053
resultsStore.revertTopicStatus(uniqueId, props.pageId, props.topicNumber);
5154
}
5255
});
56+
57+
const inputRef = ref<HTMLInputElement>();
58+
59+
function focusInput() {
60+
inputRef.value?.focus();
61+
}
5362
</script>
5463

5564
<template>
5665
<div class="fr-toggle fr-toggle--label-left">
5766
<input
5867
:id="`topic-switch-${topicNumber}`"
68+
ref="inputRef"
5969
v-model="switchValue"
6070
type="checkbox"
6171
class="fr-toggle__input"
6272
:disabled="isOffline"
6373
/>
6474
<label class="fr-toggle__label" :for="`topic-switch-${topicNumber}`">
75+
<span class="fr-sr-only">Thématique {{ topicTitle }}</span>
6576
Non applicable
6677
{{
6778
pageId === transverseElementsPageId

confiture-web-app/src/store/results.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ interface ResultsStoreState {
5454
*/
5555
lastRequestSuccessEnd: number | null;
5656
lastRequestFailed: boolean;
57+
58+
lastUpdatedTopic: number;
5759
}
5860

5961
export const useResultsStore = defineStore("results", {
@@ -64,7 +66,8 @@ export const useResultsStore = defineStore("results", {
6466
previousStatuses: {},
6567
currentRequestCount: 0,
6668
lastRequestSuccessEnd: null,
67-
lastRequestFailed: false
69+
lastRequestFailed: false,
70+
lastUpdatedTopic: 1
6871
};
6972
},
7073

@@ -175,6 +178,17 @@ export const useResultsStore = defineStore("results", {
175178
).length;
176179

177180
return testedCriteria / total;
181+
},
182+
183+
/**
184+
* @returns true if all topic's criteria are NA for a given page.
185+
*/
186+
topicIsNotApplicable() {
187+
return (pageId: number, topic: number) => {
188+
return this.getTopicResults(pageId, topic).every(
189+
(r) => r.status === CriteriumResultStatus.NOT_APPLICABLE
190+
);
191+
};
178192
}
179193
},
180194

cypress/e2e/audit.cy.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,7 @@ describe("Audit", () => {
484484
cy.contains('button[role="tab"]', "Connexion").click();
485485
cy.contains(" Non applicable sur la page").click();
486486

487-
cy.get(".page-url + section fieldset input:checked + label").should(
488-
"have.class",
489-
"grey",
490-
);
487+
cy.get(".topic-heading").should("have.class", "topic-heading--hidden");
491488
});
492489
});
493490

0 commit comments

Comments
 (0)