Display new session in the sessions list straight away

This commit is contained in:
Oliver Davies 2019-06-04 22:39:55 +01:00
parent 8454dcaf73
commit c58ebd1751
2 changed files with 9 additions and 1 deletions

View file

@ -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></session-form> <session-form @submitted="addSession($event)"></session-form>
</div> </div>
</div> </div>
</template> </template>
@ -39,6 +39,12 @@ export default {
}) })
}, },
methods: {
addSession: function (session) {
this.sessions.push(session)
}
},
computed: { computed: {
sortedSessions: function () { sortedSessions: function () {
return _(this.sessions).sortBy(session => session.attributes.title) return _(this.sessions).sortBy(session => session.attributes.title)

View file

@ -86,6 +86,8 @@ export default {
this.messages.push(`Session ${title} has been created.`) this.messages.push(`Session ${title} has been created.`)
this.errors = [] this.errors = []
this.$emit('submitted', data.data)
this.form.body = '' this.form.body = ''
this.form.title = '' this.form.title = ''
}) })