@museumwnf/viewer-core 2.19.0 → 2.20.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
|
@@ -54,6 +54,20 @@ export function overlapsRange(event, begin, end) {
|
|
|
54
54
|
return yf <= end
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Whether `event` falls in `[begin, end]` by an exhibition's own chronology,
|
|
59
|
+
* legacy's `/thg/timeline?na=&nz=`: unlike the country rule above, its bounds
|
|
60
|
+
* are inclusive, so an event ending the year a search begins, or beginning
|
|
61
|
+
* the year it ends, is in it. An event with no known end is its start year.
|
|
62
|
+
*/
|
|
63
|
+
export function touchesRange(event, begin, end) {
|
|
64
|
+
const yf = event?.year_from
|
|
65
|
+
if (begin == null && end == null) return true
|
|
66
|
+
if (!Number.isFinite(yf)) return false
|
|
67
|
+
const yt = effectiveYearTo(event) ?? yf
|
|
68
|
+
return (begin == null || yt >= begin) && (end == null || yf <= end)
|
|
69
|
+
}
|
|
70
|
+
|
|
57
71
|
/**
|
|
58
72
|
* The label under an event, trying the three rules the sites share in the
|
|
59
73
|
* order the data disambiguates them: a curated description pair
|
|
@@ -206,7 +220,7 @@ export function useTimelineEvents({
|
|
|
206
220
|
// renders no picker for this scope.
|
|
207
221
|
if (scope !== 'local' && countryId && event.country_id !== countryId) return false
|
|
208
222
|
if (collection !== undefined && !matchesCollection(event, collection)) return false
|
|
209
|
-
return overlapsRange(event, from, to)
|
|
223
|
+
return scope === 'local' ? touchesRange(event, from, to) : overlapsRange(event, from, to)
|
|
210
224
|
})
|
|
211
225
|
.map((event) => ({ ...event, text: tr ? tr(event.id) : {} }))
|
|
212
226
|
.sort((a, b) => {
|
|
@@ -55,8 +55,12 @@ export function useExhibitionData(config = {}) {
|
|
|
55
55
|
// because the item sheet's holder line is the one surface that needs the
|
|
56
56
|
// opposite of `visible` — the museum keeps its name and loses only the
|
|
57
57
|
// link, because it has no page to link to.
|
|
58
|
+
//
|
|
59
|
+
// So is a partner the package says has no text in any language: it has no
|
|
60
|
+
// name, and legacy lists no such partner, nor serves its page.
|
|
58
61
|
const hiddenPartnerIds = computed(() => new Set(exhibition.value?.hidden_partner_ids ?? []))
|
|
59
62
|
function isHiddenPartner(partner) {
|
|
63
|
+
if (Array.isArray(partner?.languages) && partner.languages.length === 0) return true
|
|
60
64
|
return hiddenPartnerIds.value.has(partner?.id)
|
|
61
65
|
}
|
|
62
66
|
|
|
@@ -80,7 +84,8 @@ export function useExhibitionData(config = {}) {
|
|
|
80
84
|
// descriptions. Hence the `!i.languages?.length ||` guard, which
|
|
81
85
|
// reads like a redundant null-check and is not.
|
|
82
86
|
items: (i) => !i.languages?.length || i.languages.includes(defaultLang),
|
|
83
|
-
|
|
87
|
+
// A partner is another case: see `isHiddenPartner` above.
|
|
88
|
+
partners: (p) => !isHiddenPartner(p),
|
|
84
89
|
},
|
|
85
90
|
})
|
|
86
91
|
|
|
@@ -114,11 +114,13 @@ export function useExhibitionItemDetail(data, timeline) {
|
|
|
114
114
|
// an exhibition with a chronology of its own and both flags off (The
|
|
115
115
|
// Hijaz Railway); it is withheld when the exhibition has no chronology
|
|
116
116
|
// in force, when the item has no date to anchor a range on, or when no
|
|
117
|
-
// event falls in it.
|
|
117
|
+
// event falls in it. Legacy asked for the item's own years, and showed
|
|
118
|
+
// them; only its "search this period" link rounded them out to
|
|
119
|
+
// centuries.
|
|
118
120
|
timeline: (record, ctx) => {
|
|
119
121
|
if (!hasTimeline.value && !usesLocalTimeline?.value) return null
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
if (!Number.isFinite(record.start_date)) return null
|
|
123
|
+
const range = [record.start_date, Number.isFinite(record.end_date) ? record.end_date : record.start_date]
|
|
122
124
|
if (findEvents({ begin: range[0], end: range[1] }).length === 0) return null
|
|
123
125
|
return {
|
|
124
126
|
heading: 'core.section.timeline',
|
|
@@ -127,7 +129,7 @@ export function useExhibitionItemDetail(data, timeline) {
|
|
|
127
129
|
events: (country) => findEvents({ country, begin: range[0], end: range[1] }),
|
|
128
130
|
range,
|
|
129
131
|
era: (year) => eraLabel(year, ctx.t),
|
|
130
|
-
searchTo: periodSearch,
|
|
132
|
+
searchTo: (country) => periodSearch(country, roundOutward(record.start_date, record.end_date)),
|
|
131
133
|
}
|
|
132
134
|
},
|
|
133
135
|
},
|
package/src/index.js
CHANGED
|
@@ -34,7 +34,7 @@ export {
|
|
|
34
34
|
combineExpansions, countryExpansion, glossaryExpansion, parseBooleanQuery, useKeywordIndex,
|
|
35
35
|
} from './catalogue/keywordIndex.js'
|
|
36
36
|
export {
|
|
37
|
-
effectiveYearTo, eventDateLabel, overlapsRange, useTimelineEvents,
|
|
37
|
+
effectiveYearTo, eventDateLabel, overlapsRange, touchesRange, useTimelineEvents,
|
|
38
38
|
} from './catalogue/timeline.js'
|
|
39
39
|
|
|
40
40
|
// The record page: the sheet engine and its derivations.
|