101 lines
2.6 KiB
Vue
101 lines
2.6 KiB
Vue
<template>
|
|
<fieldset class="border h-100 bg-white p-3 mb-3">
|
|
<legend>{{ __('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>{{ __('État de visibilité du champs') }}</b>
|
|
</label>
|
|
<br>
|
|
<small class="form-text text-muted">{{ __('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>{{ __('État d\'obligation du champs') }}</b>
|
|
</label>
|
|
<br>
|
|
<small class="form-text text-muted">{{ __('Le champs est obligatoire ou non.') }}</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { defineComponent, PropType } from "vue";
|
|
import trans from "../../modules/trans";
|
|
|
|
export default defineComponent({
|
|
mixins: [trans],
|
|
props: {
|
|
id: {
|
|
type: String,
|
|
default: null,
|
|
},
|
|
model: {
|
|
type: Object as PropType<LaravelModel>,
|
|
default: null,
|
|
},
|
|
},
|
|
data(): {
|
|
intId: string;
|
|
intModel: LaravelModel | null;
|
|
displayRequiredField: boolean;
|
|
} {
|
|
return {
|
|
intId: "",
|
|
intModel: null,
|
|
displayRequiredField: false,
|
|
};
|
|
},
|
|
mounted() {
|
|
const json = String(this.$attrs.json ?? "{}");
|
|
const data = JSON.parse(json);
|
|
this.intId = data.id ?? String(this.id);
|
|
this.intModel = data.model ?? this.model;
|
|
this.$nextTick(() => {
|
|
this.updateVisibleValue();
|
|
});
|
|
},
|
|
methods: {
|
|
updateVisibleValue() {
|
|
const inputVisible = this.$refs.inputVisible as HTMLInputElement;
|
|
this.displayRequiredField = (inputVisible.checked) ? true : false;
|
|
}
|
|
},
|
|
});
|
|
</script>
|