2021-01-30 17:17:04 +01:00
|
|
|
<template>
|
|
|
|
<create-edit
|
2021-06-24 01:24:57 +02:00
|
|
|
:title="$t('list.duplicate.title')"
|
2021-01-30 17:17:04 +01:00
|
|
|
primary-icon="paste"
|
2021-06-24 01:24:57 +02:00
|
|
|
:primary-label="$t('list.duplicate.label')"
|
2021-01-30 17:17:04 +01:00
|
|
|
@primary="duplicateList"
|
|
|
|
:loading="listDuplicateService.loading"
|
|
|
|
>
|
2021-06-24 01:24:57 +02:00
|
|
|
<p>
|
|
|
|
{{ $t('list.duplicate.text') }}
|
|
|
|
</p>
|
2021-01-30 17:17:04 +01:00
|
|
|
<namespace-search @selected="selectNamespace"/>
|
|
|
|
</create-edit>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import ListDuplicateService from '@/services/listDuplicateService'
|
2021-07-25 15:27:15 +02:00
|
|
|
import NamespaceSearch from '@/components/namespace/namespace-search.vue'
|
2021-01-30 17:17:04 +01:00
|
|
|
import ListDuplicateModel from '@/models/listDuplicateModel'
|
2021-07-25 15:27:15 +02:00
|
|
|
import CreateEdit from '@/components/misc/create-edit.vue'
|
2021-01-30 17:17:04 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'list-setting-duplicate',
|
|
|
|
data() {
|
|
|
|
return {
|
2021-09-08 11:59:38 +02:00
|
|
|
listDuplicateService: new ListDuplicateService(),
|
2021-01-30 17:17:04 +01:00
|
|
|
selectedNamespace: null,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
CreateEdit,
|
|
|
|
NamespaceSearch,
|
|
|
|
},
|
|
|
|
created() {
|
2021-06-24 01:24:57 +02:00
|
|
|
this.setTitle(this.$t('list.duplicate.title'))
|
2021-01-30 17:17:04 +01:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
selectNamespace(namespace) {
|
|
|
|
this.selectedNamespace = namespace
|
|
|
|
},
|
|
|
|
duplicateList() {
|
|
|
|
const listDuplicate = new ListDuplicateModel({
|
|
|
|
listId: this.$route.params.listId,
|
|
|
|
namespaceId: this.selectedNamespace.id,
|
|
|
|
})
|
|
|
|
this.listDuplicateService.create(listDuplicate)
|
|
|
|
.then(r => {
|
|
|
|
this.$store.commit('namespaces/addListToNamespace', r.list)
|
2021-05-26 16:46:16 +02:00
|
|
|
this.$store.commit('lists/setList', r.list)
|
2021-08-25 12:28:29 +02:00
|
|
|
this.$message.success({message: this.$t('list.duplicate.success')})
|
2021-01-30 17:17:04 +01:00
|
|
|
this.$router.push({name: 'list.index', params: {listId: r.list.id}})
|
|
|
|
})
|
|
|
|
.catch(e => {
|
2021-08-25 12:28:29 +02:00
|
|
|
this.$message.error(e)
|
2021-01-30 17:17:04 +01:00
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|