POST a session to Drupal
This commit is contained in:
parent
2142da75ff
commit
9bf6b45f09
2 changed files with 33 additions and 11 deletions
src
|
@ -2,7 +2,7 @@
|
||||||
<div id="app" class="antialiased min-h-screen font-sans bg-gray-100 text-black p-12">
|
<div id="app" class="antialiased min-h-screen font-sans bg-gray-100 text-black p-12">
|
||||||
<div class="w-full max-w-2xl mx-auto">
|
<div class="w-full max-w-2xl mx-auto">
|
||||||
<accepted-sessions-list :sessions="sortedSessions" />
|
<accepted-sessions-list :sessions="sortedSessions" />
|
||||||
<session-form @submit="addSession($event)"></session-form>
|
<session-form></session-form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -39,12 +39,6 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
|
||||||
addSession: function (attributes) {
|
|
||||||
this.sessions.push({attributes})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
sortedSessions: function () {
|
sortedSessions: function () {
|
||||||
return _(this.sessions).sortBy(session => {
|
return _(this.sessions).sortBy(session => {
|
||||||
|
|
|
@ -27,17 +27,45 @@ export default {
|
||||||
form: {
|
form: {
|
||||||
body: '',
|
body: '',
|
||||||
title: '',
|
title: '',
|
||||||
field_session_status: 'accepted'
|
field_session_status: 'accepted',
|
||||||
|
field_session_type: 'full',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
submit () {
|
submit () {
|
||||||
this.$emit('submit', _.clone(this.form))
|
const uuid = '11dad4c2-baa8-4fb2-97c6-12e1ce925806' // User 1
|
||||||
|
|
||||||
this.form.body = ''
|
const data = {
|
||||||
this.form.title = ''
|
type: 'node--session',
|
||||||
|
attributes: this.form,
|
||||||
|
relationships: {
|
||||||
|
"field_speakers": {
|
||||||
|
"data": {
|
||||||
|
"type": "user--user",
|
||||||
|
"id": uuid
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
axios({
|
||||||
|
method: 'post',
|
||||||
|
url: 'http://drupaltestcamp.docksal/jsonapi/node/session',
|
||||||
|
data: { data },
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/vnd.api+json',
|
||||||
|
'Content-Type': 'application/vnd.api+json',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(({ data }) => {
|
||||||
|
this.form.body = ''
|
||||||
|
this.form.title = ''
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
console.log(error)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue