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"
|
2021-06-23 23:24:57 +00:00
|
|
|
:tertary="$t('misc.delete')"
|
2021-01-30 16:17:04 +00:00
|
|
|
@tertary="$router.push({ name: 'list.list.settings.delete', params: { id: $route.params.listId } })"
|
|
|
|
>
|
|
|
|
<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 17:00:03 +02: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}"
|
|
|
|
:disabled="listService.loading"
|
|
|
|
@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"
|
|
|
|
:preview-is-default="false"
|
|
|
|
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>
|
|
|
|
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'
|
|
|
|
import LoadingComponent from '@/components/misc/loading.vue'
|
|
|
|
import ErrorComponent from '@/components/misc/error.vue'
|
2021-01-30 16:17:04 +00:00
|
|
|
import ListDuplicateService from '@/services/listDuplicateService'
|
|
|
|
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 11:59:38 +02:00
|
|
|
listService: new ListService(),
|
|
|
|
listDuplicateService: new ListDuplicateService(),
|
2021-01-30 16:17:04 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
CreateEdit,
|
|
|
|
ColorPicker,
|
|
|
|
editor: () => ({
|
2021-07-25 13:27:15 +00:00
|
|
|
component: import('@/components/input/editor.vue'),
|
2021-01-30 16:17:04 +00:00
|
|
|
loading: LoadingComponent,
|
|
|
|
error: ErrorComponent,
|
|
|
|
timeout: 60000,
|
|
|
|
}),
|
|
|
|
},
|
2021-09-08 11:59:38 +02:00
|
|
|
watch: {
|
|
|
|
'$route.params.listId': {
|
|
|
|
handler: 'loadList',
|
|
|
|
immediate: true,
|
|
|
|
},
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
loadList() {
|
|
|
|
const list = new ListModel({id: this.$route.params.listId})
|
|
|
|
|
|
|
|
this.listService.get(list)
|
|
|
|
.then(r => {
|
2021-08-19 21:35:38 +02:00
|
|
|
this.list = r
|
2021-01-30 16:17:04 +00:00
|
|
|
this.$store.commit(CURRENT_LIST, r)
|
2021-06-23 23:24:57 +00:00
|
|
|
this.setTitle(this.$t('list.edit.title', {list: this.list.title}))
|
2021-01-30 16:17:04 +00:00
|
|
|
})
|
|
|
|
.catch(e => {
|
2021-08-25 12:28:29 +02:00
|
|
|
this.$message.error(e)
|
2021-01-30 16:17:04 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
save() {
|
2021-05-26 16:46:16 +02:00
|
|
|
this.$store.dispatch('lists/updateList', this.list)
|
|
|
|
.then(() => {
|
2021-08-25 12:28:29 +02:00
|
|
|
this.$message.success({message: this.$t('list.edit.success')})
|
2021-02-20 17:24:40 +01:00
|
|
|
this.$router.back()
|
2021-01-30 16:17:04 +00:00
|
|
|
})
|
|
|
|
.catch(e => {
|
2021-08-25 12:28:29 +02:00
|
|
|
this.$message.error(e)
|
2021-01-30 16:17:04 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|