2018-09-09 21:28:07 +02:00
|
|
|
<template>
|
2021-01-30 17:17:04 +01:00
|
|
|
<create-edit title="Create a new list" @create="newList()" :create-disabled="list.title === ''">
|
2021-01-21 23:33:16 +01:00
|
|
|
<div class="field">
|
|
|
|
<label class="label" for="listTitle">List Title</label>
|
|
|
|
<div
|
|
|
|
:class="{ 'is-loading': listService.loading }"
|
|
|
|
class="control"
|
|
|
|
>
|
2020-09-05 22:35:52 +02:00
|
|
|
<input
|
2021-01-21 23:33:16 +01:00
|
|
|
:class="{ disabled: listService.loading }"
|
2020-09-05 22:35:52 +02:00
|
|
|
@keyup.enter="newList()"
|
2021-01-21 23:33:16 +01:00
|
|
|
@keyup.esc="$router.back()"
|
2020-09-05 22:35:52 +02:00
|
|
|
class="input"
|
2021-01-21 23:33:16 +01:00
|
|
|
placeholder="The list's title goes here..."
|
2020-09-05 22:35:52 +02:00
|
|
|
type="text"
|
2021-01-21 23:33:16 +01:00
|
|
|
name="listTitle"
|
2020-09-05 22:35:52 +02:00
|
|
|
v-focus
|
2021-01-21 23:33:16 +01:00
|
|
|
v-model="list.title"
|
|
|
|
/>
|
|
|
|
</div>
|
2020-03-04 20:27:27 +01:00
|
|
|
</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>
|
2021-01-21 23:33:16 +01:00
|
|
|
<div class="field">
|
|
|
|
<label class="label">Color</label>
|
|
|
|
<div class="control">
|
|
|
|
<color-picker v-model="list.hexColor" />
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-30 17:17:04 +01:00
|
|
|
</create-edit>
|
2018-09-09 21:28:07 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-09-05 22:35:52 +02:00
|
|
|
import ListService from '../../services/list'
|
|
|
|
import ListModel from '../../models/list'
|
2021-01-30 17:17:04 +01:00
|
|
|
import CreateEdit from '@/components/misc/create-edit'
|
2021-01-21 23:33:16 +01:00
|
|
|
import ColorPicker from '../../components/input/colorPicker'
|
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,
|
|
|
|
}
|
|
|
|
},
|
2021-01-21 23:33:16 +01:00
|
|
|
components: {
|
2021-01-30 17:17:04 +01:00
|
|
|
CreateEdit,
|
2021-01-21 23:33:16 +01:00
|
|
|
ColorPicker,
|
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
created() {
|
|
|
|
this.list = new ListModel()
|
|
|
|
this.listService = new ListService()
|
|
|
|
},
|
|
|
|
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
|
2021-01-21 23:33:16 +01:00
|
|
|
this.$store
|
|
|
|
.dispatch('lists/createList', this.list)
|
|
|
|
.then((r) => {
|
|
|
|
this.success(
|
|
|
|
{ message: 'The list was successfully created.' },
|
|
|
|
this
|
|
|
|
)
|
|
|
|
this.$router.push({
|
|
|
|
name: 'list.index',
|
|
|
|
params: { listId: r.id },
|
|
|
|
})
|
2020-09-05 22:35:52 +02:00
|
|
|
})
|
2021-01-21 23:33:16 +01:00
|
|
|
.catch((e) => {
|
2020-09-05 22:35:52 +02:00
|
|
|
this.error(e, this)
|
|
|
|
})
|
2019-03-02 11:25:10 +01:00
|
|
|
},
|
2020-09-05 22:35:52 +02:00
|
|
|
},
|
|
|
|
}
|
2018-12-25 16:03:51 +01:00
|
|
|
</script>
|