frontend: fix create-site form refs
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
<span class="label-text">Nom du site</span>
|
<span class="label-text">Nom du site</span>
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
v-model="form.name"
|
v-model="siteName"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Ex: Usine principale"
|
placeholder="Ex: Usine principale"
|
||||||
class="input input-bordered"
|
class="input input-bordered"
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<SiteContactFormFields :form="props.site" />
|
<SiteContactFormFields :form="siteRef" />
|
||||||
|
|
||||||
<div class="modal-action">
|
<div class="modal-action">
|
||||||
<button type="button" class="btn" @click="emit('close')">
|
<button type="button" class="btn" @click="emit('close')">
|
||||||
@@ -31,22 +31,39 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { toRefs } from 'vue'
|
import { computed, toRef } from 'vue'
|
||||||
|
import type { PropType } from 'vue'
|
||||||
import SiteContactFormFields from '~/components/sites/SiteContactFormFields.vue'
|
import SiteContactFormFields from '~/components/sites/SiteContactFormFields.vue'
|
||||||
|
|
||||||
|
type SiteForm = {
|
||||||
|
name: string
|
||||||
|
contactName: string
|
||||||
|
contactPhone: string
|
||||||
|
contactAddress: string
|
||||||
|
contactPostalCode: string
|
||||||
|
contactCity: string
|
||||||
|
}
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
visible: {
|
visible: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
site: {
|
site: {
|
||||||
type: Object,
|
type: Object as PropType<SiteForm>,
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['close', 'submit'])
|
const emit = defineEmits(['close', 'submit'])
|
||||||
|
|
||||||
const form = toRefs(props.site)
|
const siteRef = toRef(props, 'site')
|
||||||
|
|
||||||
|
const siteName = computed({
|
||||||
|
get: () => siteRef.value.name,
|
||||||
|
set: (value: string) => {
|
||||||
|
siteRef.value.name = value
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user