SwitchYear.vue 1.7 KB

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