2021-01-30 16:17:04 +00:00
|
|
|
<template>
|
|
|
|
<create-edit
|
2021-06-23 23:24:57 +00:00
|
|
|
:title="$t('list.edit.header')"
|
2021-01-30 16:17:04 +00:00
|
|
|
primary-icon=""
|
2021-06-23 23:24:57 +00:00
|
|
|
:primary-label="$t('misc.save')"
|
2021-01-30 16:17:04 +00:00
|
|
|
@primary="save"
|
2022-01-04 18:58:06 +00:00
|
|
|
:tertiary="$t('misc.delete')"
|
|
|
|
@tertiary="$router.push({ name: 'list.list.settings.delete', params: { id: $route.params.listId } })"
|
2021-01-30 16:17:04 +00:00
|
|
|
>
|
|
|
|
<div class="field">
|
2021-08-23 17:42:42 +00:00
|
|
|
<label class="label" for="title">{{ $t('list.title') }}</label>
|
2021-01-30 16:17:04 +00:00
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
:class="{ 'disabled': listService.loading}"
|
2021-08-20 15:00:03 +00:00
|
|
|
:disabled="listService.loading || null"
|
2021-01-30 16:17:04 +00:00
|
|
|
@keyup.enter="save"
|
|
|
|
class="input"
|
2021-08-23 17:42:42 +00:00
|
|
|
id="title"
|
2021-06-23 23:24:57 +00:00
|
|
|
:placeholder="$t('list.edit.titlePlaceholder')"
|
2021-01-30 16:17:04 +00:00
|
|
|
type="text"
|
|
|
|
v-focus
|
|
|
|
v-model="list.title"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label
|
|
|
|
class="label"
|
2021-08-23 17:42:42 +00:00
|
|
|
for="identifier"
|
2021-06-23 23:24:57 +00:00
|
|
|
v-tooltip="$t('list.edit.identifierTooltip')">
|
|
|
|
{{ $t('list.edit.identifier') }}
|
2021-01-30 16:17:04 +00:00
|
|
|
</label>
|
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
:class="{ 'disabled': listService.loading}"
|
2021-10-17 16:52:05 +00:00
|
|
|
:disabled="listService.loading ? true : null"
|
2021-01-30 16:17:04 +00:00
|
|
|
@keyup.enter="save"
|
|
|
|
class="input"
|
2021-08-23 17:42:42 +00:00
|
|
|
id="identifier"
|
2021-06-23 23:24:57 +00:00
|
|
|
:placeholder="$t('list.edit.identifierPlaceholder')"
|
2021-01-30 16:17:04 +00:00
|
|
|
type="text"
|
|
|
|
v-focus
|
|
|
|
v-model="list.identifier"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
2021-06-23 23:24:57 +00:00
|
|
|
<label class="label" for="listdescription">{{ $t('list.edit.description') }}</label>
|
2021-01-30 16:17:04 +00:00
|
|
|
<div class="control">
|
|
|
|
<editor
|
|
|
|
:class="{ 'disabled': listService.loading}"
|
|
|
|
:disabled="listService.loading"
|
2021-10-17 16:52:05 +00:00
|
|
|
:previewIsDefault="false"
|
2021-01-30 16:17:04 +00:00
|
|
|
id="listdescription"
|
2021-06-23 23:24:57 +00:00
|
|
|
:placeholder="$t('list.edit.descriptionPlaceholder')"
|
2021-01-30 16:17:04 +00:00
|
|
|
v-model="list.description"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
2021-06-23 23:24:57 +00:00
|
|
|
<label class="label">{{ $t('list.edit.color') }}</label>
|
2021-01-30 16:17:04 +00:00
|
|
|
<div class="control">
|
|
|
|
<color-picker v-model="list.hexColor"/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</create-edit>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-08-23 19:18:29 +00:00
|
|
|
import AsyncEditor from '@/components/input/AsyncEditor'
|
|
|
|
|
2021-01-30 16:17:04 +00:00
|
|
|
import ListModel from '@/models/list'
|
|
|
|
import ListService from '@/services/list'
|
2021-07-25 13:27:15 +00:00
|
|
|
import ColorPicker from '@/components/input/colorPicker.vue'
|
2021-01-30 16:17:04 +00:00
|
|
|
import {CURRENT_LIST} from '@/store/mutation-types'
|
2021-07-25 13:27:15 +00:00
|
|
|
import CreateEdit from '@/components/misc/create-edit.vue'
|
2021-01-30 16:17:04 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'list-setting-edit',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
list: ListModel,
|
2021-09-08 09:59:38 +00:00
|
|
|
listService: new ListService(),
|
2021-01-30 16:17:04 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
CreateEdit,
|
|
|
|
ColorPicker,
|
2021-08-23 19:18:29 +00:00
|
|
|
editor: AsyncEditor,
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
2021-09-08 09:59:38 +00:00
|
|
|
watch: {
|
|
|
|
'$route.params.listId': {
|
|
|
|
handler: 'loadList',
|
|
|
|
immediate: true,
|
|
|
|
},
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2021-10-11 17:37:20 +00:00
|
|
|
async loadList() {
|
2021-01-30 16:17:04 +00:00
|
|
|
const list = new ListModel({id: this.$route.params.listId})
|
|
|
|
|
2021-10-11 17:37:20 +00:00
|
|
|
const loadedList = await this.listService.get(list)
|
|
|
|
this.list = { ...loadedList }
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
2021-10-11 17:37:20 +00:00
|
|
|
|
|
|
|
async save() {
|
|
|
|
await this.$store.dispatch('lists/updateList', this.list)
|
2021-10-16 18:44:39 +00:00
|
|
|
await this.$store.dispatch(CURRENT_LIST, this.list)
|
2021-10-11 17:37:20 +00:00
|
|
|
this.setTitle(this.$t('list.edit.title', {list: this.list.title}))
|
|
|
|
this.$message.success({message: this.$t('list.edit.success')})
|
|
|
|
this.$router.back()
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|