teaching.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <NuxtLayout name="parameters">
  3. <LayoutContainer>
  4. <UiLoadingPanel v-if="pending" />
  5. <UiForm
  6. v-else
  7. :model="Parameters"
  8. :entity="parameters"
  9. >
  10. <v-table>
  11. <thead>
  12. <tr>
  13. <td>{{ $t('originalLabel') }}</td>
  14. <td>{{ $t('effectiveLabel') }}</td>
  15. </tr>
  16. </thead>
  17. <tbody>
  18. <tr v-for="enumItem in cycleEnum">
  19. <td>{{ $t(enumItem.value) }}</td>
  20. <td class="cycle-editable-cell">
  21. {{ orderedCycles[enumItem.value] ? orderedCycles[enumItem.value].label : $t(enumItem.value) }}
  22. </td>
  23. <td style="max-width: 24px;">
  24. <v-btn
  25. v-if="orderedCycles[enumItem.value]"
  26. :flat="true"
  27. icon="fa fa-pen"
  28. class="cycle-edit-icon"
  29. @click="goToCycleEditPage(orderedCycles[enumItem.value].id)"
  30. />
  31. </td>
  32. </tr>
  33. </tbody>
  34. </v-table>
  35. <v-row>
  36. <v-col cols="6">
  37. <UiInputCheckbox
  38. v-model="parameters.showEducationIsACollectivePractice"
  39. field="showEducationIsACollectivePractice"
  40. label="allow_to_configure_teachings_with_played_instrument_choice"
  41. />
  42. </v-col>
  43. </v-row>
  44. </UiForm>
  45. </LayoutContainer>
  46. </NuxtLayout>
  47. </template>
  48. <script setup lang="ts">
  49. import Parameters from "~/models/Organization/Parameters";
  50. import {useEntityFetch} from "~/composables/data/useEntityFetch";
  51. import Cycle from "~/models/Education/Cycle";
  52. import {AsyncData} from "#app";
  53. import {useOrganizationProfileStore} from "~/stores/organizationProfile";
  54. import {AnyJson} from "~/types/data";
  55. import {useEnumFetch} from "~/composables/data/useEnumFetch";
  56. /**
  57. * Disable the default layout, the page will use the layout defined with <NuxtLayout />
  58. * @see https://nuxt.com/docs/guide/directory-structure/layouts#overriding-a-layout-on-a-per-page-basis
  59. */
  60. definePageMeta({
  61. layout: false,
  62. });
  63. const organizationProfile = useOrganizationProfileStore()
  64. if (organizationProfile.parametersId === null) {
  65. throw new Error('Missing organization parameters id')
  66. }
  67. const { fetch, fetchCollection } = useEntityFetch()
  68. const { fetch: fetchEnum } = useEnumFetch()
  69. const { data: cycleEnum, pending: enumPending } = fetchEnum('education_cycle')
  70. const { data: parameters, pending: parametersPending } = fetch(Parameters, organizationProfile.parametersId) as AsyncData<Parameters, Parameters | true>
  71. const { data: cycles, pending: cyclesPending } = fetchCollection(Cycle)
  72. const pending: ComputedRef<boolean> = computed(() => enumPending.value || parametersPending.value || cyclesPending.value)
  73. const orderedCycles: ComputedRef<AnyJson> = computed(() => {
  74. if (pending.value) {
  75. return []
  76. }
  77. let orderedCycles: AnyJson = {}
  78. for (const enumItem of cycleEnum.value) {
  79. orderedCycles[enumItem.value] = null
  80. }
  81. for (const cycle of cycles.value.items) {
  82. if (!orderedCycles.hasOwnProperty(cycle.cycleEnum)) {
  83. console.error('Unknown cycle enum : ' + cycle.cycleEnum)
  84. continue
  85. }
  86. orderedCycles[cycle.cycleEnum] = cycle
  87. }
  88. return orderedCycles
  89. })
  90. const goToCycleEditPage = (id: number) => {
  91. navigateTo(`parameters/cycles/${id}`)
  92. }
  93. </script>
  94. <style scoped lang="scss">
  95. .cycle-edit-icon {
  96. color: rgb(var(--v-theme-primary));
  97. }
  98. :deep(.cycle-edit-icon .v-icon) {
  99. font-size: 18px;
  100. }
  101. </style>