From 73f7d14e7be45ece3ba4e79ddcee1b61f0e7d8e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sat, 4 Mar 2023 00:09:30 +0800 Subject: [PATCH] Fixed so that the values of the input fields are trimmed before composing the summary when they are changed. --- src/accounting/static/js/summary-editor.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/accounting/static/js/summary-editor.js b/src/accounting/static/js/summary-editor.js index 1ef00d2..c71e78c 100644 --- a/src/accounting/static/js/summary-editor.js +++ b/src/accounting/static/js/summary-editor.js @@ -462,6 +462,7 @@ class TagTabPlane extends TabPlane { this.initializeTagButtons(); const tabPlane = this; this.tag.onchange = function () { + tabPlane.tag.value = tabPlane.tag.value.trim(); let isMatched = false; for (const tagButton of tabPlane.tagButtons) { if (tagButton.dataset.value === tabPlane.tag.value) { @@ -692,6 +693,7 @@ class GeneralTripTab extends TagTabPlane { this.#directionButtons = Array.from(document.getElementsByClassName(this.prefix + "-direction")); const tabPlane = this; this.#from.onchange = function () { + tabPlane.#from.value = tabPlane.#from.value.trim(); tabPlane.updateSummary(); tabPlane.validateFrom(); }; @@ -707,6 +709,7 @@ class GeneralTripTab extends TagTabPlane { }; } this.#to.onchange = function () { + tabPlane.#to.value = tabPlane.#to.value.trim(); tabPlane.updateSummary(); tabPlane.validateTo(); }; @@ -900,14 +903,17 @@ class BusTripTab extends TagTabPlane { this.#toError = document.getElementById(this.prefix + "-to-error") const tabPlane = this; this.#route.onchange = function () { + tabPlane.#route.value = tabPlane.#route.value.trim(); tabPlane.updateSummary(); tabPlane.validateRoute(); }; this.#from.onchange = function () { + tabPlane.#from.value = tabPlane.#from.value.trim(); tabPlane.updateSummary(); tabPlane.validateFrom(); }; this.#to.onchange = function () { + tabPlane.#to.value = tabPlane.#to.value.trim(); tabPlane.updateSummary(); tabPlane.validateTo(); };