From 9f8dfb6249144b3b8bed31e76fc4baf7bc7166d6 Mon Sep 17 00:00:00 2001 From: Chloe Zermatten Date: Fri, 6 Feb 2026 17:50:50 +0000 Subject: [PATCH] Bug 10190: feat: trigger add/edit form UI/UX enhancements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - scroll to the add/edit form on button click     - prevent redundant full page reload upon the user swapping between adding and editing while the modal is open     - ensure robust scroll behaviour, handling:           - the URL being accessed directly           - the edit button in the table in the main page being used to access the form directly           - the stepper workflow being used           - the user swapping between add and edit once already looking at the form - dynamic display of 'Transport Type' consistency: only show if a 'Notice' has been selected - if a notice has been selected, prevent form submission if transport type isn't set and display an alert on submission attempt --- .../CirculationTriggersFormAdd.vue | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersFormAdd.vue index 48a01e6f83f..7cb9efb70df 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersFormAdd.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Admin/CirculationTriggers/CirculationTriggersFormAdd.vue @@ -134,6 +134,7 @@ (ruleSetInitialized && editMode === 'edit') || editMode === 'add' " + id="trigger-edit-form-general-section" > {{ $__("Add new trigger") }} @@ -285,6 +286,7 @@ (ruleSetInitialized && editMode === 'edit') || editMode === 'add' " + id="trigger-edit-form-notice-section" > {{ $__("Notice for trigger") }} @@ -341,16 +343,13 @@ v-if=" ruleSetToSubmit[ `overdue_${triggerNumber}_notice` - ] !== '' || - ((ruleSetToSubmit[ + ] !== '' && + ruleSetToSubmit[ `overdue_${triggerNumber}_notice` - ] === null || - ruleSetToSubmit[ - `overdue_${triggerNumber}_notice` - ] === undefined) && - fallbackRuleSet?.[ - `overdue_${triggerNumber}_notice` - ] !== '') + ] !== null && + ruleSetToSubmit[ + `overdue_${triggerNumber}_notice` + ] !== undefined " > @@ -386,6 +385,11 @@ ] : '' " + :required=" + !ruleSetToSubmit[ + `overdue_${triggerNumber}_mtt` + ]?.length + " /> @@ -861,6 +865,20 @@ export default { this.ruleSetToSubmit[`overdue_${this.triggerNumber}_delay`] = null; this.setAllowSubmission(); }, + async scrollToTriggerEditForm() { + let count = 0; + // ensures that the relevant section is loaded before we attempt to scroll it into view + while ( + !document.getElementById("trigger-edit-form-general-section") && + count < 8 + ) { + await new Promise(resolve => setTimeout(resolve, 250)); + count++; + } + document + .getElementById("trigger-edit-form-general-section") + .scrollIntoView({ behavior: "smooth" }); + }, }, watch: { $route: { @@ -868,6 +886,8 @@ export default { handler: function (newVal, oldVal) { if ( oldVal && + !oldVal.fullPath.includes("add") && + !oldVal.fullPath.includes("edit") && oldVal.query.triggerNumber && newVal.query.triggerNumber !== oldVal.query.triggerNumber ) { @@ -875,6 +895,12 @@ export default { } }, }, + async editMode(newValue) { + if (newValue === "add" || newValue === "edit") { + await this.$nextTick(); + await this.scrollToTriggerEditForm(); + } + }, }, components: { TriggersTable, ButtonSubmit, TriggerContext }, }; -- 2.39.5