@museumwnf/viewer-core 2.5.2 → 2.7.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.5.2",
3
+ "version": "2.7.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",
@@ -28,7 +28,7 @@ export function searchFields({ dynastyLabel } = {}) {
28
28
  location: (item, text) => [text.location, item.country_id],
29
29
  provenance: (item, text) => text.provenance,
30
30
  patron: (item, text) => text.patrons ?? text.initial_owner,
31
- artist: (item, text) => [...(item.artist_names ?? []), text.architects],
31
+ artist: (item, text) => [...(item.artist_names ?? []), text.artist, text.architects],
32
32
  material: (item, text) => text.type,
33
33
  // The catch-all across the descriptive fields the others leave out.
34
34
  other: (item, text) => [
@@ -21,6 +21,13 @@
21
21
  // collapsed behind a toggle (the view's, folded after the description);
22
22
  // when only one exists it is relabelled plain "Description". EPM records
23
23
  // are the common case of the latter.
24
+ //
25
+ // The artist's life data goes on a line under the artist, and the Period /
26
+ // Dynasty row is legacy's free-text line (`dynasty`); the record's linked
27
+ // dynasties stand in when it has none, and keep their own popouts
28
+ // (decision D5, inventory-app#2233).
29
+
30
+ import { artistLine, recordArtist } from '../../record/derivations.js'
24
31
 
25
32
  /**
26
33
  * The exhibition's item-sheet spec, over its data layer's `data`.
@@ -54,14 +61,14 @@ export function useExhibitionSheet(data, config = {}) {
54
61
  { key: 'originalOwner', label: 'sheet.field.originalOwner', value: 'initial_owner' },
55
62
  { key: 'currentOwner', label: 'sheet.field.currentOwner', value: 'owner' },
56
63
  { key: 'date', label: 'sheet.field.date', value: 'dates' },
57
- { key: 'artist', label: 'sheet.field.artists', value: (c) => c.record.artist_names, join: ', ' },
64
+ { key: 'artist', label: 'sheet.field.artists', value: (c) => artistLine(recordArtist(c.record, c.text), c.text, { style: 'line' }) },
58
65
  { key: 'scribe', label: 'sheet.field.scribe', value: 'scriber' },
59
66
  { key: 'workshop', label: 'sheet.field.workshop', value: 'workshop' },
60
67
  { key: 'type', label: 'sheet.field.type', value: 'type' },
61
68
  { key: 'inventoryNumber', label: 'sheet.field.inventoryNumber', value: (c) => c.record.owner_reference },
62
69
  { key: 'materials', label: 'sheet.field.materials', value: (c) => c.text.materials, join: '; ' },
63
70
  { key: 'dimensions', label: 'sheet.field.dimensions', value: 'dimensions' },
64
- { key: 'dynasty', label: 'sheet.field.periodDynasty', value: dynastyNames },
71
+ { key: 'dynasty', label: 'sheet.field.periodDynasty', value: (c) => c.text?.dynasty || dynastyNames(c) },
65
72
  { key: 'production', label: 'sheet.field.placeOfProduction', value: 'place_of_production' },
66
73
  { key: 'provenance', label: 'sheet.field.provenance', value: 'provenance' },
67
74
  { key: 'binding', label: 'sheet.field.binding', value: 'binding_desc' },
@@ -2,6 +2,7 @@ import { computed } from 'vue'
2
2
  import { useI18n } from '../../i18n/index.js'
3
3
  import { entityRef } from '../../composables/useEntities.js'
4
4
  import { useCollectionTree } from '../../record/collectionTree.js'
5
+ import { recordArtist } from '../../record/derivations.js'
5
6
 
6
7
  // An exhibition's themes: the tour its theme pages, its themes list and its
7
8
  // theme galleries read (inventory-app#2053). The six exhibitions each carried
@@ -240,7 +241,8 @@ export function useExhibitionThemes(data) {
240
241
  if (sheet.alternate_name) {
241
242
  fields.push({ label: `${t('sheet.field.alsoKnownAs')}:`, value: mdInline(sheet.alternate_name) })
242
243
  }
243
- if (parent.artist_names?.length) fields.push({ label: '', value: parent.artist_names.join(', ') })
244
+ const artist = recordArtist(parent, sheet)
245
+ if (artist) fields.push({ label: '', value: artist })
244
246
  if (sheet.dates) fields.push({ label: '', value: sheet.dates })
245
247
  return fields
246
248
  }
@@ -21,6 +21,13 @@
21
21
  // collapsed behind a toggle (the view's, folded after the description);
22
22
  // when only one exists it is relabelled plain "Description". EPM records
23
23
  // are the common case of the latter.
24
+ //
25
+ // The artist's life data goes on a line under the artist, and the Period /
26
+ // Dynasty row is legacy's free-text line (`dynasty`); the record's linked
27
+ // dynasties stand in when it has none, and keep their own popouts
28
+ // (decision D5, inventory-app#2233).
29
+
30
+ import { artistLine, recordArtist } from '../../record/derivations.js'
24
31
 
25
32
  /**
26
33
  * The gallery's item-sheet spec, over its data layer's `data`.
@@ -54,14 +61,14 @@ export function useGallerySheet(data, config = {}) {
54
61
  { key: 'originalOwner', label: 'sheet.field.originalOwner', value: 'initial_owner' },
55
62
  { key: 'currentOwner', label: 'sheet.field.currentOwner', value: 'owner' },
56
63
  { key: 'date', label: 'sheet.field.date', value: 'dates' },
57
- { key: 'artist', label: 'sheet.field.artists', value: (c) => c.record.artist_names, join: ', ' },
64
+ { key: 'artist', label: 'sheet.field.artists', value: (c) => artistLine(recordArtist(c.record, c.text), c.text, { style: 'line' }) },
58
65
  { key: 'scribe', label: 'sheet.field.scribe', value: 'scriber' },
59
66
  { key: 'workshop', label: 'sheet.field.workshop', value: 'workshop' },
60
67
  { key: 'type', label: 'sheet.field.type', value: 'type' },
61
68
  { key: 'inventoryNumber', label: 'sheet.field.inventoryNumber', value: (c) => c.record.owner_reference },
62
69
  { key: 'materials', label: 'sheet.field.materials', value: (c) => c.text.materials, join: '; ' },
63
70
  { key: 'dimensions', label: 'sheet.field.dimensions', value: 'dimensions' },
64
- { key: 'dynasty', label: 'sheet.field.periodDynasty', value: dynastyNames },
71
+ { key: 'dynasty', label: 'sheet.field.periodDynasty', value: (c) => c.text?.dynasty || dynastyNames(c) },
65
72
  { key: 'production', label: 'sheet.field.placeOfProduction', value: 'place_of_production' },
66
73
  { key: 'provenance', label: 'sheet.field.provenance', value: 'provenance' },
67
74
  { key: 'binding', label: 'sheet.field.binding', value: 'binding_desc' },
package/src/index.js CHANGED
@@ -39,7 +39,8 @@ export {
39
39
  glossaryEntries, glossaryTermsFor, glossaryTermsForText, sheetRows, useRecordSheet,
40
40
  } from './record/recordSheet.js'
41
41
  export {
42
- citation, relatedRecords, searchGlossary, timelineLinkFor, useGlossaryPopup, useRelatedRecords,
42
+ artistLine, citation, recordArtist, relatedRecords, removeEndingPoint, searchGlossary, timelineLinkFor, useGlossaryPopup,
43
+ useRelatedRecords,
43
44
  } from './record/derivations.js'
44
45
  export { buildCollectionTree, collectionTreeFromThemes, useCollectionTree } from './record/collectionTree.js'
45
46
  export { groupByCountry, partnerHierarchy, partnerView } from './record/partners.js'
@@ -152,3 +152,74 @@ export function timelineLinkFor(record, { name = 'timeline-results', keys = {},
152
152
  if (to != null) query[keys.end ?? 'end'] = String(to)
153
153
  return { name, query }
154
154
  }
155
+
156
+ // ── Legacy's sheet lines ───────────────────────────────────────────────────
157
+ //
158
+ // How legacy's sheets printed a value, written once so each website prints
159
+ // it the way its own legacy did.
160
+
161
+ /**
162
+ * `text` without the period(s) that end it, as legacy's `removeEndingPoint`
163
+ * printed most sheet values — sparing a period after "C", as in "B.C.".
164
+ * Anything but a string comes back as ''.
165
+ *
166
+ * Legacy's `preg_replace("/([^C])\.+[[:space:]]*$/", "\\1", …)`, read as a
167
+ * scan from the end rather than as that regex, which backtracks
168
+ * polynomially on a long run of periods. Same answers: the final run of
169
+ * periods goes with the whitespace after it; after a "C", or at the very
170
+ * start, the run's first period stays.
171
+ */
172
+ export function removeEndingPoint(text) {
173
+ if (typeof text !== 'string') return ''
174
+ const body = text.trimEnd()
175
+ let start = body.length
176
+ while (start > 0 && body[start - 1] === '.') start--
177
+ if (start === body.length) return text
178
+ if (start === 0 || body[start - 1] === 'C') return body.length - start > 1 ? body.slice(0, start + 1) : text
179
+ return body.slice(0, start)
180
+ }
181
+
182
+ const lifePart = (value) => (typeof value === 'string' ? value.trim() : '')
183
+
184
+ /**
185
+ * The artist the sheet names: the translation's own `artist` when it has one,
186
+ * else the record's `artist_names`. A Sharing History record has no artist
187
+ * entity, and legacy wrote its artist per language ("Unknown", "Inconnu"),
188
+ * so the package carries it on each translation (inventory-app#2233, C22).
189
+ */
190
+ export function recordArtist(record, text) {
191
+ return lifePart(text?.artist) || (record?.artist_names ?? []).join(', ')
192
+ }
193
+
194
+ /**
195
+ * The artist line as Markdown: `artist`, then the artist's life data the
196
+ * record's translation carries (`artist_birthdate`, `artist_birthplace`,
197
+ * `artist_deathdate`, `artist_deathplace`), each part only when set and
198
+ * joined exactly as legacy joined it, in one of legacy's two shapes:
199
+ *
200
+ * - `'bracketed'` — Baroque Art's and Sharing History's `database_item.php`:
201
+ * on the artist's line, after a no-break space,
202
+ * `Name (1660, Chemnitz-1736, Augsburg)`; a missing birth date keeps the
203
+ * comma before the place, as it did there. Nothing without an artist.
204
+ * - `'line'` — the galleries' and exhibitions' `DatabaseItem.vue`
205
+ * (`returnArtistData`): on a line of its own under the artist,
206
+ * `1660, Chemnitz - 1736, Augsburg`.
207
+ *
208
+ * Islamic Art's sheet printed the artist alone. '' when there is nothing
209
+ * to print.
210
+ */
211
+ export function artistLine(artist, text, { style = 'bracketed' } = {}) {
212
+ const name = lifePart(artist)
213
+ const born = lifePart(text?.artist_birthdate)
214
+ const bornAt = lifePart(text?.artist_birthplace)
215
+ const died = lifePart(text?.artist_deathdate)
216
+ const diedAt = lifePart(text?.artist_deathplace)
217
+ if (style === 'line') {
218
+ const birth = [born, bornAt].filter(Boolean).join(', ')
219
+ const death = [died, diedAt].filter(Boolean).join(', ')
220
+ return [name, [birth, death].filter(Boolean).join(' - ')].filter(Boolean).join(' \n')
221
+ }
222
+ if (!name) return ''
223
+ if (!(born || bornAt || died || diedAt)) return name
224
+ return `${name} (${born}${bornAt ? `, ${bornAt}` : ''}${died ? `-${died}` : ''}${diedAt ? `, ${diedAt}` : ''})`
225
+ }