SwitchYear.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. <strong class="pl-2 text-neutral-strong">
  11. {{$t('not_current_year_reset')}}
  12. </strong>
  13. </a>
  14. </UiSystemBar>
  15. </template>
  16. <script setup lang="ts">
  17. import {useAccessProfileStore} from "~/stores/accessProfile";
  18. import {useOrganizationProfileStore} from "~/stores/organizationProfile";
  19. import {ComputedRef} from "@vue/reactivity";
  20. import {useFormStore} from "~/stores/form";
  21. const accessProfile = useAccessProfileStore()
  22. const organizationProfile = useOrganizationProfileStore()
  23. const { setDirty } = useFormStore()
  24. const show: ComputedRef<boolean> = computed(() => {
  25. return (
  26. accessProfile.historical.past || accessProfile.historical.future ||
  27. (accessProfile.historical.dateStart && accessProfile.historical.dateStart.length > 0) ||
  28. (accessProfile.historical.dateEnd && accessProfile.historical.dateEnd.length > 0) ||
  29. accessProfile.activityYear !== organizationProfile.currentActivityYear
  30. )
  31. })
  32. const resetYear = async () => {
  33. accessProfile.setHistorical(false, true, false)
  34. if (organizationProfile.currentActivityYear) {
  35. accessProfile.activityYear = organizationProfile.currentActivityYear
  36. }
  37. // Il faut ajouter un patch sur le profile ici
  38. setDirty(false)
  39. window.location.reload()
  40. }
  41. </script>
  42. <style scoped lang="scss">
  43. .v-system-bar {
  44. font-size: 14px;
  45. }
  46. .v-icon {
  47. height: 20px;
  48. margin: 0 6px;
  49. }
  50. #resetLink:hover {
  51. cursor: pointer;
  52. }
  53. </style>