mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 09:15:33 +00:00
Filtering now works
This commit is contained in:
@@ -37,6 +37,14 @@
|
||||
EntryString string
|
||||
IncipitString string
|
||||
}
|
||||
|
||||
.filters
|
||||
type BeitraegeFilterParameters struct {
|
||||
Agent string
|
||||
Type string
|
||||
Year string
|
||||
OnlyScans bool
|
||||
}
|
||||
*/}}
|
||||
|
||||
{{ $isAlm := false }}
|
||||
@@ -76,33 +84,51 @@
|
||||
{{ template "_searchboxsimple" Arr $model.parameters true $q }}
|
||||
<fieldset class="selectgroup">
|
||||
<div class="selectgroup-option">
|
||||
<input type="checkbox" name="title" id="title"
|
||||
{{ if or $isBase $isTitle -}}checked{{- end -}} />
|
||||
<input
|
||||
type="checkbox"
|
||||
name="title"
|
||||
id="title"
|
||||
{{ if or $isBase $isTitle -}}checked{{- end -}} />
|
||||
<label for="title">Titel</label>
|
||||
</div>
|
||||
<div class="selectgroup-option">
|
||||
<input type="checkbox" name="incipit" id="incipit"
|
||||
{{ if or $isBase $isIncipit -}}checked{{- end -}} />
|
||||
<input
|
||||
type="checkbox"
|
||||
name="incipit"
|
||||
id="incipit"
|
||||
{{ if or $isBase $isIncipit -}}checked{{- end -}} />
|
||||
<label for="incipit">Incipit</label>
|
||||
</div>
|
||||
<div class="selectgroup-option">
|
||||
<input type="checkbox" name="persons" id="persons"
|
||||
{{ if or $isBase $isPerson -}}checked{{- end -}} />
|
||||
<input
|
||||
type="checkbox"
|
||||
name="persons"
|
||||
id="persons"
|
||||
{{ if or $isBase $isPerson -}}checked{{- end -}} />
|
||||
<label for="person">Personen & Pseudonyme</label>
|
||||
</div>
|
||||
<div class="selectgroup-option">
|
||||
<input type="checkbox" name="entry" id="entry"
|
||||
{{ if or $isBase $isEntry -}}checked{{- end -}} />
|
||||
<input
|
||||
type="checkbox"
|
||||
name="entry"
|
||||
id="entry"
|
||||
{{ if or $isBase $isEntry -}}checked{{- end -}} />
|
||||
<label for="entry">Bandtitel</label>
|
||||
</div>
|
||||
<div class="selectgroup-option">
|
||||
<input type="checkbox" name="year" id="year"
|
||||
{{ if or $isBase $isYear -}}checked{{- end -}} />
|
||||
<input
|
||||
type="checkbox"
|
||||
name="year"
|
||||
id="year"
|
||||
{{ if or $isBase $isYear -}}checked{{- end -}} />
|
||||
<label for="year">Jahr</label>
|
||||
</div>
|
||||
<div class="selectgroup-option">
|
||||
<input type="checkbox" name="annotations" id="annotations"
|
||||
{{ if or $isBase $isAnnotation -}}checked{{- end -}} />
|
||||
<input
|
||||
type="checkbox"
|
||||
name="annotations"
|
||||
id="annotations"
|
||||
{{ if or $isBase $isAnnotation -}}checked{{- end -}} />
|
||||
<label for="annotations">Anmerkungen</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
@@ -116,114 +142,37 @@
|
||||
|
||||
{{- if $model.parameters.IsBeitraegeSearch -}}
|
||||
<div class="container-normal" id="searchresults">
|
||||
<div class="border-b border-zinc-300 flex flex-row justify-between">
|
||||
<div>
|
||||
{{ if $model.parameters.Query -}}
|
||||
Suche nach <b>»{{ $model.parameters.Query }}«</b> ·
|
||||
{{- end -}}
|
||||
{{- if $isAlm -}}
|
||||
Inhaltsnummer <b>»{{ $model.parameters.AlmString }}«</b> ·
|
||||
{{- end -}}
|
||||
<i class="ri-book-line"></i>
|
||||
{{ if eq $model.result.Count 1 -}}
|
||||
Ein Beitrag
|
||||
{{ else -}}
|
||||
{{ $model.result.Count }} Beiträge
|
||||
{{- end }}
|
||||
in
|
||||
{{ if eq ($model.result.Entries | len) 1 -}}
|
||||
einem Band
|
||||
{{ else -}}
|
||||
{{ $model.result.Entries | len }} Bänden
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- if gt (len $model.result.Pages) 1 }}
|
||||
<div>
|
||||
{{ if gt $model.parameters.Page 1 -}}
|
||||
<a
|
||||
href="{{- $model.parameters.ToQueryParamsBeitraege -}}&page={{ $model.parameters.Prev
|
||||
}}" class="mr-1.5">
|
||||
<i class="ri-arrow-left-long-line"></i>
|
||||
</a>
|
||||
{{ template "_filterlist" $model }}
|
||||
{{ template "tablehead" $model }}
|
||||
{{- if $model.result.Hits -}}
|
||||
<div class="mt-8" id="almanachcontents">
|
||||
{{- range $_, $hit := $model.result.Hits -}}
|
||||
{{- $e := index $model.result.Entries $hit -}}
|
||||
{{- $contents := index $model.result.Contents $e.Id -}}
|
||||
<div
|
||||
class="font-serif flex flex-row justify-between text-stone-800
|
||||
font-bold border-b pb-0.5 mb-2 tab-list-head items-end">
|
||||
<div>
|
||||
{{ $e.PreferredTitle }}
|
||||
</div>
|
||||
<div
|
||||
class="inline-block font-sans bg-slate-800 text-white h-max text-sm px-1.5 rounded">
|
||||
{{- len $contents -}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-7 tab-list-panel">
|
||||
{{- range $i, $c := $contents -}}
|
||||
{{- $rels := index $model.result.ContentsAgents $c.Id -}}
|
||||
{{- template "_content" Arr $c $e $rels $model.result.Agents false true
|
||||
$model.parameters
|
||||
-}}
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
S. {{ $model.parameters.Page }} /
|
||||
{{ $model.result.PagesCount }}
|
||||
{{ if lt $model.parameters.Page ($model.result.PagesCount) -}}
|
||||
<a
|
||||
href="{{- $model.parameters.ToQueryParamsBeitraege -}}&page={{ $model.parameters.Next
|
||||
}}" class="ml-1.5">
|
||||
<i class="ri-arrow-right-long-line"></i>
|
||||
</a>
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
|
||||
{{- if not $isAlm -}}
|
||||
<div>
|
||||
<label
|
||||
for="sort"
|
||||
class="align-baseline h-min self-end pb-1 mr-2 text-sm font-sans
|
||||
text-stone-700"
|
||||
>Sortierung</label
|
||||
>
|
||||
|
||||
{{/* INFO: We always redrect to letter = A bc some letters dont exist for other professions */}}
|
||||
<select
|
||||
class="h-min pb-1 border-b-4 border-zinc-300 px-1.5"
|
||||
name="sort"
|
||||
id="sort"
|
||||
autocomplete="off"
|
||||
hx-get="{{- $model.parameters.ToQueryParamsBeitraege -}}"
|
||||
trigger="change"
|
||||
hx-push-url="true"
|
||||
hx-select="main"
|
||||
hx-target="main">
|
||||
<option
|
||||
value="year"
|
||||
{{ if eq $model.parameters.Sort "year" -}}
|
||||
selected
|
||||
{{- end -}}>
|
||||
Jahr
|
||||
</option>
|
||||
<option value="entry" {{ if eq $model.parameters.Sort "entry" -}}selected{{- end -}}>
|
||||
Bände A-Z
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
||||
{{- if $model.result.Hits -}}
|
||||
|
||||
<div class="mt-8" id="almanachcontents">
|
||||
{{- range $_, $hit := $model.result.Hits -}}
|
||||
{{- $e := index $model.result.Entries $hit -}}
|
||||
{{- $contents := index $model.result.Contents $e.Id -}}
|
||||
<div
|
||||
class="font-serif flex flex-row justify-between text-stone-800
|
||||
font-bold border-b pb-0.5 mb-2 tab-list-head items-end">
|
||||
<div>
|
||||
{{ $e.PreferredTitle }}
|
||||
</div>
|
||||
<div
|
||||
class="inline-block font-sans bg-slate-800 text-white h-max text-sm px-1.5 rounded">
|
||||
{{- len $contents -}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-7 tab-list-panel">
|
||||
{{- range $i, $c := $contents -}}
|
||||
{{- $rels := index $model.result.ContentsAgents $c.Id -}}
|
||||
{{- template "_content" Arr $c $e $rels $model.result.Agents false true
|
||||
$model.parameters
|
||||
-}}
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
||||
|
||||
<script type="module">
|
||||
let elements = document.querySelectorAll('.search-text');
|
||||
let mark_instance = new Mark(elements);
|
||||
@@ -235,5 +184,4 @@
|
||||
}, 200);
|
||||
</script>
|
||||
</div>
|
||||
|
||||
{{- end -}}
|
||||
|
||||
119
views/routes/suche/beitraege/tablehead.gohtml
Normal file
119
views/routes/suche/beitraege/tablehead.gohtml
Normal file
@@ -0,0 +1,119 @@
|
||||
{{ $model := . }}
|
||||
|
||||
{{ $isAlm := false }}
|
||||
{{ $isTitle := false }}
|
||||
{{ $isYear := false }}
|
||||
{{ $isPerson := false }}
|
||||
{{ $isAnnotation := false }}
|
||||
{{ $isIncipit := false }}
|
||||
{{ $isEntry := false }}
|
||||
|
||||
{{- $isAlm = $model.parameters.AlmString -}}
|
||||
{{- $isTitle = or $model.parameters.Title $model.parameters.TitleString -}}
|
||||
{{- $isYear = or $model.parameters.Year $model.parameters.YearString -}}
|
||||
{{- $isPerson = or $model.parameters.Persons $model.parameters.PersonsString -}}
|
||||
{{- $isAnnotation = or $model.parameters.Annotations $model.parameters.AnnotationsString -}}
|
||||
{{- $isIncipit = or $model.parameters.Incipit $model.parameters.IncipitString -}}
|
||||
{{- $isEntry = or $model.parameters.Entry $model.parameters.EntryString -}}
|
||||
|
||||
{{- $isBase := not (or $isTitle $isYear $isPerson $isAnnotation $isIncipit $isEntry) -}}
|
||||
|
||||
|
||||
<div class="border-b border-zinc-300 flex flex-row justify-between">
|
||||
<div class="flex flex-row gap-x-2">
|
||||
{{ if $model.parameters.Query -}}
|
||||
<div>Suche nach <b>»{{ $model.parameters.Query }}«</b></div>
|
||||
<div>·</div>
|
||||
{{- end -}}
|
||||
{{- if $isAlm -}}
|
||||
<div>Inhaltsnummer <b>»{{ $model.parameters.AlmString }}«</b></div>
|
||||
<div>·</div>
|
||||
{{- end -}}
|
||||
<div>
|
||||
<i class="ri-book-line"></i>
|
||||
{{ if eq $model.result.Count 1 -}}
|
||||
Ein Beitrag
|
||||
{{ else -}}
|
||||
{{ $model.result.Count }} Beiträge
|
||||
{{- end }}
|
||||
in
|
||||
{{ if eq ($model.result.Entries | len) 1 -}}
|
||||
einem Band
|
||||
{{ else -}}
|
||||
{{ $model.result.Entries | len }} Bänden
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- if gt (len $model.result.Pages) 1 }}
|
||||
<div>·</div>
|
||||
<div class="[&>_a]:no-underline">
|
||||
{{ if gt $model.parameters.Page 1 -}}
|
||||
<a
|
||||
href="{{- $model.parameters.ToQueryParamsBeitraege -}}&page={{ $model.parameters.Prev }}"
|
||||
class="mr-1.5">
|
||||
<i class="ri-arrow-left-long-line"></i>
|
||||
</a>
|
||||
{{- end -}}
|
||||
Seite {{ $model.parameters.Page }} /
|
||||
{{ $model.result.PagesCount }}
|
||||
{{ if lt $model.parameters.Page ($model.result.PagesCount) -}}
|
||||
<a
|
||||
href="{{- $model.parameters.ToQueryParamsBeitraege -}}&page={{ $model.parameters.Next }}"
|
||||
class="ml-1.5">
|
||||
<i class="ri-arrow-right-long-line"></i>
|
||||
</a>
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{- end -}}
|
||||
</div>
|
||||
|
||||
{{- if not $isAlm -}}
|
||||
<div>
|
||||
<label
|
||||
for="onlyscans"
|
||||
class="align-baseline h-min self-end pb-1 mr-1 text-sm font-sans text-stone-700">
|
||||
Nur Digitalisate
|
||||
</label>
|
||||
<input
|
||||
class="mr-4"
|
||||
type="checkbox"
|
||||
id="onlyscans"
|
||||
name="onlyscans"
|
||||
autocomplete="off"
|
||||
hx-get="{{- $model.parameters.ToQueryParamsBeitraege -}}"
|
||||
trigger="change"
|
||||
hx-push-url="true"
|
||||
hx-select="main"
|
||||
hx-target="main"
|
||||
{{ if $model.filters.OnlyScans -}}checked{{- end -}} />
|
||||
|
||||
<label
|
||||
for="sort"
|
||||
class="align-baseline h-min self-end pb-1 mr-2 text-sm font-sans
|
||||
text-stone-700"
|
||||
>Sortierung</label
|
||||
>
|
||||
|
||||
<select
|
||||
class="h-min pb-1 border-b-4 border-zinc-300 px-1.5"
|
||||
name="sort"
|
||||
id="sort"
|
||||
autocomplete="off"
|
||||
hx-get="{{- $model.parameters.ToQueryParamsBeitraege -}}"
|
||||
trigger="change"
|
||||
hx-push-url="true"
|
||||
hx-select="main"
|
||||
hx-target="main">
|
||||
<option
|
||||
value="year"
|
||||
{{ if eq $model.parameters.Sort "year" -}}
|
||||
selected
|
||||
{{- end -}}>
|
||||
Jahr
|
||||
</option>
|
||||
<option value="entry" {{ if eq $model.parameters.Sort "entry" -}}selected{{- end -}}>
|
||||
Bände A-Z
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
{{- end -}}
|
||||
</div>
|
||||
75
views/routes/suche/components/_filterlist.gohtml
Normal file
75
views/routes/suche/components/_filterlist.gohtml
Normal file
@@ -0,0 +1,75 @@
|
||||
{{ $model := . }}
|
||||
|
||||
|
||||
<div class="flex flex-row gap-x-6 mb-4">
|
||||
<filter-list
|
||||
id="agent-list"
|
||||
data-queryparam="personsstring"
|
||||
data-url="{{ $model.parameters.ToQueryParamsBeitraege }}&agentfilter="
|
||||
data-placeholder="Personen und Körperschaften filtern..."></filter-list>
|
||||
|
||||
<filter-list
|
||||
id="year-list"
|
||||
data-queryparam="yearstring"
|
||||
data-url="{{ $model.parameters.ToQueryParamsBeitraege }}&yearfilter="
|
||||
data-placeholder="Jahre filtern..."></filter-list>
|
||||
|
||||
<filter-list
|
||||
id="types-list"
|
||||
data-queryparam="type"
|
||||
data-url="{{ $model.parameters.ToQueryParamsBeitraege }}&typefilter="
|
||||
data-placeholder="Betragskategorien filtern..."></filter-list>
|
||||
</div>
|
||||
|
||||
<script type="module">
|
||||
let agentList = document.getElementById("agent-list");
|
||||
if (agentList) {
|
||||
agentList.items = {{ $model.result.AgentsList }};
|
||||
|
||||
agentList.setSearchTextFunc((item) => {
|
||||
return item.name;
|
||||
});
|
||||
|
||||
agentList.setHREFFunc((item) => {
|
||||
return item.name;
|
||||
});
|
||||
|
||||
agentList.setLinkTextFunc((item) => {
|
||||
return `
|
||||
<span class="filter-list-searchable">${item.name}</span>
|
||||
<span class="text-xs text-stone-500 whitespace-nowrap font-sans">
|
||||
${item.corporate_body ? "Verlag/Druck/Vertrieb" : item.biographical_data}
|
||||
</span>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
let yearList = document.getElementById("year-list");
|
||||
if (yearList) {
|
||||
yearList.items = {{ $model.result.YearList }};
|
||||
|
||||
yearList.setHREFFunc((item) => {
|
||||
return String(item);
|
||||
});
|
||||
|
||||
yearList.setLinkTextFunc((item) => {
|
||||
if (item === 0) return "ohne Jahr";
|
||||
return String(item);
|
||||
});
|
||||
}
|
||||
|
||||
let typesList = document.getElementById("types-list");
|
||||
if (typesList) {
|
||||
typesList.items = {{ $model.result.TypesList }};
|
||||
|
||||
typesList.setHREFFunc((item) => {
|
||||
return String(item);
|
||||
});
|
||||
|
||||
typesList.setLinkTextFunc((item) => {
|
||||
return item;
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user