FormSelect.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <script setup>
  2. const props = defineProps({
  3. modelValue: [String, Number, Boolean],
  4. label: {
  5. type: String,
  6. default: ''
  7. },
  8. fieldName: {
  9. type: String,
  10. default: '',
  11. required: true
  12. },
  13. fieldError: [String],
  14. options: {
  15. type: Array,
  16. required: true
  17. },
  18. help: {
  19. type: String,
  20. default: ''
  21. },
  22. isIndented: Boolean,
  23. isDisabled: Boolean,
  24. })
  25. const selected = ref(props.modelValue)
  26. </script>
  27. <template>
  28. <div class="field is-flex">
  29. <div v-if="isIndented" class="mx-2 pr-1" :style="{ 'opacity': isDisabled ? '0.5' : '1' }">
  30. <FontAwesomeIcon class="has-text-grey" :icon="['fas', 'chevron-right']" transform="rotate-135"/>
  31. </div>
  32. <div>
  33. <label class="label" v-html="$t(label)" :style="{ 'opacity': isDisabled ? '0.5' : '1' }"></label>
  34. <div class="control">
  35. <div class="select">
  36. <select v-model="selected" v-on:change="$emit('update:modelValue', $event.target.value)" :disabled="isDisabled">
  37. <option v-for="option in options" :value="option.value">{{ $t(option.text) }}</option>
  38. </select>
  39. </div>
  40. </div>
  41. <FieldError v-if="fieldError != undefined" :error="fieldError" :field="fieldName" />
  42. <p class="help" v-html="$t(help)" v-if="help"></p>
  43. </div>
  44. </div>
  45. </template>