fix select defaut value

This commit is contained in:
2020-09-12 08:52:20 +02:00
parent e91671a78f
commit 68cbc950f5
9 changed files with 41 additions and 33 deletions

View File

@@ -37,7 +37,7 @@
<DateTimeField
label="Date de fin"
name="end_date"
required />
@update:field="form.end_date = $event" :errors="errors" />
</div>
<TextAreaField name="description"
label="Description"
@@ -91,7 +91,6 @@ export default {
methods: {
submitForm: function () {
this.form.private = this.checked
console.log(this.form)
// eslint-disable-next-line no-undef
axios.post('/api/events', this.form)

View File

@@ -4,7 +4,7 @@
<form v-else @submit.prevent="submitForm">
<div class="flex justify-between flex-center mb-4">
<router-link to="/memos/" class="btn">Back</router-link>
<button class="btn-primary">Add New Memo</button>
<button type="submit" class="btn-primary">Update Event</button>
</div>
<div class="box">
<InputField name="name"
@@ -26,22 +26,24 @@
required
@update:field="form.location = $event" :errors="errors" />
<SelectorField name="category_id"
v-if="form.category_id"
label="Catégorie"
:options="categories"
class="mr-4"
required
:selected="String(form.category_id)"
:selected="form.category_id"
@update:field="form.category_id = $event" :errors="errors" />
<DateTimeField
class="mr-4"
label="Date de début"
name="start_date"
:selected="form.start_date"
required
@update:field="form.start_date = $event" :errors="errors" />
<DateTimeField
label="Date de fin"
name="end_date"
required />
@update:field="form.end_date = $event" :errors="errors" />
</div>
<TextAreaField name="description"
label="Description"
@@ -103,8 +105,6 @@ export default {
this.form = this.event.data.attributes.data
this.form.description = this.event.data.attributes.data.description
this.form.category_id = this.event.data.attributes.data.category.data.event_category_id
console.log(this.form)
// this.loading = false
})
.catch(errors => {
this.errors = errors.response.data.errors
@@ -113,10 +113,12 @@ export default {
methods: {
submitForm: function () {
this.form.private = this.checked
console.log(this.form)
delete this.form.category
delete this.form.invitations
delete this.form['invitations-with-email']
// eslint-disable-next-line no-undef
axios.patch('/api/events', this.form)
axios.patch('/api/events/' + this.event.data.event_id, this.form)
.then(response => {
this.$router.push(response.data.links.self)
})
@@ -127,7 +129,6 @@ export default {
},
watch: {
checked: function () {
console.log(this.checked, this.form)
this.form.private = this.checked
}
}

View File

@@ -19,13 +19,15 @@
<div v-else class="box">
<div class="flex justify-between flex-wrap">
<h1 class="text-xl text-marine">{{ event.data.attributes.data.name }}</h1>
<h2 class="text-sm text-marine">{{ event.data.attributes.data.location }}</h2>
</div>
<div v-if="event.data.attributes.data.description">{{ event.data.attributes.data.description }}</div>
<div class="flex justify-between">
<span class="mt-auto self-end bg-gray-400 text-white tag">{{ event.data.attributes.data.category.data.attributes.data.name }}</span>
<span class="mt-auto self-end bg-gray-400 text-white tag">{{ event.data.attributes.data.start_date }}</span>
</div>
<h2 class="text-lg text-marine">{{ event.data.attributes.data.location }}</h2>
<div v-if="event.data.attributes.data.description">{{ event.data.attributes.data.description }}</div>
<div class="flex justify-end">
<div>
<span class="mt-auto self-end bg-gray-400 text-white tag">{{ event.data.attributes.data.start_date }}</span>
<span v-if="event.data.attributes.data.end_date" class="mt-auto self-end bg-gray-400 text-white tag">{{ event.data.attributes.data.end_date }}</span>
</div>
</div>
</div>
</div>