Revised the summary helper so that when the summary is changed with the tag changed, the on-change callback is run to check the tag button status.
This commit is contained in:
parent
73f7d14e7b
commit
f41db78831
@ -462,27 +462,35 @@ class TagTabPlane extends TabPlane {
|
|||||||
this.initializeTagButtons();
|
this.initializeTagButtons();
|
||||||
const tabPlane = this;
|
const tabPlane = this;
|
||||||
this.tag.onchange = function () {
|
this.tag.onchange = function () {
|
||||||
tabPlane.tag.value = tabPlane.tag.value.trim();
|
tabPlane.onTagChange();
|
||||||
let isMatched = false;
|
|
||||||
for (const tagButton of tabPlane.tagButtons) {
|
|
||||||
if (tagButton.dataset.value === tabPlane.tag.value) {
|
|
||||||
tagButton.classList.remove("btn-outline-primary");
|
|
||||||
tagButton.classList.add("btn-primary");
|
|
||||||
tabPlane.editor.filterSuggestedAccounts(tagButton);
|
|
||||||
isMatched = true;
|
|
||||||
} else {
|
|
||||||
tagButton.classList.remove("btn-primary");
|
|
||||||
tagButton.classList.add("btn-outline-primary");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!isMatched) {
|
|
||||||
tabPlane.editor.filterSuggestedAccounts(null);
|
|
||||||
}
|
|
||||||
tabPlane.updateSummary();
|
tabPlane.updateSummary();
|
||||||
tabPlane.validateTag();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The callback when the tag input is changed
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
onTagChange() {
|
||||||
|
this.tag.value = this.tag.value.trim();
|
||||||
|
let isMatched = false;
|
||||||
|
for (const tagButton of this.tagButtons) {
|
||||||
|
if (tagButton.dataset.value === this.tag.value) {
|
||||||
|
tagButton.classList.remove("btn-outline-primary");
|
||||||
|
tagButton.classList.add("btn-primary");
|
||||||
|
this.editor.filterSuggestedAccounts(tagButton);
|
||||||
|
isMatched = true;
|
||||||
|
} else {
|
||||||
|
tagButton.classList.remove("btn-primary");
|
||||||
|
tagButton.classList.add("btn-outline-primary");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isMatched) {
|
||||||
|
this.editor.filterSuggestedAccounts(null);
|
||||||
|
}
|
||||||
|
this.validateTag();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the summary according to the input in the tab plane.
|
* Updates the summary according to the input in the tab plane.
|
||||||
*
|
*
|
||||||
@ -618,7 +626,10 @@ class GeneralTagTab extends TagTabPlane {
|
|||||||
if (found === null) {
|
if (found === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.tag.value = found[1];
|
if (this.tag.value !== found[1]) {
|
||||||
|
this.tag.value = found[1];
|
||||||
|
this.onTagChange();
|
||||||
|
}
|
||||||
for (const tagButton of this.tagButtons) {
|
for (const tagButton of this.tagButtons) {
|
||||||
if (tagButton.dataset.value === this.tag.value) {
|
if (tagButton.dataset.value === this.tag.value) {
|
||||||
tagButton.classList.remove("btn-outline-primary");
|
tagButton.classList.remove("btn-outline-primary");
|
||||||
@ -776,7 +787,10 @@ class GeneralTripTab extends TagTabPlane {
|
|||||||
if (found === null) {
|
if (found === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.tag.value = found[1];
|
if (this.tag.value !== found[1]) {
|
||||||
|
this.tag.value = found[1];
|
||||||
|
this.onTagChange();
|
||||||
|
}
|
||||||
this.#from.value = found[2];
|
this.#from.value = found[2];
|
||||||
for (const directionButton of this.#directionButtons) {
|
for (const directionButton of this.#directionButtons) {
|
||||||
if (directionButton.dataset.arrow === found[3]) {
|
if (directionButton.dataset.arrow === found[3]) {
|
||||||
@ -967,7 +981,10 @@ class BusTripTab extends TagTabPlane {
|
|||||||
if (found === null) {
|
if (found === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.tag.value = found[1];
|
if (this.tag.value !== found[1]) {
|
||||||
|
this.tag.value = found[1];
|
||||||
|
this.onTagChange();
|
||||||
|
}
|
||||||
this.#route.value = found[2];
|
this.#route.value = found[2];
|
||||||
this.#from.value = found[3];
|
this.#from.value = found[3];
|
||||||
this.#to.value = found[4];
|
this.#to.value = found[4];
|
||||||
|
Loading…
Reference in New Issue
Block a user