2018-09-09 21:28:07 +02:00
|
|
|
<template>
|
2018-12-25 16:03:51 +01:00
|
|
|
<div class="fullpage">
|
|
|
|
<a class="close" @click="back()">
|
|
|
|
<icon :icon="['far', 'times-circle']">
|
|
|
|
</icon>
|
|
|
|
</a>
|
2018-09-09 21:28:07 +02:00
|
|
|
<h3>Create a new list</h3>
|
2018-12-25 16:03:51 +01:00
|
|
|
<form @submit.prevent="newList" @keyup.esc="back()">
|
2018-09-09 21:28:07 +02:00
|
|
|
<div class="field is-grouped">
|
2019-03-02 11:25:10 +01:00
|
|
|
<p class="control is-expanded" :class="{ 'is-loading': listService.loading}">
|
|
|
|
<input v-focus class="input" :class="{ 'disabled': listService.loading}" v-model="list.title" type="text" placeholder="The list's name goes here...">
|
2018-09-09 21:28:07 +02:00
|
|
|
</p>
|
|
|
|
<p class="control">
|
2018-12-25 16:03:51 +01:00
|
|
|
<button type="submit" class="button is-success noshadow">
|
2018-09-09 21:28:07 +02:00
|
|
|
<span class="icon is-small">
|
|
|
|
<icon icon="plus"/>
|
|
|
|
</span>
|
|
|
|
Add
|
|
|
|
</button>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-03-02 11:25:10 +01:00
|
|
|
import auth from '../../auth'
|
|
|
|
import router from '../../router'
|
|
|
|
import ListService from '../../services/list'
|
|
|
|
import ListModel from '../../models/list'
|
2018-09-09 21:28:07 +02:00
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
export default {
|
|
|
|
name: "NewList",
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
list: ListModel,
|
|
|
|
listService: ListService,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeMount() {
|
|
|
|
// Check if the user is already logged in, if so, redirect him to the homepage
|
|
|
|
if (!auth.user.authenticated) {
|
|
|
|
router.push({name: 'home'})
|
|
|
|
}
|
|
|
|
},
|
2018-12-25 16:03:51 +01:00
|
|
|
created() {
|
2019-03-02 11:25:10 +01:00
|
|
|
this.list = new ListModel()
|
|
|
|
this.listService = new ListService()
|
2018-12-25 16:03:51 +01:00
|
|
|
this.$parent.setFullPage();
|
|
|
|
},
|
2019-03-02 11:25:10 +01:00
|
|
|
methods: {
|
|
|
|
newList() {
|
|
|
|
this.list.namespaceID = this.$route.params.id
|
|
|
|
this.listService.create(this.list)
|
|
|
|
.then(response => {
|
2018-09-09 21:28:07 +02:00
|
|
|
this.$parent.loadNamespaces()
|
2020-01-30 22:47:08 +01:00
|
|
|
this.success({message: 'The list was successfully created.'}, this)
|
2019-03-02 11:25:10 +01:00
|
|
|
router.push({name: 'showList', params: {id: response.id}})
|
|
|
|
})
|
|
|
|
.catch(e => {
|
2020-01-30 22:47:08 +01:00
|
|
|
this.error(e, this)
|
2019-03-02 11:25:10 +01:00
|
|
|
})
|
|
|
|
},
|
2018-12-25 16:03:51 +01:00
|
|
|
back() {
|
|
|
|
router.go(-1)
|
|
|
|
},
|
2019-03-02 11:25:10 +01:00
|
|
|
}
|
|
|
|
}
|
2018-12-25 16:03:51 +01:00
|
|
|
</script>
|