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>
|
2020-03-04 20:27:27 +01:00
|
|
|
<div class="field is-grouped">
|
|
|
|
<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..."
|
|
|
|
@keyup.esc="back()"
|
|
|
|
@keyup.enter="newList()"/>
|
|
|
|
</p>
|
|
|
|
<p class="control">
|
2020-06-17 19:10:48 +02:00
|
|
|
<button class="button is-success noshadow" @click="newList()" :disabled="list.title === ''">
|
2018-09-09 21:28:07 +02:00
|
|
|
<span class="icon is-small">
|
|
|
|
<icon icon="plus"/>
|
|
|
|
</span>
|
2020-03-04 20:27:27 +01:00
|
|
|
Add
|
|
|
|
</button>
|
|
|
|
</p>
|
|
|
|
</div>
|
2020-06-17 19:10:48 +02:00
|
|
|
<p class="help is-danger" v-if="showError && list.title === ''">
|
|
|
|
Please specify a title.
|
2020-03-04 20:27:27 +01:00
|
|
|
</p>
|
2018-09-09 21:28:07 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-03-02 11:25:10 +01:00
|
|
|
import router from '../../router'
|
|
|
|
import ListService from '../../services/list'
|
|
|
|
import ListModel from '../../models/list'
|
2020-05-08 20:43:51 +02:00
|
|
|
import {IS_FULLPAGE} from '../../store/mutation-types'
|
2018-09-09 21:28:07 +02:00
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
export default {
|
|
|
|
name: "NewList",
|
|
|
|
data() {
|
|
|
|
return {
|
2020-03-04 20:27:27 +01:00
|
|
|
showError: false,
|
2019-03-02 11:25:10 +01:00
|
|
|
list: ListModel,
|
|
|
|
listService: ListService,
|
|
|
|
}
|
|
|
|
},
|
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()
|
2020-05-08 20:43:51 +02:00
|
|
|
this.$store.commit(IS_FULLPAGE, true)
|
2018-12-25 16:03:51 +01:00
|
|
|
},
|
2020-07-07 22:07:13 +02:00
|
|
|
mounted() {
|
|
|
|
this.setTitle('Create a new list')
|
|
|
|
},
|
2019-03-02 11:25:10 +01:00
|
|
|
methods: {
|
|
|
|
newList() {
|
2020-06-17 19:10:48 +02:00
|
|
|
if (this.list.title === '') {
|
2020-03-04 20:27:27 +01:00
|
|
|
this.showError = true
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.showError = false
|
|
|
|
|
2020-04-17 12:19:53 +02:00
|
|
|
this.list.namespaceId = this.$route.params.id
|
2019-03-02 11:25:10 +01:00
|
|
|
this.listService.create(this.list)
|
|
|
|
.then(response => {
|
2020-05-08 20:43:51 +02:00
|
|
|
response.namespaceId = this.list.namespaceId
|
|
|
|
this.$store.commit('namespaces/addListToNamespace', response)
|
2020-01-30 22:47:08 +01:00
|
|
|
this.success({message: 'The list was successfully created.'}, this)
|
2020-04-30 12:49:42 +02:00
|
|
|
router.push({name: 'list.index', params: {listId: response.id}})
|
2019-03-02 11:25:10 +01:00
|
|
|
})
|
|
|
|
.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>
|