ActivityYear.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <main class="d-flex">
  3. <span class="mr-2 ot_dark_grey--text font-weight-bold">{{ $t(label) }} : </span>
  4. <UiXeditableText
  5. class="activity-year-input"
  6. type="number"
  7. :data="activityYear"
  8. @update="updateActivityYear"
  9. >
  10. <template #xeditable.read="{inputValue}">
  11. <v-icon aria-hidden="false" class="ot_green--text" x-small>
  12. fas fa-edit
  13. </v-icon>
  14. <strong class="ot_green--text"> {{ inputValue }} <span v-if="yearPlusOne">/ {{ parseInt(inputValue) + 1 }}</span></strong>
  15. </template>
  16. </UiXeditableText>
  17. </main>
  18. </template>
  19. <script lang="ts">
  20. import { defineComponent, useContext } from '@nuxtjs/composition-api'
  21. import { useMyProfile } from '~/composables/data/useMyProfile'
  22. import { $organizationProfile } from '~/services/profile/organizationProfile'
  23. import { $useForm } from '~/composables/form/useForm'
  24. export default defineComponent({
  25. setup () {
  26. const { store } = useContext()
  27. const { updateMyProfile, setActivityYear, activityYear } = useMyProfile()
  28. const { markFormAsNotDirty } = $useForm()
  29. const organizationProfile = $organizationProfile(store)
  30. const yearPlusOne:boolean = !organizationProfile.isManagerProduct()
  31. const label:string = organizationProfile.isSchool() ? 'schooling_year' : organizationProfile.isArtist() ? 'season_year' : 'cotisation_year'
  32. const updateActivityYear = async (newDate:number) => {
  33. markFormAsNotDirty()
  34. setActivityYear(newDate)
  35. await updateMyProfile()
  36. window.location.reload()
  37. }
  38. return {
  39. activityYear,
  40. label,
  41. yearPlusOne,
  42. updateActivityYear
  43. }
  44. }
  45. })
  46. </script>
  47. <style lang="scss">
  48. .activity-year-input{
  49. max-height: 20px;
  50. input{
  51. font-size: 14px;
  52. width: 55px !important;
  53. }
  54. }
  55. </style>