SwitchYear.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <!--
  2. Switch year bar
  3. Barre d'alerte qui s'affiche lorsque l'utilisateur n'est pas sur l'année courante.
  4. -->
  5. <template>
  6. <!-- TODO : fonctionnement à valider -->
  7. <UiSystemBar v-if="show" class="theme-warning">
  8. {{$t('not_current_year')}}
  9. <a @click="resetYear" class="text-decoration-none on-warning" style="cursor: pointer;">
  10. &nbsp;<strong>{{$t('not_current_year_reset')}}</strong>
  11. </a>
  12. </UiSystemBar>
  13. </template>
  14. <script setup lang="ts">
  15. import {useAccessProfileStore} from "~/stores/accessProfile";
  16. import {useOrganizationProfileStore} from "~/stores/organizationProfile";
  17. import {ComputedRef} from "@vue/reactivity";
  18. import {useFormStore} from "~/stores/form";
  19. const accessProfile = useAccessProfileStore()
  20. const organizationProfile = useOrganizationProfileStore()
  21. const { setDirty } = useFormStore()
  22. const show: ComputedRef<boolean> = computed(() => {
  23. return (
  24. accessProfile.historical.past || accessProfile.historical.future ||
  25. (accessProfile.historical.dateStart && accessProfile.historical.dateStart.length > 0) ||
  26. (accessProfile.historical.dateEnd && accessProfile.historical.dateEnd.length > 0) ||
  27. accessProfile.activityYear !== organizationProfile.currentActivityYear
  28. )
  29. })
  30. const resetYear = async () => {
  31. accessProfile.setHistorical(false, true, false)
  32. if (organizationProfile.currentActivityYear) {
  33. accessProfile.activityYear = organizationProfile.currentActivityYear
  34. }
  35. // Il faut ajouter un patch sur le profile ici
  36. setDirty(false)
  37. window.location.reload()
  38. }
  39. </script>
  40. <style scoped lang="scss">
  41. .v-system-bar {
  42. font-size: 14px;
  43. }
  44. .v-icon {
  45. height: 20px;
  46. margin: 0 6px;
  47. }
  48. </style>