@museumwnf/viewer-core 2.18.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@museumwnf/viewer-core",
3
- "version": "2.18.0",
3
+ "version": "2.20.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",
@@ -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
- partners: (p) => !hiddenPartnerIds.value.has(p.id),
87
+ // A partner is another case: see `isHiddenPartner` above.
88
+ partners: (p) => !isHiddenPartner(p),
84
89
  },
85
90
  })
86
91
 
@@ -148,13 +153,14 @@ export function useExhibitionData(config = {}) {
148
153
  return { name: 'item', params: { id: item.id } }
149
154
  }
150
155
 
151
- // Institutions (monument owners) and museums both live in partners.json —
152
- // the package ships the union of legacy's /partners and /institutions
153
- // because a static package has no endpoints to split them across. The
154
- // viewer routes by `type`, which is what legacy's two page templates
155
- // keyed off.
156
+ // Institutions (monument owners) and museums both live in partners.json.
157
+ // Legacy's /partners lists every owner once (MWNF-621), and its client
158
+ // opens the institution's pages only for a record of legacy's mwnf3
159
+ // institutions table: a Sharing History partner is a partner whatever it
160
+ // holds, though the package types one holding monuments as an institution.
161
+ const INSTITUTIONS_TABLE = 'mwnf3:institutions:'
156
162
  function isInstitution(partner) {
157
- return partner?.type === 'institution'
163
+ return String(partner?.backward_compatibility ?? '').startsWith(INSTITUTIONS_TABLE)
158
164
  }
159
165
 
