Skip to content

Commit

Permalink
LWS-201/203: Fix pill labels (#1085)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperengstrom authored Aug 9, 2024
1 parent 866b15a commit 170a871
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lxl-web/src/lib/components/find/SearchMapping.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
{:else if m.operator === 'existence' || m.operator === 'notExistence'}
{@const symbol = getRelationSymbol(m.operator)}
<span class="pill-relation">{symbol}</span>
<div class="pill-label inline-block text-2-regular first-letter:uppercase">{m.label}</div>
<div class="pill-label inline text-2-regular">{m.label}</div>
{:else if 'label' in m && 'display' in m}
{@const symbol = getRelationSymbol(m.operator)}
<div class="pill-label inline-block text-2-regular first-letter:uppercase">{m.label}</div>
<div class="pill-label inline text-2-regular">{m.label}</div>
<span class="pill-relation">{symbol}</span>
<span class="pill-value">
<DecoratedData data={m.display} showLabels={ShowLabelsOptions['Never']} />
Expand Down
8 changes: 7 additions & 1 deletion lxl-web/src/lib/utils/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function displayMappings(
display: displayUtil.lensAndFormat(property, LensType.Chip, locale),
label: m.alias
? translate(`facet.${m.alias}`)
: m.property?.labelByLang?.[locale] || m.property?.['@id'] || 'no label', // lensandformat?
: capitalize(m.property?.labelByLang?.[locale] || m.property?.label) || m.property?.['@id'] || 'No label', // lensandformat?
operator,
...('up' in m && { up: replacePath(m.up as Link, usePath) })
} as DisplayMapping;
Expand Down Expand Up @@ -222,6 +222,12 @@ function replacePath(view: Link, usePath: string) {
};
}

function capitalize(str: string | undefined) {
if (str && typeof str === 'string') {
return str[0].toUpperCase() + str.slice(1);
} return str;
}

export function shouldShowMapping(mapping: DisplayMapping[]) {
if (mapping.length === 1 && mapping[0].display === '*' && mapping[0].operator === 'equals') {
return false; // hide if only wildcard search
Expand Down

0 comments on commit 170a871

Please sign in to comment.