Skip to content

Commit

Permalink
feat(DefaultTable): fix card click
Browse files Browse the repository at this point in the history
  • Loading branch information
iNeoO committed Nov 8, 2024
1 parent 171264e commit 65633fe
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ fileignoreconfig:
- filename: packages/shared/src/components/PasswordInput.vue
checksum: af4fe62dc455e943fcfacaa6ee0495e1ab20f9ed2094ad70c457b7a27ab46759
- filename: packages/shared/src/components/Table/DsfrDataTableV2.vue
checksum: eaa191de00bd4bd60de2d9e7e4acd9551018be5bd3e510ea385940f5f450e778
checksum: f7d1a3d6315ed6b5dac684654daee6cca56a704f7dc3eed15f8ca0d1c7255993
- filename: packages/shared/src/components/Table/DsfrDataTableV2Wrapper.vue
checksum: 3d201233abc1aedfe7c755f0c8c2ad79cf5e31a3c20dbdcb1d828d8c8ee27d45
- filename: packages/shared/src/components/Table/dsfrDataTabeV2/DsfrPaginationV2.vue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ import { DsfrDataTableV2Wrapper, ValidationModal } from "@vao/shared";
const demandeSejourStore = useDemandeSejourStore();
const userStore = useUserStore();
const route = useRoute();
const data = computed(() => demandeSejourStore.demandes);
const total = computed(() => demandeSejourStore.total);
const params = Object.fromEntries(new URLSearchParams(window.location.search));
const { query } = route;
const titles = [
{
Expand Down Expand Up @@ -130,40 +131,22 @@ const sortableTitles = titles.flatMap((title) =>
title.options?.isSortable ? [title.key] : [],
);
const defaultStatus = [
demandesSejours.statuts.TRANSMISE,
demandesSejours.statuts.EN_COURS,
demandesSejours.statuts.A_MODIFIER,
demandesSejours.statuts.REFUSEE,
demandesSejours.statuts.ATTENTE_8_JOUR,
demandesSejours.statuts.TRANSMISE_8J,
demandesSejours.statuts.EN_COURS_8J,
demandesSejours.statuts.A_MODIFIER_8J,
demandesSejours.statuts.REFUSEE_8J,
demandesSejours.statuts.VALIDEE_8J,
demandesSejours.statuts.SEJOUR_EN_COURS,
demandesSejours.statuts.TERMINEE,
demandesSejours.statuts.ANNULEE,
demandesSejours.statuts.ABANDONNEE,
];
const idFonctionnelle = ref(params.idFonctionnelle || "");
const libelle = ref(params.libelle || "");
const organisme = ref(params.organisme || "");
const defaultStatus = [...Object.values(demandesSejours.statuts)];
const idFonctionnelle = ref(query.idFonctionnelle ?? "");
const libelle = ref(query.libelle ?? "");
const organisme = ref(query.organisme ?? "");
const status = ref(
params.status
? params.status
query.statuts
? query.statuts
.split(",")
.filter((statut) => Object.values(defaultStatus).includes(statut))
: [],
);
const limit = ref(parseInt(params.limit, 10) || 10);
const offset = ref(parseInt(params.offset, 10) || 0);
const sort = ref(sortableTitles.includes(params.sort) ? params.sort : "");
const limit = ref(parseInt(query.limit, 10) || 10);
const offset = ref(parseInt(query.offset, 10) || 0);
const sort = ref(sortableTitles.includes(query.sort) ? query.sort : "");
const sortDirection = ref(
["", "asc", "desc"].includes(params.sortDirection)
? params.sortDirection
: "",
["", "asc", "desc"].includes(query.sortDirection) ? query.sortDirection : "",
);
const isValidParams = (params) =>
Expand Down Expand Up @@ -207,9 +190,6 @@ const updateData = () => {
? { sortDirection: sortDirection.value }
: {}),
...getSearchParams(),
...(isValidParams(status.value) // we use english for url, but french for api
? { status: status.value.join(",") }
: {}),
},
});
}, 300);
Expand Down Expand Up @@ -254,18 +234,26 @@ const navigate = (state) => {
const validatePriseEnCharge = async () => {
const declarationId = declarationAPrendreEnCharge.value.declarationId;
try {
await demandeSejourStore.prendreEnCharge();
await demandeSejourStore.prendreEnCharge(declarationId);
declarationAPrendreEnCharge.value = null;
navigateTo({
path: `/sejours/${declarationId}`,
});
} catch (error) {
log.w("prend en charge", error);
toaster.error({
titleTag: "h2",
description: "Erreur lors de la prise en charge de la demande",
});
throw error;
}
};
// exposxition to parents
defineExpose({
updateStatus: (value) => {
status.value = value;
updateData();
},
});
</script>
10 changes: 4 additions & 6 deletions packages/frontend-bo/src/pages/sejours/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}})
</h1>
<CardsNumber :values="cards" @click="onClickCards" />
<DemandesSejourDefaultTable />
<DemandesSejourDefaultTable ref="dataTable" />
</div>
</template>

Expand All @@ -21,7 +21,7 @@ definePageMeta({

const sejourStore = useDemandeSejourStore();

const statuts = ref(null);
const dataTable = ref(null);

const cards = computed(() => [
{
Expand Down Expand Up @@ -49,10 +49,8 @@ const cards = computed(() => [
]);

const onStatutSelect = (value) => {
if (value.length) {
statuts.value = value;
} else {
statuts.value = null;
if (dataTable.value) {
dataTable.value.updateStatus(value);
}
};

Expand Down
8 changes: 4 additions & 4 deletions packages/shared/src/components/Table/DsfrDataTableV2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type NestedKeys<T> = {
export type CustomKeys = `custom-${string}`;
export type Title<T> = {
key: NestedKeys<T> | `custom-${string}`;
key: NestedKeys<T> | CustomKeys;
label: string;
options?: {
isFixedLeft?: boolean;
Expand Down Expand Up @@ -83,10 +83,10 @@ const props = withDefaults(
);
const emits = defineEmits<{
"update:sort": [NestedKeys<T>];
"update:sort-direction": ["asc" | "desc"];
"update:sort": [NestedKeys<T> | ""];
"update:sort-direction": ["asc" | "desc" | ""];
"update:selected": [Array<T[RowId]>];
sort: [{ sort: NestedKeys<T>; direction: "asc" | "desc" }];
sort: [{ sort: NestedKeys<T>; direction: "asc" | "desc" | "" }];
}>();
defineSlots<
Expand Down

0 comments on commit 65633fe

Please sign in to comment.