vikunja-frontend/src/views/list/NewList.vue

87 lines
1.8 KiB
Vue
Raw Normal View History

2018-09-09 21:28:07 +02:00
<template>
<create title="Create a new list" @create="newList()" :create-disabled="list.title === ''">
<div class="field">
<label class="label" for="listTitle">List Title</label>
<div
:class="{ 'is-loading': listService.loading }"
class="control"
>
<input
:class="{ disabled: listService.loading }"
@keyup.enter="newList()"
@keyup.esc="$router.back()"
class="input"
placeholder="The list's title goes here..."
type="text"
name="listTitle"
v-focus
v-model="list.title"
/>
</div>
</div>
2020-06-17 19:10:48 +02:00
<p class="help is-danger" v-if="showError && list.title === ''">
Please specify a title.
</p>
<div class="field">
<label class="label">Color</label>
<div class="control">
<color-picker v-model="list.hexColor" />
</div>
</div>
</create>
2018-09-09 21:28:07 +02:00
</template>
<script>
import ListService from '../../services/list'
import ListModel from '../../models/list'
import Create from '@/components/misc/create'
import ColorPicker from '../../components/input/colorPicker'
2018-09-09 21:28:07 +02:00
export default {
name: 'NewList',
data() {
return {
showError: false,
list: ListModel,
listService: ListService,
}
},
components: {
Create,
ColorPicker,
},
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
}
this.showError = false
this.list.namespaceId = this.$route.params.id
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 },
})
})
.catch((e) => {
this.error(e, this)
})
},
},
}
2018-12-25 16:03:51 +01:00
</script>