1
0
mirror of https://github.com/koloml/furbooru-tagging-assistant.git synced 2025-12-23 23:02:58 +00:00

Added autocompletion of my: namespace

This commit is contained in:
2024-07-22 22:05:09 +04:00
parent 71ab75efaf
commit 3f22852714

View File

@@ -156,19 +156,29 @@ export class SearchWrapper extends BaseComponent {
}
const propertyName = parsedResult.groups.name;
const propertyType = this.#properties.get(propertyName);
const hasOperatorSyntax = Boolean(parsedResult.groups.op_syntax);
const hasValueSyntax = Boolean(parsedResult.groups.value_syntax);
// No suggestions for values for now, maybe could add suggestions for namespaces like my:*
if (hasValueSyntax) {
if (this.#typeValues.has(propertyType)) {
const givenValue = parsedResult.groups.value;
for (let candidateValue of this.#typeValues.get(propertyType)) {
if (givenValue && !candidateValue.startsWith(givenValue)) {
continue;
}
suggestionsList.push(`${propertyName}${parsedResult.groups.op_syntax ?? ''}:${candidateValue}`);
}
}
return suggestionsList;
}
// If at least one dot placed, start suggesting operators
if (hasOperatorSyntax) {
const propertyType = this.#properties.get(propertyName);
if (this.#typeOperators.has(propertyType)) {
const operatorName = parsedResult.groups.op;
@@ -287,4 +297,15 @@ export class SearchWrapper extends BaseComponent {
[SearchWrapper.#typeNumeric, SearchWrapper.#comparisonOperators],
[SearchWrapper.#typeDate, SearchWrapper.#comparisonOperators],
]);
static #typeValues = new Map([
[SearchWrapper.#typePersonal, [
'comments',
'faves',
'posts',
'uploads',
'upvotes',
'watched',
]]
]);
}