Checkbox.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <!--
  2. Case à cocher
  3. @see https://vuetifyjs.com/en/components/checkboxes/
  4. -->
  5. <template>
  6. <v-container
  7. class="px-0"
  8. fluid
  9. >
  10. <v-checkbox
  11. v-model="data"
  12. :value="data"
  13. :label="$t(label_field)"
  14. :disabled="readonly"
  15. :error="error || !!violation"
  16. :error-messages="errorMessage || violation ? $t(violation) : ''"
  17. @change="onChange($event)"
  18. />
  19. </v-container>
  20. </template>
  21. <script lang="ts">
  22. import {defineComponent, useContext} from '@nuxtjs/composition-api'
  23. import {useError} from "~/composables/form/useError";
  24. export default defineComponent({
  25. props: {
  26. field: {
  27. type: String,
  28. required: false,
  29. default: null
  30. },
  31. label: {
  32. type: String,
  33. required: false,
  34. default: null
  35. },
  36. data: {
  37. type: Boolean,
  38. required: false
  39. },
  40. readonly: {
  41. type: Boolean,
  42. required: false
  43. },
  44. error: {
  45. type: Boolean,
  46. required: false
  47. },
  48. errorMessage: {
  49. type: String,
  50. required: false,
  51. default: null
  52. }
  53. },
  54. setup (props, {emit}) {
  55. const {store} = useContext()
  56. const {violation, onChange} = useError(props.field, emit, store)
  57. return {
  58. label_field: props.label ?? props.field,
  59. violation,
  60. onChange
  61. }
  62. }
  63. })
  64. </script>
  65. <style scoped>
  66. </style>