@museumwnf/viewer-core 2.11.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@museumwnf/viewer-core",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
4
4
  "description": "Application engine for MWNF websites: turns a dataset.config.js into a mounted Vue application.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -105,6 +105,14 @@ export function searchRows(filters, count = 4) {
105
105
  return rows
106
106
  }
107
107
 
108
+ /**
109
+ * The query key of the search language: legacy's own `searchlanguage`. Never
110
+ * `lang`, which carries the language the website is read in: a visitor
111
+ * reading in French still searches every language, as on legacy, unless
112
+ * they pick one.
113
+ */
114
+ export const SEARCH_LANGUAGE_KEY = 'searchlanguage'
115
+
108
116
  /** The query keys `searchRows` reads, for a results spec's `keys`. */
109
117
  export function searchRowKeys(count = 4) {
110
118
  const keys = ['q', 'field']
@@ -125,7 +133,8 @@ export function searchedFor(filters, t, { rows = 4, extras = [] } = {}) {
125
133
  .map((row, i) => `${i > 0 ? `${row.cond} ` : ''}${searchFieldLabel(row.field, t)}: "${row.keyword}"`)
126
134
  if (filters.from) parts.push(`${t('catalogue.filter.from')} ${filters.from}`)
127
135
  if (filters.to) parts.push(`${t('catalogue.filter.to')} ${filters.to}`)
128
- if (filters.lang) parts.push(`${t('catalogue.search.language')}: ${String(filters.lang).toUpperCase()}`)
136
+ const language = filters[SEARCH_LANGUAGE_KEY]
137
+ if (language) parts.push(`${t('catalogue.search.language')}: ${String(language).toUpperCase()}`)
129
138
  for (const extra of extras) {
130
139
  const part = extra(filters, t)
131
140
  if (part) parts.push(part)
@@ -149,7 +158,7 @@ export function searchSummary({ filters, t, pageInfo }, options = {}) {
149
158
  * The index behind the results page: one long-lived `useKeywordIndex` over
150
159
  * `entity` (`fields` grammar, legacy's `rank: 'hits'` order, the glossary
151
160
  * and country expansions of `database_results.php`), its search language
152
- * kept in step with the query's `lang`. `narrow(list, filters)` is a results
161
+ * kept in step with the query's `searchlanguage`. `narrow(list, filters)` is a results
153
162
  * spec's `narrow`: the matches in rank order, kept to what `list` (the
154
163
  * records the spec's `scope` let through) carries. Pass `sort: false` to the
155
164
  * spec, so the rank order stands.
@@ -165,7 +174,7 @@ export function useFieldSearch({
165
174
  const index = useKeywordIndex(entity, { grammar: 'fields', fields, language, rank, expand })
166
175
 
167
176
  function narrow(list, filters) {
168
- language.value = filters.lang || ''
177
+ language.value = filters[SEARCH_LANGUAGE_KEY] || ''
169
178
  const matches = index.search(searchRows(filters, rows))
170
179
  if (!list) return matches
171
180
  const allowed = new Set(list.map((record) => record.id))
package/src/index.js CHANGED
@@ -5,7 +5,7 @@ export {
5
5
  CATALOGUE_DATE_MODE, CATALOGUE_PAGE_SIZE, objectsAndMonumentsSummary, useCatalogue,
6
6
  } from './catalogue/catalogue.js'
7
7
  export {
8
- searchFieldLabel, searchFieldOptions, searchFields, searchRowKeys, searchRows, searchSummary, searchedFor,
8
+ SEARCH_LANGUAGE_KEY, searchFieldLabel, searchFieldOptions, searchFields, searchRowKeys, searchRows, searchSummary, searchedFor,
9
9
  useFieldSearch, useSearchFieldOptions,
10
10
  } from './catalogue/fieldSearch.js'
11
11
  export { useDataPackage } from './composables/useDataPackage.js'