160
166
  function partnerRoute(partner) {
@@ -204,6 +210,13 @@ export function useExhibitionData(config = {}) {
204
210
  return projectLabel(manifest, item?.project_id, lang)
205
211
  }
206
212
 
213
+ /** The record's project by its legacy code (`ISL`, `EPM`), which legacy's
214
+ * sheet keyed some labels on; '' when the manifest does not carry it. */
215
+ function projectCode(item) {
216
+ const key = manifest?.projects?.[item?.project_id]?.backward_compatibility
217
+ return key ? String(key).split(':').pop().toUpperCase() : ''
218
+ }
219
+
207
220
  /** The exhibition's own per-language chrome text. */
208
221
  function exhibitionTitle(lang = defaultLang) {
209
222
  return exhibition.value?.titles?.[lang] ?? exhibition.value?.titles?.en ?? ''
@@ -247,7 +260,7 @@ export function useExhibitionData(config = {}) {
247
260
  chromeImage,
248
261
  partnerById, countryById, tagById, dynastyById, glossaryById, languageByCode,
249
262
  countryByCode, countryLabelFromCode, countryIdForCode, countryLabel,
250
- itemRoute, isInstitution, partnerRoute, partnerObjectsRoute,
263
+ itemRoute, isInstitution, partnerRoute, partnerObjectsRoute, projectCode,
251
264
  isExploreRecord, projectName,
252
265
  exhibitionTitle, exhibitionSubtitle, exhibitionHeadline, bannerCaption,
253
266
  siblingSites, siblingUrl,
@@ -26,13 +26,14 @@ import { useExhibitionSheet } from './useExhibitionSheet.js'
26
26
  * `data.isHiddenPartner`, `data.labelOf`, `data.partnerById`,
27
27
  * `data.partnerRoute`, `data.translations`, what `useExhibitionSheet` reads,
28
28
  * and `timeline.countryIdForCode`, `timeline.hasTimeline`,
29
- * `timeline.timelineEvents` (`countries`, `findEvents`), `timeline.timelineSpec`.
29
+ * `timeline.usesLocalTimeline`, `timeline.timelineEvents` (`countries`,
30
+ * `findEvents`), `timeline.timelineSpec`.
30
31
  */
31
32
  export function useExhibitionItemDetail(data, timeline) {
32
33
  const {
33
34
  dynastyById, isExploreRecord, isHiddenPartner, labelOf, partnerById, partnerRoute, translations,
34
35
  } = data
35
- const { countryIdForCode, hasTimeline, timelineEvents, timelineSpec } = timeline
36
+ const { countryIdForCode, hasTimeline, usesLocalTimeline, timelineEvents, timelineSpec } = timeline
36
37
  const { countries: timelineCountries, findEvents } = timelineEvents
37
38
  const { itemSheet: platformSheet } = useExhibitionSheet(data)
38
39
 
@@ -107,13 +108,20 @@ export function useExhibitionItemDetail(data, timeline) {
107
108
  records: dynastiesWithHistory(record, language),
108
109
  tr: (d) => dynastyTr(d, language),
109
110
  }),
110
- // Withheld when the exhibition reports no chronology, or the item has
111
- // no date to anchor a range on: legacy then printed no "timeline"
112
- // anywhere on the sheet.
111
+ // Legacy's sheet asked its own chronology (`/thg/timeline`) for the
112
+ // events of the item's period whatever the exhibition's timeline flags
113
+ // said, and drew the link when it answered any. So the link stays for
114
+ // an exhibition with a chronology of its own and both flags off (The
115
+ // Hijaz Railway); it is withheld when the exhibition has no chronology
116
+ // in force, when the item has no date to anchor a range on, or when no
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.
113
120
  timeline: (record, ctx) => {
114
- if (!hasTimeline.value) return null
115
- const range = roundOutward(record.start_date, record.end_date)
116
- if (range[0] == null) return null
121
+ if (!hasTimeline.value && !usesLocalTimeline?.value) return null
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]
124
+ if (findEvents({ begin: range[0], end: range[1] }).length === 0) return null
117
125
  return {
118
126
  heading: 'core.section.timeline',
119
127
  countries: timelineCountries.value.map((c) => ({ value: c.value, label: c.label ?? ctx.t('timeline.form.allCountries') })),
@@ -121,7 +129,7 @@ export function useExhibitionItemDetail(data, timeline) {
121
129
  events: (country) => findEvents({ country, begin: range[0], end: range[1] }),
122
130
  range,
123
131
  era: (year) => eraLabel(year, ctx.t),
124
- searchTo: periodSearch,
132
+ searchTo: (country) => periodSearch(country, roundOutward(record.start_date, record.end_date)),
125
133
  }
126
134
  },
127
135
  },
@@ -33,12 +33,13 @@ import { artistLine, pictureCredits, picturesInLanguage, recordArtist } from '..
33
33
  * The exhibition's item-sheet spec, over its data layer's `data`.
34
34
  *
35
35
  * Reads `data.defaultLang`, `data.itemRoute`, `data.labelOf`,
36
- * `data.mdInline`, `data.mdStrip`, `data.partnerById`, `data.projectName`,
37
- * `data.tr`, `data.translations`. `config` carries nothing today.
36
+ * `data.mdInline`, `data.mdStrip`, `data.partnerById`, `data.projectCode`,
37
+ * `data.projectName`, `data.tr`, `data.translations`. `config` carries
38
+ * nothing today.
38
39
  */
39
40
  export function useExhibitionSheet(data, config = {}) {
40
41
  void config
41
- const { defaultLang, itemRoute, labelOf, mdInline, mdStrip, partnerById, projectName, tr, translations } = data
42
+ const { defaultLang, itemRoute, labelOf, mdInline, mdStrip, partnerById, projectCode, projectName, tr, translations } = data
42
43
 
43
44
  const bothDescriptions = (c) => Boolean(c.text.description) && Boolean(c.text.short_description)
44
45
 
@@ -48,40 +49,60 @@ export function useExhibitionSheet(data, config = {}) {
48
49
  .filter(Boolean)
49
50
  .join(', ')
50
51
 
52
+ // Legacy's sheet printed a monument (a record with a `monumentId`) under
53
+ // its own labels and with the rows only a monument has; an object keeps
54
+ // the object's. Its architects row read "Architect(s) / Masterbuilder(s)"
55
+ // for a Discover Islamic Art or Explore record and "Artists" otherwise.
56
+ const monument = (c) => c.record.type === 'monument'
57
+ const object = (c) => !monument(c)
58
+ const islamicArt = (c) => ['ISL', 'EPM'].includes(projectCode(c.record))
59
+
51
60
  const fields = [
52
- { key: 'name', label: 'sheet.field.name', value: 'name' },
53
- { key: 'aka', label: 'sheet.field.alsoKnownAs', value: 'alternate_name' },
61
+ { key: 'name', label: 'sheet.field.name', value: 'name', when: object },
62
+ { key: 'monumentName', label: 'sheet.dxa.monumentName', value: 'name', when: monument },
63
+ { key: 'aka', label: 'sheet.field.alsoKnownAs', value: 'alternate_name', when: object },
64
+ { key: 'monumentAka', label: 'sheet.dxa.monumentAlsoKnownAs', value: 'alternate_name', when: monument },
54
65
  { key: 'location', label: 'sheet.field.location', value: (c) => [c.text.location, labelOf('countries', c.record.country_id)].filter(Boolean).join(', ') },
55
66
  // The holding museum, rendered by the wrapper's `museum` slot: the item's
56
67
  // holder text, then the partner it refers to (decision D3,
57
68
  // inventory-app#2015). The value is the partner's id when the package
58
69
  // carries the partner, otherwise the holder text, so the row stays for an
59
- // item whose holder has no partner page.
60
- { key: 'museum', label: 'sheet.field.holdingMuseum', value: (c) => (partnerById.value.get(c.record.partner_id) ? c.record.partner_id : (c.text.holder ?? '')), render: 'custom' },
70
+ // item whose holder has no partner page. A monument has no holding
71
+ // museum: legacy printed its responsible institution as written.
72
+ { key: 'museum', label: 'sheet.field.holdingMuseum', value: (c) => (partnerById.value.get(c.record.partner_id) ? c.record.partner_id : (c.text.holder ?? '')), render: 'custom', when: object },
73
+ { key: 'institution', label: 'sheet.dxa.responsibleInstitution', value: (c) => c.text.institution || c.text.holder, when: monument },
61
74
  { key: 'originalOwner', label: 'sheet.field.originalOwner', value: 'initial_owner' },
62
75
  { key: 'currentOwner', label: 'sheet.field.currentOwner', value: 'owner' },
63
- { key: 'date', label: 'sheet.field.date', value: 'dates' },
76
+ { key: 'date', label: 'sheet.field.date', value: 'dates', when: object },
77
+ { key: 'monumentDate', label: 'sheet.field.dateOfMonument', value: 'dates', when: monument },
78
+ { key: 'architects', label: 'sheet.field.architects', value: 'architects', when: islamicArt },
79
+ { key: 'monumentArtists', label: 'sheet.dxa.monumentArtists', value: 'architects', when: (c) => !islamicArt(c) },
64
80
  { key: 'artist', label: 'sheet.field.artists', value: (c) => artistLine(recordArtist(c.record, c.text), c.text, { style: 'line' }) },
65
81
  { key: 'scribe', label: 'sheet.field.scribe', value: 'scriber' },
66
82
  { key: 'workshop', label: 'sheet.field.workshop', value: 'workshop' },
67
- { key: 'type', label: 'sheet.field.type', value: 'type' },
83
+ { key: 'type', label: 'sheet.field.type', value: 'type', when: object },
84
+ { key: 'monumentType', label: 'sheet.dxa.monumentType', value: 'type', when: monument },
68
85
  { key: 'inventoryNumber', label: 'sheet.field.inventoryNumber', value: (c) => c.record.owner_reference },
69
86
  { key: 'materials', label: 'sheet.field.materials', value: (c) => c.text.materials, join: '; ' },
70
87
  { key: 'dimensions', label: 'sheet.field.dimensions', value: 'dimensions' },
71
88
  { key: 'dynasty', label: 'sheet.field.periodDynasty', value: (c) => c.text?.dynasty || dynastyNames(c) },
89
+ { key: 'patrons', label: 'sheet.field.patrons', value: 'patrons' },
72
90
  { key: 'production', label: 'sheet.field.placeOfProduction', value: 'place_of_production' },
73
91
  { key: 'provenance', label: 'sheet.field.provenance', value: 'provenance' },
74
92
  { key: 'binding', label: 'sheet.field.binding', value: 'binding_desc' },
93
+ { key: 'history', label: 'sheet.field.history', value: 'history', render: 'block' },
75
94
  { key: 'description', label: 'sheet.field.description', value: 'description', render: 'block' },
76
95
  // The only description there is, under the plain label; the toggled one
77
96
  // is the view's, folded after `description` when both exist.
78
97
  { key: 'shortDescription', label: 'sheet.field.description', value: 'short_description', render: 'block', when: (c) => !bothDescriptions(c) },
79
98
  { key: 'catalogue', label: 'sheet.field.catalogueLink', value: 'linkcatalogs', render: 'link' },
99
+ { key: 'datation', label: 'sheet.field.datationMethod', value: 'method_for_datation', when: object },
100
+ { key: 'monumentDatation', label: 'sheet.field.monumentDatationMethod', value: 'method_for_datation', when: monument },
80
101
  { key: 'obtention', label: 'sheet.field.obtentionMethod', value: 'obtention' },
81
- { key: 'datation', label: 'sheet.field.datationMethod', value: 'method_for_datation' },
82
102
  { key: 'provenanceMethod', label: 'sheet.field.provenanceMethod', value: 'method_for_provenance' },
83
103
  { key: 'bibliography', label: 'sheet.field.bibliography', value: 'bibliography', render: 'block' },
84
- { key: 'copyright', label: 'sheet.field.copyrightInformation', value: 'copyright' },
104
+ { key: 'copyright', label: 'sheet.field.copyrightInformation', value: 'copyright', when: object },
105
+ { key: 'monumentCopyright', label: 'sheet.dxa.monumentCopyrightInformation', value: 'copyright', when: monument },
85
106
  ]
86
107
 
87
108
  const itemSheet = {
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.
@@ -247,7 +247,8 @@ export function recordArtist(record, text) {
247
247
  * comma before the place, as it did there. Nothing without an artist.
248
248
  * - `'line'` — the galleries' and exhibitions' `DatabaseItem.vue`
249
249
  * (`returnArtistData`): on a line of its own under the artist,
250
- * `1660, Chemnitz - 1736, Augsburg`.
250
+ * `1660, Chemnitz - 1736, Augsburg`, then the period of activity
251
+ * (`period_activity`) on a line of its own.
251
252
  *
252
253
  * Islamic Art's sheet printed the artist alone. '' when there is nothing
253
254
  * to print.
@@ -261,7 +262,7 @@ export function artistLine(artist, text, { style = 'bracketed' } = {}) {
261
262
  if (style === 'line') {
262
263
  const birth = [born, bornAt].filter(Boolean).join(', ')
263
264
  const death = [died, diedAt].filter(Boolean).join(', ')
264
- return [name, [birth, death].filter(Boolean).join(' - ')].filter(Boolean).join(' \n')
265
+ return [name, [birth, death].filter(Boolean).join(' - '), lifePart(text?.period_activity)].filter(Boolean).join(' \n')
265
266
  }
266
267
  if (!name) return ''
267
268
  if (!(born || bornAt || died || diedAt)) return name