Revised the #isQueryMatched method to always does partial match in the JavaScript OriginalLineItem class. Removed the full match from the query values. It is really wierd to type in the half with no match until you type the full term. It may create misunderstanding that there is no further match if you keep typing.

This commit is contained in:
依瑪貓 2023-03-24 07:38:17 +08:00
parent 8c1ecd6eac
commit c865141583
2 changed files with 14 additions and 19 deletions

View File

@ -760,7 +760,7 @@ class JournalEntryLineItem(db.Model):
setattr(self, "__net_balance", net_balance)
@property
def query_values(self) -> tuple[list[str], list[str]]:
def query_values(self) -> list[str]:
"""Returns the values to be queried.
:return: The values to be queried.
@ -772,17 +772,17 @@ class JournalEntryLineItem(db.Model):
journal_entry_day: date = self.journal_entry.date
description: str = "" if self.description is None else self.description
return ([description],
[str(journal_entry_day.year),
"{}/{}".format(journal_entry_day.year,
journal_entry_day.month),
"{}/{}".format(journal_entry_day.month,
journal_entry_day.day),
"{}/{}/{}".format(journal_entry_day.year,
journal_entry_day.month,
journal_entry_day.day),
format_amount(self.amount),
format_amount(self.net_balance)])
return [description,
str(journal_entry_day.year),
"{}/{}".format(journal_entry_day.year,
journal_entry_day.month),
"{}/{}".format(journal_entry_day.month,
journal_entry_day.day),
"{}/{}/{}".format(journal_entry_day.year,
journal_entry_day.month,
journal_entry_day.day),
format_amount(self.amount),
format_amount(self.net_balance)]
class Option(db.Model):

View File

@ -273,7 +273,7 @@ class OriginalLineItem {
/**
* The values to query against
* @type {string[][]}
* @type {string[]}
*/
#queryValues;
@ -366,16 +366,11 @@ class OriginalLineItem {
if (query === "") {
return true;
}
for (const queryValue of this.#queryValues[0]) {
for (const queryValue of this.#queryValues) {
if (queryValue.toLowerCase().includes(query.toLowerCase())) {
return true;
}
}
for (const queryValue of this.#queryValues[1]) {
if (queryValue === query) {
return true;
}
}
return false;
}