This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/views/list/NewList.vue

74 lines
1.8 KiB
Vue
Raw Normal View History

2018-09-09 19:28:07 +00:00
<template>
2021-10-17 15:28:44 +00:00
<create-edit :title="$t('list.create.header')" @create="newList()" :primary-disabled="list.title === ''">
<div class="field">
<label class="label" for="listTitle">{{ $t('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="$t('list.create.titlePlaceholder')"
type="text"
name="listTitle"
v-focus
v-model="list.title"
/>
</div>
</div>
2020-06-17 17:10:48 +00:00
<p class="help is-danger" v-if="showError && list.title === ''">
{{ $t('list.create.addTitleRequired') }}
</p>
<div class="field">
<label class="label">{{ $t('list.color') }}</label>
<div class="control">
<color-picker v-model="list.hexColor" />
</div>
</div>
</create-edit>
2018-09-09 19:28:07 +00:00
</template>
2022-02-15 12:07:34 +00:00
<script lang="ts">
import ListService from '../../services/list'
import ListModel from '../../models/list'
import CreateEdit from '@/components/misc/create-edit.vue'
import ColorPicker from '../../components/input/colorPicker'
2018-09-09 19:28:07 +00:00
export default {
name: 'NewList',
data() {
return {
showError: false,
list: new ListModel(),
listService: new ListService(),
}
},
components: {
CreateEdit,
ColorPicker,
},
mounted() {
this.setTitle(this.$t('list.create.header'))
},
methods: {
async newList() {
if (this.list.title === '') {
this.showError = true
return
}
this.showError = false
2021-11-17 17:04:53 +00:00
this.list.namespaceId = parseInt(this.$route.params.namespaceId)
const list = await this.$store.dispatch('lists/createList', this.list)
this.$message.success({message: this.$t('list.create.createdSuccess') })
this.$router.push({
name: 'list.index',
params: { listId: list.id },
})
},
},
}
2018-12-25 15:03:51 +00:00
</script>