2021-01-30 17:17:04 +01:00
|
|
|
<template>
|
|
|
|
<create-edit
|
|
|
|
title="Duplicate this list"
|
|
|
|
primary-icon="paste"
|
|
|
|
primary-label="Duplicate"
|
|
|
|
@primary="duplicateList"
|
|
|
|
:loading="listDuplicateService.loading"
|
|
|
|
>
|
|
|
|
<p>Select a namespace which should hold the duplicated list:</p>
|
|
|
|
<namespace-search @selected="selectNamespace"/>
|
|
|
|
</create-edit>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import ListDuplicateService from '@/services/listDuplicateService'
|
|
|
|
import NamespaceSearch from '@/components/namespace/namespace-search'
|
|
|
|
import ListDuplicateModel from '@/models/listDuplicateModel'
|
|
|
|
import CreateEdit from '@/components/misc/create-edit'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'list-setting-duplicate',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
listDuplicateService: ListDuplicateService,
|
|
|
|
selectedNamespace: null,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
CreateEdit,
|
|
|
|
NamespaceSearch,
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.listDuplicateService = new ListDuplicateService()
|
|
|
|
this.setTitle('Duplicate List')
|
|
|
|
},
|
|
|
|
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-06-22 22:07:57 +02:00
|
|
|
this.success({message: 'The list was successfully duplicated.'})
|
2021-01-30 17:17:04 +01:00
|
|
|
this.$router.push({name: 'list.index', params: {listId: r.list.id}})
|
|
|
|
})
|
|
|
|
.catch(e => {
|
2021-06-22 22:07:57 +02:00
|
|
|
this.error(e)
|
2021-01-30 17:17:04 +01:00
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|