|
|
@@ -22,10 +22,15 @@ Barre d'alerte qui s'affiche lorsque l'utilisateur n'est pas sur l'année couran
|
|
|
import {useOrganizationProfileStore} from "~/stores/organizationProfile";
|
|
|
import {ComputedRef} from "@vue/reactivity";
|
|
|
import {useFormStore} from "~/stores/form";
|
|
|
+ import Access from "~/models/Access/Access";
|
|
|
+ import {usePageStore} from "~/stores/page";
|
|
|
+ import {useEntityManager} from "~/composables/data/useEntityManager";
|
|
|
|
|
|
+ const { em } = useEntityManager()
|
|
|
const accessProfile = useAccessProfileStore()
|
|
|
const organizationProfile = useOrganizationProfileStore()
|
|
|
const { setDirty } = useFormStore()
|
|
|
+ const pageStore = usePageStore()
|
|
|
|
|
|
const show: ComputedRef<boolean> = computed(() => {
|
|
|
return (
|
|
|
@@ -37,15 +42,24 @@ Barre d'alerte qui s'affiche lorsque l'utilisateur n'est pas sur l'année couran
|
|
|
})
|
|
|
|
|
|
const resetYear = async () => {
|
|
|
- accessProfile.setHistorical(false, true, false)
|
|
|
-
|
|
|
- if (organizationProfile.currentActivityYear) {
|
|
|
- accessProfile.activityYear = organizationProfile.currentActivityYear
|
|
|
- }
|
|
|
+ const defaultValues = {
|
|
|
+ historical: {
|
|
|
+ "future": false,
|
|
|
+ "past": false,
|
|
|
+ "present": true,
|
|
|
+ },
|
|
|
+ activityYear: organizationProfile.currentActivityYear
|
|
|
+ }
|
|
|
|
|
|
// Il faut ajouter un patch sur le profile ici
|
|
|
setDirty(false)
|
|
|
|
|
|
+ pageStore.loading = true
|
|
|
+ await em.patch(Access, accessProfile.currentAccessId, defaultValues)
|
|
|
+ if (process.server) {
|
|
|
+ // Force profile refresh server side to avoid a bug where server and client stores diverge on profile refresh
|
|
|
+ await em.refreshProfile()
|
|
|
+ }
|
|
|
window.location.reload()
|
|
|
}
|
|
|
</script>
|