2018-09-09 21:28:07 +02:00
|
|
|
<template>
|
2018-12-25 16:03:51 +01:00
|
|
|
<div class="fullpage">
|
2020-09-05 22:35:52 +02:00
|
|
|
<a @click="back()" class="close">
|
2018-12-25 16:03:51 +01:00
|
|
|
<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">
|
2020-09-05 22:35:52 +02:00
|
|
|
<p :class="{ 'is-loading': listService.loading}" class="control is-expanded">
|
|
|
|
<input
|
2020-03-04 20:27:27 +01:00
|
|
|
:class="{ 'disabled': listService.loading}"
|
2020-09-05 22:35:52 +02:00
|
|
|
@keyup.enter="newList()"
|
2020-03-04 20:27:27 +01:00
|
|
|
@keyup.esc="back()"
|
2020-09-05 22:35:52 +02:00
|
|
|
class="input"
|
|
|
|
placeholder="The list's name goes here..."
|
|
|
|
type="text"
|
|
|
|
v-focus
|
|
|
|
v-model="list.title"/>
|
2020-03-04 20:27:27 +01:00
|
|
|
</p>
|
|
|
|
<p class="control">
|
2021-01-17 18:57:57 +01:00
|
|
|
<x-button
|
|
|
|
:disabled="list.title === ''"
|
|
|
|
@click="newList()"
|
|
|
|
icon="plus"
|
|
|
|
:shadow="false"
|
|
|
|
>
|
2020-03-04 20:27:27 +01:00
|
|
|
Add
|
2021-01-17 18:57:57 +01:00
|
|
|
</x-button>
|
2020-03-04 20:27:27 +01:00
|
|
|
</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>
|
2020-09-05 22:35:52 +02:00
|
|
|
import router from '../../router'
|
|
|
|
import ListService from '../../services/list'
|
|
|
|
import ListModel from '../../models/list'
|
|
|
|
import {IS_FULLPAGE} from '@/store/mutation-types'
|
2018-09-09 21:28:07 +02:00
|
|
|
|
2020-09-05 22:35:52 +02:00
|
|
|
export default {
|
|
|
|
name: 'NewList',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
showError: false,
|
|
|
|
list: ListModel,
|
|
|
|
listService: ListService,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.list = new ListModel()
|
|
|
|
this.listService = new ListService()
|
|
|
|
this.$store.commit(IS_FULLPAGE, true)
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.setTitle('Create a new list')
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
newList() {
|
|
|
|
if (this.list.title === '') {
|
|
|
|
this.showError = true
|
|
|
|
return
|
2019-03-02 11:25:10 +01:00
|
|
|
}
|
2020-09-05 22:35:52 +02:00
|
|
|
this.showError = false
|
|
|
|
|
|
|
|
this.list.namespaceId = this.$route.params.id
|
2020-11-12 19:59:32 +01:00
|
|
|
this.$store.dispatch('lists/createList', this.list)
|
|
|
|
.then(r => {
|
2020-09-05 22:35:52 +02:00
|
|
|
this.success({message: 'The list was successfully created.'}, this)
|
2020-11-12 19:59:32 +01:00
|
|
|
router.push({name: 'list.index', params: {listId: r.id}})
|
2020-09-05 22:35:52 +02:00
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
this.error(e, this)
|
|
|
|
})
|
2019-03-02 11:25:10 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
back() {
|
|
|
|
router.go(-1)
|
2020-07-07 22:07:13 +02:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
}
|
2018-12-25 16:03:51 +01:00
|
|
|
</script>
|