Added a "note" field to the summary editor.
This commit is contained in:
parent
85fde6219e
commit
78a62a9575
@ -74,6 +74,12 @@ class SummaryEditor {
|
|||||||
*/
|
*/
|
||||||
number;
|
number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The note.
|
||||||
|
* @type {HTMLInputElement}
|
||||||
|
*/
|
||||||
|
note;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The account buttons
|
* The account buttons
|
||||||
* @type {HTMLButtonElement[]}
|
* @type {HTMLButtonElement[]}
|
||||||
@ -140,6 +146,7 @@ class SummaryEditor {
|
|||||||
this.#modal = document.getElementById(this.prefix + "-modal");
|
this.#modal = document.getElementById(this.prefix + "-modal");
|
||||||
this.summary = document.getElementById(this.prefix + "-summary");
|
this.summary = document.getElementById(this.prefix + "-summary");
|
||||||
this.number = document.getElementById(this.prefix + "-number-number");
|
this.number = document.getElementById(this.prefix + "-number-number");
|
||||||
|
this.note = document.getElementById(this.prefix + "-number-note");
|
||||||
// noinspection JSValidateTypes
|
// noinspection JSValidateTypes
|
||||||
this.#accountButtons = Array.from(document.getElementsByClassName(this.prefix + "-account"));
|
this.#accountButtons = Array.from(document.getElementsByClassName(this.prefix + "-account"));
|
||||||
|
|
||||||
@ -605,7 +612,7 @@ class GeneralTagTab extends TagTabPlane {
|
|||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
populate() {
|
populate() {
|
||||||
const found = this.editor.summary.value.match(/^([^—]+)—.+?(?:×\d+)?$/);
|
const found = this.editor.summary.value.match(/^([^—]+)—.+?(?:×\d+)?(?:\([^)]+\))?$/);
|
||||||
if (found === null) {
|
if (found === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -761,7 +768,7 @@ class GeneralTripTab extends TagTabPlane {
|
|||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
populate() {
|
populate() {
|
||||||
const found = this.editor.summary.value.match(/^([^—]+)—([^—→↔]+)([→↔])(.+?)(?:×\d+)?$/);
|
const found = this.editor.summary.value.match(/^([^—]+)—([^—→↔]+)([→↔])(.+?)(?:×\d+)?(?:\([^)]+\))?$/);
|
||||||
if (found === null) {
|
if (found === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -949,7 +956,7 @@ class BusTripTab extends TagTabPlane {
|
|||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
populate() {
|
populate() {
|
||||||
const found = this.editor.summary.value.match(/^([^—]+)—([^—]+)—([^—→]+)→(.+?)(?:×\d+)?$/);
|
const found = this.editor.summary.value.match(/^([^—]+)—([^—]+)—([^—→]+)→(.+?)(?:×\d+)?(?:\([^)]+\))?$/);
|
||||||
if (found === null) {
|
if (found === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1110,13 +1117,11 @@ class NumberTab extends TabPlane {
|
|||||||
super(editor);
|
super(editor);
|
||||||
const tabPlane = this;
|
const tabPlane = this;
|
||||||
this.editor.number.onchange = function () {
|
this.editor.number.onchange = function () {
|
||||||
const found = tabPlane.editor.summary.value.match(/^(.+)×(\d+)$/);
|
tabPlane.updateSummary();
|
||||||
if (found !== null) {
|
};
|
||||||
tabPlane.editor.summary.value = found[1];
|
this.editor.note.onchange = function () {
|
||||||
}
|
tabPlane.editor.note.value = tabPlane.editor.note.value.trim();
|
||||||
if (parseInt(tabPlane.editor.number.value) > 1) {
|
tabPlane.updateSummary();
|
||||||
tabPlane.editor.summary.value = tabPlane.editor.summary.value + "×" + tabPlane.editor.number.value;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1130,6 +1135,24 @@ class NumberTab extends TabPlane {
|
|||||||
return "number";
|
return "number";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the summary according to the input in the tab plane.
|
||||||
|
*
|
||||||
|
* @override
|
||||||
|
*/
|
||||||
|
updateSummary() {
|
||||||
|
const found = this.editor.summary.value.match(/^(.*?)(?:×\d+)?(?:\([^)]+\))?$/);
|
||||||
|
if (found !== null) {
|
||||||
|
this.editor.summary.value = found[1];
|
||||||
|
}
|
||||||
|
if (parseInt(this.editor.number.value) > 1) {
|
||||||
|
this.editor.summary.value = this.editor.summary.value + "×" + this.editor.number.value;
|
||||||
|
}
|
||||||
|
if (this.editor.note.value !== "") {
|
||||||
|
this.editor.summary.value = this.editor.summary.value + "(" + this.editor.note.value + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the tab plane input.
|
* Resets the tab plane input.
|
||||||
*
|
*
|
||||||
@ -1137,6 +1160,7 @@ class NumberTab extends TabPlane {
|
|||||||
*/
|
*/
|
||||||
reset() {
|
reset() {
|
||||||
this.editor.number.value = "";
|
this.editor.number.value = "";
|
||||||
|
this.editor.note.value = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1146,11 +1170,16 @@ class NumberTab extends TabPlane {
|
|||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
populate() {
|
populate() {
|
||||||
const found = this.editor.summary.value.match(/^.+×(\d+)$/);
|
const found = this.editor.summary.value.match(/^(.*?)(?:×(\d+))?(?:\(([^)]+)\))?$/);
|
||||||
if (found === null) {
|
if (found[2] === undefined) {
|
||||||
this.editor.number.value = "";
|
this.editor.number.value = "";
|
||||||
} else {
|
} else {
|
||||||
this.editor.number.value = found[1];
|
this.editor.number.value = found[2];
|
||||||
|
}
|
||||||
|
if (found[3] === undefined) {
|
||||||
|
this.editor.note.value = "";
|
||||||
|
} else {
|
||||||
|
this.editor.note.value = found[3];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,12 @@ First written: 2023/2/28
|
|||||||
<label class="form-label" for="accounting-summary-editor-{{ summary_editor.type }}-number-number">{{ A_("The number of items") }}</label>
|
<label class="form-label" for="accounting-summary-editor-{{ summary_editor.type }}-number-number">{{ A_("The number of items") }}</label>
|
||||||
<div id="accounting-summary-editor-{{ summary_editor.type }}-number-number-error" class="invalid-feedback"></div>
|
<div id="accounting-summary-editor-{{ summary_editor.type }}-number-number-error" class="invalid-feedback"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-floating">
|
||||||
|
<input id="accounting-summary-editor-{{ summary_editor.type }}-number-note" class="form-control" type="text" value="" placeholder=" ">
|
||||||
|
<label class="form-label" for="accounting-summary-editor-{{ summary_editor.type }}-number-note">{{ A_("Note") }}</label>
|
||||||
|
<div id="accounting-summary-editor-{{ summary_editor.type }}-number-note-error" class="invalid-feedback"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{# The suggested accounts #}
|
{# The suggested accounts #}
|
||||||
|
Loading…
Reference in New Issue
Block a user