fix: properly update state when duplicating a list
This commit is contained in:
parent
a0d0c2cb1f
commit
e7de930129
1 changed files with 11 additions and 11 deletions
|
@ -21,9 +21,9 @@
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {ref, shallowReactive} from 'vue'
|
import {ref, shallowReactive} from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import {useRoute, useRouter} from 'vue-router'
|
||||||
import { useStore } from 'vuex'
|
import {useStore} from 'vuex'
|
||||||
import { useI18n } from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import ListDuplicateService from '@/services/listDuplicateService'
|
import ListDuplicateService from '@/services/listDuplicateService'
|
||||||
import CreateEdit from '@/components/misc/create-edit.vue'
|
import CreateEdit from '@/components/misc/create-edit.vue'
|
||||||
|
@ -32,29 +32,30 @@ import Multiselect from '@/components/input/multiselect.vue'
|
||||||
import ListDuplicateModel from '@/models/listDuplicateModel'
|
import ListDuplicateModel from '@/models/listDuplicateModel'
|
||||||
import NamespaceModel from '@/models/namespace'
|
import NamespaceModel from '@/models/namespace'
|
||||||
|
|
||||||
import { success } from '@/message'
|
import {success} from '@/message'
|
||||||
import { useTitle } from '@/composables/useTitle'
|
import {useTitle} from '@/composables/useTitle'
|
||||||
import { useNameSpaceSearch } from '@/composables/useNamespaceSearch'
|
import {useNameSpaceSearch} from '@/composables/useNamespaceSearch'
|
||||||
|
|
||||||
|
const {t} = useI18n({useScope: 'global'})
|
||||||
const { t } = useI18n({useScope: 'global'})
|
|
||||||
useTitle(() => t('list.duplicate.title'))
|
useTitle(() => t('list.duplicate.title'))
|
||||||
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
namespaces,
|
namespaces,
|
||||||
findNamespaces,
|
findNamespaces,
|
||||||
} = useNameSpaceSearch()
|
} = useNameSpaceSearch()
|
||||||
|
|
||||||
const selectedNamespace = ref<NamespaceModel>()
|
const selectedNamespace = ref<NamespaceModel>()
|
||||||
|
|
||||||
function selectNamespace(namespace: NamespaceModel) {
|
function selectNamespace(namespace: NamespaceModel) {
|
||||||
selectedNamespace.value = namespace
|
selectedNamespace.value = namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router= useRouter()
|
const router = useRouter()
|
||||||
|
const store = useStore()
|
||||||
|
|
||||||
const listDuplicateService = shallowReactive(new ListDuplicateService())
|
const listDuplicateService = shallowReactive(new ListDuplicateService())
|
||||||
|
|
||||||
async function duplicateList() {
|
async function duplicateList() {
|
||||||
const listDuplicate = new ListDuplicateModel({
|
const listDuplicate = new ListDuplicateModel({
|
||||||
// FIXME: should be parameter
|
// FIXME: should be parameter
|
||||||
|
@ -64,7 +65,6 @@ async function duplicateList() {
|
||||||
|
|
||||||
const duplicate = await listDuplicateService.create(listDuplicate)
|
const duplicate = await listDuplicateService.create(listDuplicate)
|
||||||
|
|
||||||
const store = useStore()
|
|
||||||
store.commit('namespaces/addListToNamespace', duplicate.list)
|
store.commit('namespaces/addListToNamespace', duplicate.list)
|
||||||
store.commit('lists/setList', duplicate.list)
|
store.commit('lists/setList', duplicate.list)
|
||||||
success({message: t('list.duplicate.success')})
|
success({message: t('list.duplicate.success')})
|
||||||
|
|
Loading…
Reference in a new issue