EditeurCompetence.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div class="editor-panel">
  3. <h3>Modifier une compétence ou préférence</h3>
  4. <div class="actions">
  5. <button class="btn small primary" v-on:click="emitCreationOrder">
  6. <i class="material-icons">create</i>Nouveau
  7. </button>
  8. <button
  9. class="btn small error"
  10. :disabled="competence === undefined"
  11. v-on:click="emitDeleteOrder"
  12. >
  13. <i class="material-icons">delete_forever</i>Supprimer
  14. </button>
  15. </div>
  16. <div class="empty" v-if="competence === undefined">
  17. Veuillez selectioner une ligne du tableau.
  18. </div>
  19. <div class="editor-body" v-else>
  20. <styled-input
  21. class="s3"
  22. label="Identifiant"
  23. id="competence_id"
  24. type="text"
  25. :modelValue="competence.id"
  26. disabled
  27. />
  28. <styled-input
  29. class="s9"
  30. label="Titre"
  31. id="name"
  32. type="text"
  33. :modelValue="competence.name"
  34. @input="inputListener($event, 'name')"
  35. />
  36. <styled-input
  37. label="Description"
  38. id="competence_description"
  39. type="textarea"
  40. :modelValue="competence.description"
  41. @input="inputListener($event, 'description')"
  42. />
  43. <h4 style="margin-top: 0.8rem">Propriétés</h4>
  44. <checkbox
  45. id="competence_isPreference"
  46. label="Préference"
  47. :modelValue="competence.isPreference"
  48. @input="checkboxListener($event, 'isPreference')"
  49. />
  50. <checkbox
  51. id="competence_isTeachable"
  52. label="Apprenable"
  53. :modelValue="competence.isTeachable"
  54. @input="checkboxListener($event, 'isTeachable')"
  55. />
  56. </div>
  57. </div>
  58. </template>
  59. <script lang="ts">
  60. import Competence from "@/models/Competence";
  61. import styledInput from "./input.vue";
  62. import checkbox from "./checkBox.vue";
  63. import { defineComponent, PropType } from "vue";
  64. import { MutationTypes } from "@/store/Mutations";
  65. import "@/assets/css/editor-panel.css";
  66. export default defineComponent({
  67. name: "EditeurCompetence",
  68. components: { styledInput, checkbox },
  69. props: { competence: { type: Object as PropType<Competence> } },
  70. data() {
  71. return {};
  72. },
  73. watch: {},
  74. computed: {},
  75. methods: {
  76. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  77. inputListener(event: any, field: keyof Competence) {
  78. this.updateCompetence(field, event.target.value);
  79. },
  80. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  81. checkboxListener(event: any, field: keyof Competence) {
  82. this.updateCompetence(field, event.target.checked);
  83. },
  84. updateCompetence<K extends keyof Competence>(k: K, value: Competence[K]) {
  85. if (this.competence) {
  86. this.$store.commit(MutationTypes.editConstraint, {
  87. id: this.competence.id,
  88. field: k,
  89. value: value,
  90. });
  91. }
  92. },
  93. emitCreationOrder: function () {
  94. this.$emit("create");
  95. },
  96. emitDeleteOrder: function () {
  97. this.$emit("delete", this.competence);
  98. },
  99. },
  100. });
  101. </script>
  102. <style scoped></style>