2019-06-02 23:36:07 +01:00
|
|
|
<template>
|
|
|
|
|
<section class="mt-8">
|
|
|
|
|
<h3 class="text-2xl font-semibold mb-4">Submit a Session</h3>
|
|
|
|
|
|
2019-06-04 21:18:13 +01:00
|
|
|
<div v-if="errors.length" class="bg-red-100 border border-red-300 p-4 mb-6">
|
|
|
|
|
<ul class="list-disc list-inside ml-3">
|
2019-06-04 21:27:12 +01:00
|
|
|
<li v-for="error in errors" :key="error.detail">{{ error.detail }}</li>
|
2019-06-04 21:18:13 +01:00
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
|
2019-06-02 23:36:07 +01:00
|
|
|
<form action="" @submit.prevent="submit">
|
|
|
|
|
<label class="block mb-4">
|
|
|
|
|
Title
|
|
|
|
|
<input name="title" type="text" class="w-full border border-gray-400 p-2 mt-1" v-model="form.title" required/>
|
|
|
|
|
</label>
|
|
|
|
|
|
|
|
|
|
<label class="block mb-4">
|
|
|
|
|
Abstract
|
|
|
|
|
<textarea name="title" rows="5" class="w-full border border-gray-400 p-2 mt-1" v-model="form.body" required/>
|
|
|
|
|
</label>
|
|
|
|
|
|
|
|
|
|
<input class="cursor-pointer bg-blue-500 hover:bg-blue-700 focus:bg-blue-700 text-gray-100 px-4 py-2 rounded" type="submit" value="Submit session">
|
|
|
|
|
</form>
|
|
|
|
|
</section>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
2019-06-04 21:18:13 +01:00
|
|
|
errors: [],
|
2019-06-02 23:36:07 +01:00
|
|
|
form: {
|
|
|
|
|
body: '',
|
2019-06-03 00:54:25 +01:00
|
|
|
field_session_status: 'accepted',
|
|
|
|
|
field_session_type: 'full',
|
2019-06-04 21:22:10 +01:00
|
|
|
title: ''
|
2019-06-02 23:36:07 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
submit () {
|
2019-06-03 00:54:25 +01:00
|
|
|
const uuid = '11dad4c2-baa8-4fb2-97c6-12e1ce925806' // User 1
|
2019-06-02 23:50:01 +01:00
|
|
|
|
2019-06-03 00:54:25 +01:00
|
|
|
const data = {
|
|
|
|
|
type: 'node--session',
|
|
|
|
|
attributes: this.form,
|
|
|
|
|
relationships: {
|
2019-06-04 21:27:12 +01:00
|
|
|
'field_speakers': {
|
|
|
|
|
'data': {
|
|
|
|
|
'id': uuid,
|
|
|
|
|
'type': 'user--user'
|
2019-06-03 00:54:25 +01:00
|
|
|
}
|
2019-06-04 21:27:12 +01:00
|
|
|
}
|
2019-06-03 00:54:25 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-04 21:27:12 +01:00
|
|
|
const baseUrl = 'http://drupaltestcamp.docksal'
|
2019-06-04 21:21:55 +01:00
|
|
|
|
2019-06-03 00:54:25 +01:00
|
|
|
axios({
|
|
|
|
|
method: 'post',
|
2019-06-04 21:21:55 +01:00
|
|
|
url: `${baseUrl}/jsonapi/node/session`,
|
2019-06-03 00:54:25 +01:00
|
|
|
data: { data },
|
|
|
|
|
headers: {
|
|
|
|
|
'Accept': 'application/vnd.api+json',
|
2019-06-04 21:27:12 +01:00
|
|
|
'Content-Type': 'application/vnd.api+json'
|
2019-06-03 00:54:25 +01:00
|
|
|
}
|
|
|
|
|
})
|
2019-06-04 21:23:33 +01:00
|
|
|
.then(response => {
|
2019-06-03 00:54:25 +01:00
|
|
|
this.form.body = ''
|
|
|
|
|
this.form.title = ''
|
2019-06-04 21:23:33 +01:00
|
|
|
})
|
2019-06-04 21:18:13 +01:00
|
|
|
.catch(error => {
|
|
|
|
|
this.errors = error.response.data.errors || []
|
2019-06-03 00:54:25 +01:00
|
|
|
})
|
2019-06-02 23:36:07 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|