94 lines
2.6 KiB
Vue
94 lines
2.6 KiB
Vue
<template>
|
|
<fieldset class="border h-100 bg-white p-3 mb-3">
|
|
<legend>{{ trans.methods.__('Spécificités') }}</legend>
|
|
<div class="row w-100 mx-auto">
|
|
<div class="col-12 col-md-6">
|
|
<div class="form-check form-switch">
|
|
<input
|
|
@change="updateVisibleValue"
|
|
id="fieldVisible"
|
|
class="form-check-input"
|
|
name="is_visible"
|
|
type="checkbox"
|
|
value="1"
|
|
role="button"
|
|
ref="inputVisible"
|
|
:checked="intModel?.is_visible ? true : false"
|
|
>
|
|
<label
|
|
class="form-check-label"
|
|
for="fieldVisible"
|
|
role="button"
|
|
>
|
|
<b>{{ trans.methods.__('État de visibilité du champs') }}</b>
|
|
</label>
|
|
<br>
|
|
<small class="form-text text-muted">{{ trans.methods.__('Le champs est visible ou non.') }}</small>
|
|
</div>
|
|
</div>
|
|
<div
|
|
v-if="displayRequiredField"
|
|
class="col-12 col-md-6"
|
|
>
|
|
<div class="form-check form-switch">
|
|
<input
|
|
id="fieldRequired"
|
|
class="form-check-input"
|
|
name="required"
|
|
type="checkbox"
|
|
value="1"
|
|
role="button"
|
|
:checked="intModel?.required ? true : false"
|
|
>
|
|
<label
|
|
class="form-check-label"
|
|
for="fieldRequired"
|
|
role="button"
|
|
>
|
|
<b>{{ trans.methods.__('État d\'obligation du champs') }}</b>
|
|
</label>
|
|
<br>
|
|
<small class="form-text text-muted">{{ trans.methods.__('Le champs est obligatoire ou non.') }}</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { ref, onMounted, nextTick, defineProps } from "vue";
|
|
import trans from "./../../modules/trans";
|
|
|
|
defineOptions({
|
|
name: "FormulariesSwitchComponent"
|
|
});
|
|
|
|
const props = defineProps<{
|
|
id?: string;
|
|
model?: LaravelModel | null;
|
|
}>();
|
|
|
|
const inputVisible = ref<HTMLInputElement | null>(null);
|
|
const intId = ref<string>("");
|
|
const intModel = ref<LaravelModel | null>(null);
|
|
const displayRequiredField = ref<boolean>(false);
|
|
|
|
function updateVisibleValue() {
|
|
if (inputVisible.value?.checked) {
|
|
displayRequiredField.value = true;
|
|
} else {
|
|
displayRequiredField.value = false;
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
const json = String((Object(props)["json"] ?? "{}"));
|
|
const data = JSON.parse(json);
|
|
intId.value = data.id ?? String(props.id ?? "");
|
|
intModel.value = data.model ?? props.model ?? null;
|
|
|
|
nextTick(() => {
|
|
updateVisibleValue();
|
|
});
|
|
});
|
|
</script>
|