Skip to content

Commit 207b585

Browse files
committed
refactor(search): Improve letter height handling and update default values
Updated letter height parsing to consider quantity, atLeast, and atMost values. Adjusted default values for notAfter and notBefore dates, and linked letter height range in SearchFilters to configuration settings.
1 parent ba6086a commit 207b585

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

frontend/src/lib/components/search/SearchFilters.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { Button } from 'bits-ui';
33
import { slide } from 'svelte/transition';
44
import RangeSlider from './RangeSlider.svelte';
5+
import * as config from '$lib/config';
56
67
let {
78
show = $bindable(false),
@@ -11,7 +12,10 @@
1112
publicationConjunction = $bindable(true),
1213
sortAggregationsBy = $bindable('key'),
1314
selectedDateRange = $bindable([0, 0]),
14-
selectedLetterHeightRange = $bindable([0, 0]),
15+
selectedLetterHeightRange = $bindable([
16+
config.search.minLetterHeight,
17+
config.search.maxLetterHeight
18+
]),
1519
selectedFilters = $bindable({}),
1620
sortAggregationsByChange,
1721
languageConjunctionChange,
@@ -263,7 +267,7 @@
263267
title="Letter height"
264268
unit="mm"
265269
min={0}
266-
max={100}
270+
max={config.search.maxLetterHeight}
267271
step={1}
268272
startLabel="Minimum"
269273
endLabel="Maximum"

frontend/src/lib/components/search/search.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,20 @@ export function load({
267267
: undefined;
268268
const letterHeights =
269269
item.letterHeights && item.letterHeights.length > 0
270-
? item.letterHeights.map((d) => ({ atLeast: d.atLeast ?? 0, atMost: d.atMost ?? 100 }))
271-
: [{ atLeast: 0, atMost: 100 }];
270+
? item.letterHeights.map((d) => {
271+
if (d.quantity) {
272+
return {
273+
atLeast: Number.parseInt(d.quantity),
274+
atMost: Number.parseInt(d.quantity)
275+
};
276+
} else {
277+
return {
278+
atLeast: Number.parseInt(d.atLeast ?? '0'),
279+
atMost: Number.parseInt(d.atMost ?? '250')
280+
};
281+
}
282+
})
283+
: [{ atLeast: 0, atMost: 0 }];
272284

273285
let repositoryRole = item.repository?.role?.toLowerCase() ?? undefined;
274286
repositoryRole = repositoryRole?.indexOf('private') !== -1 ? 'private' : repositoryRole;
@@ -287,8 +299,8 @@ export function load({
287299
// raw values, because the original are converted to facet values
288300
rawObjectType: item.objectType,
289301
// facet values
290-
notAfter: item?.date?.notAfter ?? undefined,
291-
notBefore: item?.date?.notBefore ?? undefined,
302+
notAfter: item?.date?.notAfter ?? 0,
303+
notBefore: item?.date?.notBefore ?? 1900,
292304
language: item?.textLang?.languages ?? undefined,
293305
languageCert: item?.textLang?.cert ?? undefined,
294306
inscriptionType: getHierarchicalValues(item.type?.ana),
@@ -471,12 +483,13 @@ export function search({
471483
filters,
472484
filter: (item) => {
473485
const matchesDateRange =
474-
(!dateRange[0] && !dateRange[1]) ||
486+
(dateRange[0] === undefined && dateRange[1] === undefined) ||
475487
(item.notBefore >= dateRange[0] && item.notAfter <= dateRange[1]);
476488

477489
const matchesLetterHeightRange =
478-
item.letterHeightAtLeast >= letterHeightRange[0] &&
479-
item.letterHeightAtMost <= letterHeightRange[1];
490+
(letterHeightRange[0] === undefined && letterHeightRange[1] === undefined) ||
491+
(item.letterHeightAtLeast >= letterHeightRange[0] &&
492+
item.letterHeightAtMost <= letterHeightRange[1]);
480493

481494
return matchesDateRange && matchesLetterHeightRange;
482495
}

0 commit comments

Comments
 (0)