2023-10-04 09:30:05 +02:00
|
|
|
<script setup>
|
|
|
|
defineOptions({
|
|
|
|
inheritAttrs: false
|
|
|
|
})
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
modelValue: Boolean,
|
|
|
|
fieldName: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
label: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
labelClass: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
help: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
2023-12-05 11:37:40 +01:00
|
|
|
isIndented: Boolean,
|
|
|
|
isDisabled: Boolean,
|
2023-10-04 09:30:05 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
const emit = defineEmits(['update:modelValue'])
|
|
|
|
const attrs = useAttrs()
|
2023-10-05 14:00:30 +02:00
|
|
|
const model = computed({
|
|
|
|
get() {
|
|
|
|
return props.modelValue;
|
|
|
|
},
|
|
|
|
set(value) {
|
|
|
|
emit("update:modelValue", value);
|
|
|
|
},
|
|
|
|
})
|
2023-10-04 09:30:05 +02:00
|
|
|
|
2023-10-05 14:00:30 +02:00
|
|
|
function toggleModel() {
|
|
|
|
if (attrs['disabled'] != true) {
|
|
|
|
model.value = !model.value
|
2023-10-04 09:30:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2023-12-05 11:37:40 +01:00
|
|
|
<div class="field is-flex">
|
|
|
|
<div v-if="isIndented" class="mx-2 pr-1" :style="{ 'opacity': isDisabled ? '0.5' : '1' }">
|
|
|
|
<FontAwesomeIcon class="has-text-grey" :icon="['fas', 'chevron-right']" transform="rotate-135"/>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<input :id="fieldName" type="checkbox" :name="fieldName" class="is-checkradio is-info" v-model="model" :disabled="isDisabled" />
|
|
|
|
<label tabindex="0" :for="fieldName" class="label" :class="labelClass" v-html="$t(label)" v-on:keypress.space.prevent="toggleModel" />
|
|
|
|
<p class="help" v-html="$t(help)" v-if="help" />
|
|
|
|
</div>
|
2023-10-04 09:30:05 +02:00
|
|
|
</div>
|
|
|
|
</template>
|