Bugzilla – Attachment 188768 Details for
Bug 40191
Design pattern: Redirect user to a view of the record after saving instead of list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40191: Add configurable post-save navigation for Vue resource forms
Bug-40191-Add-configurable-post-save-navigation-fo.patch (text/plain), 7.25 KB, created by
Martin Renvoize (ashimema)
on 2025-10-31 08:59:27 UTC
(
hide
)
Description:
Bug 40191: Add configurable post-save navigation for Vue resource forms
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-10-31 08:59:27 UTC
Size:
7.25 KB
patch
obsolete
>From d040765ea26126ced01820906873ec952f1b5bcd Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> >Date: Fri, 17 Oct 2025 10:25:26 +0100 >Subject: [PATCH] Bug 40191: Add configurable post-save navigation for Vue > resource forms > >This patch introduces a new navigation behavior system for resource forms, >allowing each resource type to define its default post-save action (stay on >form, show detail, or return to list). > >Changes: >- Add `on_save_navigation` prop to ResourceFormSave component >- Extend base-resource composable with navigation configuration >- Implement navigation logic in ButtonSubmit component >- Apply to AgreementResource as initial implementation > >This provides a more flexible UX by letting different resource types have >appropriate default behaviors while maintaining consistent patterns. > >Signed-off-by: Michaela <michaela.sieber@kit.edu> >Signed-off-by: Jan Kissig <bibliothek@th-wildau.de> >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >--- > .../prog/js/vue/components/ButtonSubmit.vue | 7 +----- > .../vue/components/ERM/AgreementResource.vue | 22 ++++++++++--------- > .../js/vue/components/ResourceFormSave.vue | 22 ++++++++++++++++++- > .../js/vue/components/SkeletonResource.vue | 2 ++ > .../prog/js/vue/composables/base-resource.js | 1 + > 5 files changed, 37 insertions(+), 17 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ButtonSubmit.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ButtonSubmit.vue >index 790449be65d..cf91b240149 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ButtonSubmit.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ButtonSubmit.vue >@@ -1,16 +1,11 @@ > <template> > <button >- v-if="form" >- @click="form.value.requestSubmit()" >+ @click="form && form.value.requestSubmit()" > class="btn btn-primary" > > > <font-awesome-icon v-if="icon" :icon="icon" /> > {{ title }} > </button> >- <button v-else type="submit" class="btn btn-primary"> >- <font-awesome-icon v-if="icon" :icon="icon" /> >- {{ title }} >- </button> > </template> > > <script> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementResource.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementResource.vue >index e3b26a33094..006004065aa 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementResource.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementResource.vue >@@ -810,18 +810,20 @@ export default { > delete agreement.agreement_packages; > > if (agreement_id) { >- baseResource.apiClient.update(agreement, agreement_id).then( >- success => { >- baseResource.setMessage($__("Agreement updated")); >- baseResource.router.push({ name: "AgreementsList" }); >- }, >- error => {} >- ); >+ return baseResource.apiClient >+ .update(agreement, agreement_id) >+ .then( >+ agreement => { >+ baseResource.setMessage($__("Agreement updated")); >+ return agreement; >+ }, >+ error => {} >+ ); > } else { >- baseResource.apiClient.create(agreement).then( >- success => { >+ return baseResource.apiClient.create(agreement).then( >+ agreement => { > baseResource.setMessage($__("Agreement created")); >- baseResource.router.push({ name: "AgreementsList" }); >+ return agreement; > }, > error => {} > ); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ResourceFormSave.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ResourceFormSave.vue >index 688211001dd..5758973995a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ResourceFormSave.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ResourceFormSave.vue >@@ -14,7 +14,7 @@ > :componentPropData="{ ...$props, ...$data, resourceForm }" > /> > <form >- @submit="instancedResource.onFormSave($event, resourceToSave)" >+ @submit="saveAndNavigate($event, resourceToSave)" > ref="resourceForm" > > > <TabsWrapper >@@ -154,11 +154,31 @@ export default { > initialized.value = true; > } > }); >+ >+ const saveAndNavigate = ($event, resourceToSave) => { >+ const { components, navigationOnFormSave, onFormSave, router, idAttr } = props.instancedResource >+ // Default to show >+ const navigationAction = navigationOnFormSave || components.show >+ const idParamRequired = navigationAction === components.show || navigationAction === components.edit >+ onFormSave($event, resourceToSave).then(resource => { >+ if(resource) { >+ router.push({ >+ name: navigationAction, >+ ...(idParamRequired && { >+ params: { >+ [idAttr]: resource[idAttr] >+ } >+ }) >+ }) >+ } >+ }) >+ } > return { > initialized, > resource, > resourceToSave, > resourceForm, >+ saveAndNavigate > }; > }, > props: { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/SkeletonResource.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/SkeletonResource.vue >index 10444ebeb5b..5aece6dedff 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/SkeletonResource.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/SkeletonResource.vue >@@ -108,6 +108,8 @@ export default { > props: props, > additionalToolbarButtons, > defaultToolbarButtons, >+ // The default behaviour for the below is the "show" component so is not necessary if this is the desired behaviour >+ navigationOnFormSave: "SkeletonsList" > }); > > /* >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/composables/base-resource.js b/koha-tmpl/intranet-tmpl/prog/js/vue/composables/base-resource.js >index 3c0188f4841..e6204e378cc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/composables/base-resource.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/composables/base-resource.js >@@ -42,6 +42,7 @@ import { > * @param {Function} resourceConfig.additionalToolbarButtons - A function to add additional buttons to the toolbar. > * @param {String} resourceConfig.formGroupsDisplayMode - The display mode for the form groups if not the default. Can be one of the following: "accordion", "tabs". > * @param {Array} resourceConfig.stickyToolbar - The names of the components with a toolbar that should be sticky. >+ * @param {Array} resourceConfig.navigationOnFormSave - The name of the component that should be navigated to when saving the resource creation/edit form. Defaults to the show component > * > * @return {Object} An object containing the utilities provided by this composable. > */ >-- >2.51.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40191
:
188107
|
188108
|
188109
|
188137
|
188138
|
188139
|
188164
|
188165
|
188167
|
188193
|
188194
|
188195
|
188196
|
188197
|
188198
|
188201
|
188202
|
188203
| 188768 |
188769
|
188770
|
188771
|
188772
|
188773
|
188774
|
188775
|
188776