UX: styling, fix import, hide brands immediately, sort brands by frequency, see #2071
This commit is contained in:
parent
6c6f988f3c
commit
a70dbf0043
3 changed files with 24 additions and 12 deletions
|
@ -142,9 +142,15 @@ export default class NameSuggestionIndex {
|
|||
type: string,
|
||||
tags: Record<string, string>,
|
||||
country: string[],
|
||||
location?: [number, number]
|
||||
location?: [number, number],
|
||||
options?:{
|
||||
/**
|
||||
* If set, sort by frequency instead of alphabetically
|
||||
*/
|
||||
sortByFrequency: boolean
|
||||
}
|
||||
): Promise<Mapping[]> {
|
||||
const mappings: Mapping[] = []
|
||||
const mappings: (Mapping & {frequency: number})[] = []
|
||||
const frequencies = await NameSuggestionIndex.fetchFrequenciesFor(type, country)
|
||||
for (const key in tags) {
|
||||
if (key.startsWith("_")) {
|
||||
|
@ -180,7 +186,7 @@ export default class NameSuggestionIndex {
|
|||
addExtraTags: Object.keys(tags)
|
||||
.filter((k) => k !== type)
|
||||
.map((k) => new Tag(k, tags[k])),
|
||||
then: new TypedTranslation<Record<string, never>>({ "*": nsiItem.displayName }),
|
||||
then: new TypedTranslation<Record<string, never>>({ "*": nsiItem.displayName +" "+(frequency) }),
|
||||
hideInAnswer: false,
|
||||
ifnot: undefined,
|
||||
alsoShowIf: undefined,
|
||||
|
@ -190,9 +196,14 @@ export default class NameSuggestionIndex {
|
|||
// As such, it should be "true" but this is not supported
|
||||
priorityIf: frequency > 0 ? new RegexTag("id", /.*/) : undefined,
|
||||
searchTerms: { "*": [nsiItem.displayName, nsiItem.id] },
|
||||
frequency: frequency ?? -1
|
||||
})
|
||||
}
|
||||
}
|
||||
if(options?.sortByFrequency){
|
||||
mappings.sort((a, b) => b.frequency - a.frequency)
|
||||
}
|
||||
|
||||
return mappings
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue