From 1ae97ac2a1eed19f092a6cf1a266e4de3b68b2b6 Mon Sep 17 00:00:00 2001 From: romankko2 Date: Wed, 15 Feb 2023 15:57:07 +0100 Subject: [PATCH] query params URL --- app/src/plugins/app/_config/App.vue | 12 +++++++++++- app/src/plugins/app/_config/router.ts | 14 -------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app/src/plugins/app/_config/App.vue b/app/src/plugins/app/_config/App.vue index 8135608..f96b70b 100644 --- a/app/src/plugins/app/_config/App.vue +++ b/app/src/plugins/app/_config/App.vue @@ -63,7 +63,9 @@ export default { this.$refs['z-task-modal'].showModal(task, editMode, masterTask) }) - this.$events.on('show-master-task-modal', ({masterTask, editMode}) => { + this.$events.on('show-master-task-modal', ({ masterTask, editMode }) => { + const id = masterTask.id + this.$router.push({ query: { 'master-task': id } }) this.$refs['z-master-task-modal'].showModal(masterTask, editMode) }) @@ -104,6 +106,14 @@ export default { onMasterTaskEdited(masterTask){ this.$events.emit('on-master-task-edited', masterTask) } + }, + + watch: { + '$route'() { + if (this.$route.query['master-task']) { + this.$events.emit('show-master-task-modal', { masterTask: { id: this.$route.query['master-task'] }, editMode: false }) + } + } } } \ No newline at end of file diff --git a/app/src/plugins/app/_config/router.ts b/app/src/plugins/app/_config/router.ts index 6801cca..9b5d54b 100644 --- a/app/src/plugins/app/_config/router.ts +++ b/app/src/plugins/app/_config/router.ts @@ -113,18 +113,4 @@ const router = createRouter({ routes }) -// router.afterEach((to) => { -// if (to.fullPath.includes('?master-task')) { -// const searchParams = new URLSearchParams(to.fullPath.split('?')[1]) -// const id = searchParams.get('id') - -// this.$events.emit('show-master-task-modal', { id }) -// } else if (to.fullPath.includes('?task')) { -// const searchParams = new URLSearchParams(to.fullPath.split('?')[1]) -// const id = searchParams.get('id') - -// this.$events.emit('show-task-modal', { id }) -// } -// }) - export default router