ActivityYear.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. v-on:update="updateActivityYear">
  9. <template v-slot:xeditable.read="{inputValue}">
  10. <v-icon aria-hidden="false" class="ot_green--text" x-small>fas fa-edit</v-icon>
  11. <strong class="ot_green--text"> {{inputValue}} <span v-if="yearPlusOne">/ {{ parseInt(inputValue) + 1}}</span></strong>
  12. </template>
  13. </UiXeditableText>
  14. </main>
  15. </template>
  16. <script lang="ts">
  17. import {defineComponent, useContext} from '@nuxtjs/composition-api'
  18. import {$useActivityYearUpdater} from "~/use/updater/useActivityYearUpdater";
  19. import {$organizationProfile} from "~/services/profile/organizationProfile";
  20. import {$useDirtyForm} from "~/use/form/useDirtyForm";
  21. export default defineComponent({
  22. setup() {
  23. const {store, $dataPersister} = useContext()
  24. const {updater, activityYear} = $useActivityYearUpdater(store, $dataPersister)
  25. const {markFormAsNotDirty} = $useDirtyForm(store)
  26. const organizationProfile = $organizationProfile(store);
  27. let yearPlusOne = !organizationProfile.isManagerProduct()
  28. const label = organizationProfile.isSchool() ? 'schooling_year' : organizationProfile.isArtist() ? 'season_year' : 'cotisation_year'
  29. const updateActivityYear = async (newDate:number) =>{
  30. markFormAsNotDirty()
  31. await updater(newDate)
  32. console.log('1')
  33. setTimeout(()=>window.location.reload(), 0)
  34. }
  35. return {
  36. activityYear,
  37. label,
  38. yearPlusOne,
  39. updateActivityYear
  40. }
  41. }
  42. })
  43. </script>
  44. <style lang="scss">
  45. .activity-year-input{
  46. max-height: 20px;
  47. input{
  48. font-size: 14px;
  49. width: 55px !important;
  50. }
  51. }
  52. </style>