chore: update frontend configuration
This commit is contained in:
@@ -4,13 +4,13 @@
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="relative flex-1">
|
||||
<input
|
||||
type="text"
|
||||
v-model="searchTerm"
|
||||
type="text"
|
||||
class="input input-bordered w-full pr-10"
|
||||
:placeholder="placeholder"
|
||||
@focus="openDropdown = true; ensureOptionsLoaded()"
|
||||
@input="onSearch"
|
||||
/>
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="absolute right-2 top-1/2 -translate-y-1/2 btn btn-ghost btn-xs"
|
||||
@@ -57,11 +57,13 @@
|
||||
|
||||
<dialog class="modal" :class="{ 'modal-open': openCreateModal }">
|
||||
<div class="modal-box">
|
||||
<h3 class="font-bold text-lg mb-4">Nouveau constructeur</h3>
|
||||
<h3 class="font-bold text-lg mb-4">
|
||||
Nouveau constructeur
|
||||
</h3>
|
||||
<form @submit.prevent="handleCreate">
|
||||
<div class="form-control mb-3">
|
||||
<label class="label"><span class="label-text">Nom</span></label>
|
||||
<input v-model="createForm.name" type="text" class="input input-bordered" required />
|
||||
<input v-model="createForm.name" type="text" class="input input-bordered" required>
|
||||
</div>
|
||||
<FieldEmail
|
||||
v-model="createForm.email"
|
||||
@@ -78,9 +80,11 @@
|
||||
/>
|
||||
|
||||
<div class="modal-action">
|
||||
<button type="button" class="btn" @click="closeCreateModal">Annuler</button>
|
||||
<button type="button" class="btn" @click="closeCreateModal">
|
||||
Annuler
|
||||
</button>
|
||||
<button type="submit" class="btn btn-primary" :disabled="creating">
|
||||
<span v-if="creating" class="loading loading-spinner loading-xs mr-2"></span>
|
||||
<span v-if="creating" class="loading loading-spinner loading-xs mr-2" />
|
||||
Créer
|
||||
</button>
|
||||
</div>
|
||||
@@ -100,16 +104,16 @@ import IconLucideChevronsUpDown from '~icons/lucide/chevrons-up-down'
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: null,
|
||||
default: null
|
||||
},
|
||||
label: {
|
||||
type: String,
|
||||
default: '',
|
||||
default: ''
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: 'Sélectionner ou créer un constructeur...',
|
||||
},
|
||||
default: 'Sélectionner ou créer un constructeur...'
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
@@ -131,7 +135,7 @@ const applyOptions = (items = []) => {
|
||||
if (selectedId && !limited.some(item => item.id === selectedId)) {
|
||||
const selected = cloned.find(item => item.id === selectedId)
|
||||
if (selected) {
|
||||
if (limited.length >= 10) limited.pop()
|
||||
if (limited.length >= 10) { limited.pop() }
|
||||
limited.unshift(selected)
|
||||
}
|
||||
}
|
||||
@@ -142,7 +146,7 @@ const applyOptions = (items = []) => {
|
||||
const createForm = ref({
|
||||
name: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
phone: ''
|
||||
})
|
||||
|
||||
const selectedConstructeur = computed(() =>
|
||||
@@ -171,8 +175,8 @@ const ensureOptionsLoaded = async (force = false) => {
|
||||
applyOptions(constructeurs.value)
|
||||
return
|
||||
}
|
||||
if (!force && searchTerm.value === lastSearchTerm && options.value.length) return
|
||||
if (options.value.length && !force) return
|
||||
if (!force && searchTerm.value === lastSearchTerm && options.value.length) { return }
|
||||
if (options.value.length && !force) { return }
|
||||
const result = await searchConstructeurs(searchTerm.value)
|
||||
if (result.success) {
|
||||
applyOptions(result.data || [])
|
||||
@@ -189,7 +193,7 @@ const onSearch = () => {
|
||||
lastSearchTerm = ''
|
||||
return
|
||||
}
|
||||
if (searchTerm.value === lastSearchTerm) return
|
||||
if (searchTerm.value === lastSearchTerm) { return }
|
||||
const result = await searchConstructeurs(searchTerm.value)
|
||||
if (result.success) {
|
||||
applyOptions(result.data || [])
|
||||
@@ -212,8 +216,8 @@ const closeCreateModal = () => {
|
||||
const handleCreate = async () => {
|
||||
creating.value = true
|
||||
const payload = { ...createForm.value }
|
||||
if (!payload.phone) delete payload.phone
|
||||
if (!payload.email) delete payload.email
|
||||
if (!payload.phone) { delete payload.phone }
|
||||
if (!payload.email) { delete payload.email }
|
||||
const result = await createConstructeur(payload)
|
||||
creating.value = false
|
||||
if (result.success) {
|
||||
|
||||
Reference in New Issue
Block a user