diff --git a/src/composables/useNavigate.js b/src/composables/useNavigate.js new file mode 100644 index 000000000..de2bcdd34 --- /dev/null +++ b/src/composables/useNavigate.js @@ -0,0 +1,16 @@ +import { useRouter, useRoute } from 'vue-router'; + +export function useNavigate() { + const router = useRouter(); + const route = useRoute(); + + function navigate(id, action = 'Card') { + router.push({ name: `${route.meta.moduleName}${action}`, params: { id } }); + } + + function redirectToView(name, action = 'Create') { + router.push({ name: name ?? `${route.meta.moduleName}${action}` }); + } + + return { navigate, redirectToView }; +} diff --git a/src/pages/Entry/EntryList.vue b/src/pages/Entry/EntryList.vue index 6f146e21a..69d45fa2f 100644 --- a/src/pages/Entry/EntryList.vue +++ b/src/pages/Entry/EntryList.vue @@ -1,7 +1,6 @@