teaching.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <LayoutContainer>
  3. <UiLoadingPanel v-if="pending" />
  4. <UiForm
  5. v-else-if="parameters !== null"
  6. :model="Parameters"
  7. :entity="parameters"
  8. action-position="bottom"
  9. >
  10. <LayoutParametersTable
  11. :items="tableItems"
  12. :columns-definitions="[{ property: 'originalLabel' }, { property: 'effectiveLabel' }]"
  13. identifier="value"
  14. :actions="[TABLE_ACTION.EDIT]"
  15. actions-route="/parameters/cycles"
  16. />
  17. <!-- <v-table>-->
  18. <!-- <thead>-->
  19. <!-- <tr>-->
  20. <!-- <td>{{ $t('originalLabel') }}</td>-->
  21. <!-- <td>{{ $t('effectiveLabel') }}</td>-->
  22. <!-- <td>{{ $t('actions') }}</td>-->
  23. <!-- </tr>-->
  24. <!-- </thead>-->
  25. <!-- <tbody>-->
  26. <!-- <tr v-for="enumItem in cycleEnum" :key="enumItem.value">-->
  27. <!-- <td>{{ $t(enumItem.value) }}</td>-->
  28. <!-- <td class="cycle-editable-cell">-->
  29. <!-- {{-->
  30. <!-- orderedCycles[enumItem.value]-->
  31. <!-- ? orderedCycles[enumItem.value].label-->
  32. <!-- : $t(enumItem.value)-->
  33. <!-- }}-->
  34. <!-- </td>-->
  35. <!-- <td style="max-width: 24px">-->
  36. <!-- <v-btn-->
  37. <!-- v-if="orderedCycles[enumItem.value]"-->
  38. <!-- :flat="true"-->
  39. <!-- icon="fa fa-pen"-->
  40. <!-- class="cycle-edit-icon"-->
  41. <!-- @click="goToCycleEditPage(orderedCycles[enumItem.value].id)"-->
  42. <!-- />-->
  43. <!-- </td>-->
  44. <!-- </tr>-->
  45. <!-- </tbody>-->
  46. <!-- </v-table>-->
  47. <UiInputCheckbox
  48. v-model="parameters.showEducationIsACollectivePractice"
  49. field="showEducationIsACollectivePractice"
  50. label="allow_to_configure_teachings_with_played_instrument_choice"
  51. />
  52. </UiForm>
  53. </LayoutContainer>
  54. </template>
  55. <script setup lang="ts">
  56. import type { AsyncData } from '#app'
  57. import type { ComputedRef } from 'vue'
  58. import Parameters from '~/models/Organization/Parameters'
  59. import { useEntityFetch } from '~/composables/data/useEntityFetch'
  60. import Cycle from '~/models/Education/Cycle'
  61. import { useOrganizationProfileStore } from '~/stores/organizationProfile'
  62. import type { AnyJson } from '~/types/data'
  63. import { useEnumFetch } from '~/composables/data/useEnumFetch'
  64. import ApiResource from '~/models/ApiResource'
  65. import {TABLE_ACTION} from '~/types/enum/enums';
  66. definePageMeta({
  67. name: 'parameters_teaching_page',
  68. })
  69. const organizationProfile = useOrganizationProfileStore()
  70. if (organizationProfile.parametersId === null) {
  71. throw new Error('Missing organization parameters id')
  72. }
  73. const { fetch, fetchCollection } = useEntityFetch()
  74. const { fetch: fetchEnum } = useEnumFetch()
  75. const { data: cycleEnum, pending: enumPending } = fetchEnum('education_cycle')
  76. const { data: parameters, pending: parametersPending } = fetch(
  77. Parameters,
  78. organizationProfile.parametersId,
  79. ) as AsyncData<ApiResource | null, Error | null>
  80. const { data: cycles, pending: cyclesPending } = fetchCollection(Cycle)
  81. const pending: ComputedRef<boolean> = computed(
  82. () => enumPending.value || parametersPending.value || cyclesPending.value,
  83. )
  84. const orderedCycles: ComputedRef<AnyJson> = computed(() => {
  85. if (pending.value || cycleEnum.value === null || cycles.value === null) {
  86. return []
  87. }
  88. const orderedCycles: AnyJson = {}
  89. for (const enumItem of cycleEnum.value) {
  90. orderedCycles[enumItem.value] = null
  91. }
  92. for (const cycle of cycles.value.items) {
  93. if (!Object.prototype.hasOwnProperty.call(orderedCycles, cycle.cycleEnum)) {
  94. console.error('Unknown cycle enum : ' + cycle.cycleEnum)
  95. continue
  96. }
  97. orderedCycles[cycle.cycleEnum] = cycle
  98. }
  99. return orderedCycles
  100. })
  101. const tableItems = computed(() => {
  102. return cycleEnum.value?.map((item) => {
  103. return {
  104. value: item.value,
  105. originalLabel: item.label,
  106. effectiveLabel: item.label
  107. }
  108. }) || []
  109. })
  110. </script>
  111. <style scoped lang="scss">
  112. .v-table {
  113. width: 100%;
  114. max-width: 800px;
  115. thead {
  116. td {
  117. border-bottom: thin solid rgba(var(--v-border-color), var(--v-border-opacity));
  118. }
  119. }
  120. }
  121. .cycle-edit-icon {
  122. color: rgb(var(--v-theme-neutral-strong));
  123. }
  124. :deep(.cycle-edit-icon .v-icon) {
  125. font-size: 18px;
  126. }
  127. </style>