From 49fd2f97a21f96d2f24327bc46eb851f0d1cd1bc Mon Sep 17 00:00:00 2001 From: Steven Clontz Date: Fri, 1 Nov 2024 16:35:18 -0500 Subject: [PATCH] Display aliases on Explore page (#177) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Display aliases on Explore page * lint * typeset aliases * add property aliases to formula suggestions * only sort by ID when no text filter is given * only search names/aliases, decrease threshold * lint 🧹 --- .../src/components/Search/Results/Found.svelte | 8 +++++++- .../Shared/Formula/Input/Suggestions.svelte | 9 +++++++++ packages/viewer/src/components/Traits/Table.svelte | 13 ++++++++++++- packages/viewer/src/stores/search.ts | 2 +- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/packages/viewer/src/components/Search/Results/Found.svelte b/packages/viewer/src/components/Search/Results/Found.svelte index b2aea391..13719f88 100644 --- a/packages/viewer/src/components/Search/Results/Found.svelte +++ b/packages/viewer/src/components/Search/Results/Found.svelte @@ -7,6 +7,12 @@ export let text: string | undefined export let formula: F.Formula | undefined export let results: Space[] + let sortedResults: Space[] + $: if (text !== undefined && text.length > 0) { + sortedResults = results + } else { + sortedResults = results.sort((a, b) => a.id - b.id) + } {results.length} spaces @@ -18,6 +24,6 @@ {/if} a.id - b.id)} + spaces={sortedResults} properties={formula ? [...F.properties(formula)] : []} /> diff --git a/packages/viewer/src/components/Shared/Formula/Input/Suggestions.svelte b/packages/viewer/src/components/Shared/Formula/Input/Suggestions.svelte index 2b708d54..6c0f4a01 100644 --- a/packages/viewer/src/components/Shared/Formula/Input/Suggestions.svelte +++ b/packages/viewer/src/components/Shared/Formula/Input/Suggestions.svelte @@ -20,6 +20,15 @@ on:keydown={() => onClick(i)} > + {#if property.aliases.length > 0} +
+ + {#each property.aliases as alias, i} + {#if i > 0},{' '}{/if} + + {/each} + + {/if} {/each} diff --git a/packages/viewer/src/components/Traits/Table.svelte b/packages/viewer/src/components/Traits/Table.svelte index 7cb21886..3ed11859 100644 --- a/packages/viewer/src/components/Traits/Table.svelte +++ b/packages/viewer/src/components/Traits/Table.svelte @@ -4,6 +4,7 @@ import { Link } from '../Shared' import Value from './Value.svelte' + import Typeset from '../Shared/Typeset.svelte' export let properties: Property[] export let spaces: Space[] @@ -30,7 +31,17 @@ S{space.id}
{#each properties as property (property.id)}
- +
+ {#if space.aliases.length > 0} +
+ + {#each space.aliases as alias, i} + {#if i > 0}, {/if} + + {/each} + +
+ {/if}
diff --git a/packages/viewer/src/stores/search.ts b/packages/viewer/src/stores/search.ts index 2f21f8b9..d335debd 100644 --- a/packages/viewer/src/stores/search.ts +++ b/packages/viewer/src/stores/search.ts @@ -29,8 +29,8 @@ export default function create({ keys: [ { name: 'name', weight: 0.7 }, { name: 'aliases', weight: 0.7 }, - { name: 'description', weight: 0.3 }, ], + threshold: 0.3, }), )