From c7e259d2d9d7f7c29c43ca7d64000ce329af37d0 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Mon, 20 Oct 2025 14:13:36 +0100 Subject: [PATCH] Bug 40191: Replace 'Submit' with 'Save' Signed-off-by: Jan Kissig --- .../js/vue/components/ResourceFormSave.vue | 85 +++++++++++-------- 1 file changed, 50 insertions(+), 35 deletions(-) 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 70e33400784..f5cc061bfe5 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ResourceFormSave.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ResourceFormSave.vue @@ -93,8 +93,11 @@ !instancedResource.stickyToolbar.includes('Form')) " > - - + + editMode.value ? $__("Save") : $__("Submit")) const resourceToSave = computed(() => { return ( @@ -145,7 +147,7 @@ export default { props.instancedResource.idAttr ] ) { - editMode.value = true + editMode.value = true; props.instancedResource.getResource( props.instancedResource.route.params[ props.instancedResource.idAttr @@ -163,60 +165,74 @@ export default { }); const saveAndNavigate = ($event, resourceToSave) => { - const { components, navigationOnFormSave, onFormSave, router, idAttr } = props.instancedResource + const { + components, + navigationOnFormSave, + onFormSave, + router, + idAttr, + } = props.instancedResource; // Default to show - const navigationAction = saveOptionSelected.value || navigationOnFormSave || components.show - const idParamRequired = navigationAction === components.show || navigationAction === components.edit + const navigationAction = + saveOptionSelected.value || + navigationOnFormSave || + components.show; + const idParamRequired = + navigationAction === components.show || + navigationAction === components.edit; onFormSave($event, resourceToSave).then(resource => { - if(resource) { + if (resource) { router.push({ name: navigationAction, ...(idParamRequired && { params: { - [idAttr]: resource[idAttr] - } - }) - }) + [idAttr]: resource[idAttr], + }, + }), + }); } - }) - } + }); + }; - const saveOptionSelected = ref(props.instancedResource.navigationOnFormSave) + const saveOptionSelected = ref( + props.instancedResource.navigationOnFormSave + ); const dropdownButtons = computed(() => { - const { components, navigationOnFormSave } = props.instancedResource + const { components, navigationOnFormSave } = + props.instancedResource; const buttonOptions = { list: { - title: $__("%s and return to list").format(buttonTextLeader.value), + title: $__("Save and return to list"), action: "submit", cssClass: "btn btn-default", callback: () => { - saveOptionSelected.value = components.list - } + saveOptionSelected.value = components.list; + }, }, show: { - title: $__("%s and show").format(buttonTextLeader.value), + title: $__("Save and show"), action: "submit", cssClass: "btn btn-default", callback: () => { - saveOptionSelected.value = components.show - } + saveOptionSelected.value = components.show; + }, }, edit: { - title: $__("%s and continue editing").format(buttonTextLeader.value), + title: $__("Save and continue editing"), action: "submit", cssClass: "btn btn-default", callback: () => { - saveOptionSelected.value = components.edit - } - } - } + saveOptionSelected.value = components.edit; + }, + }, + }; return Object.keys(buttonOptions).reduce((acc, key) => { - if(key === "show" && !navigationOnFormSave) return acc - if(components[key] === navigationOnFormSave) return acc - return [buttonOptions[key], ...acc] - },[]) - }) + if (key === "show" && !navigationOnFormSave) return acc; + if (components[key] === navigationOnFormSave) return acc; + return [buttonOptions[key], ...acc]; + }, []); + }); return { initialized, @@ -226,7 +242,6 @@ export default { saveAndNavigate, editMode, dropdownButtons, - buttonTextLeader }; }, props: { @@ -237,7 +252,7 @@ export default { FormElement, TabsWrapper, AccordionWrapper, - DropdownButtons + DropdownButtons, }, name: "ResourceFormSave", }; -- 2.39.5