@museumwnf/viewer-layout 3.76.1 → 3.78.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-layout",
3
- "version": "3.76.1",
3
+ "version": "3.78.0",
4
4
  "description": "Page structure for MWNF websites: PageShell composing seven optional, token-styled sections, the content components a page is made of, and the composed views a website names instead of writing a page.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -18,6 +18,7 @@
18
18
  "src/styles/dxa-gallery.css",
19
19
  "src/styles/dxa-exhibition.css",
20
20
  "src/dxa/testing.js",
21
+ "src/dxa/relatedKind.js",
21
22
  "src/minisite/testing.js"
22
23
  ],
23
24
  "main": "./dist/index.js",
@@ -30,8 +31,6 @@
30
31
  "./dxa": "./dist/dxa.js",
31
32
  "./standalone": "./dist/standalone.js",
32
33
  "./minisite": "./dist/minisite.js",
33
- "./publications": "./dist/publications.js",
34
- "./travels": "./dist/travels.js",
35
34
  "./dxa/gallery.css": "./src/styles/dxa-gallery.css",
36
35
  "./dxa/exhibition.css": "./src/styles/dxa-exhibition.css",
37
36
  "./dxa/testing": "./src/dxa/testing.js",
@@ -0,0 +1,11 @@
1
+ // Which of an item sheet's two related blocks a `related_items` entry goes
2
+ // in: legacy's Related Objects (dxa-client DatabaseItem.vue drew only the
3
+ // related objects) or Related Monuments (Discover Islamic Art's sheet drew
4
+ // the monuments apart, under "Related monuments"). The exporters write each
5
+ // entry's `type` since inventory-app#2611; before that, an entry in the
6
+ // package takes its record's type and one outside counts as an object, as
7
+ // the sheet drew it then.
8
+ export function relatedKind(ref, itemById) {
9
+ const type = ref?.type ?? itemById?.get(ref?.id)?.type
10
+ return type === 'monument' ? 'monument' : 'object'
11
+ }
@@ -12,6 +12,7 @@
12
12
  import { describe, expect, it, vi } from 'vitest'
13
13
  import { loadEntities, mergeMessages } from '@museumwnf/viewer-core'
14
14
  import * as viewerCore from '@museumwnf/viewer-core'
15
+ import { relatedKind } from './relatedKind.js'
15
16
 
16
17
  // A link to a legacy site that has a new one is drawn with the new site's
17
18
  // address from viewer-core 2.18.0 on (inventory-app#2482), as stored before.
@@ -168,25 +169,37 @@ function searchTests(mountSite, loadItems) {
168
169
  }
169
170
 
170
171
  // Legacy's Related Objects: every related object a thumbnail under "Related
171
- // Objects", those outside this site's package too (inventory-app#2491). One
172
- // outside whose project has a site of its own links to it there. Both
173
- // families drew them so; `heading` is the family's own word for them. An
172
+ // Objects", those outside this site's package too (inventory-app#2491), and
173
+ // the related monuments apart under "Related Monuments", after them, as
174
+ // Discover Islamic Art's sheet drew them (inventory-app#2611). One outside
175
+ // whose project has a site of its own links to it there. Both families draw
176
+ // them so; `headings` are the family's own words for the two blocks. An
174
177
  // exhibition's sheet shows only the records its build carries in English.
175
- function relatedObjectsTest(mountSite, manifest, heading) {
176
- it('draws every related object as a thumbnail, those outside the package too', async () => {
178
+ function relatedObjectsTest(mountSite, manifest, headings) {
179
+ it('draws every related object and monument as a thumbnail, apart, those outside the package too', async () => {
177
180
  const [items] = await loadEntities(['items'])
181
+ const byId = new Map(items.map((i) => [i.id, i]))
182
+ const isMonument = (ref) => relatedKind(ref, byId) === 'monument'
178
183
  const shown = items.filter((i) => !i.languages?.length || i.languages.includes('en'))
179
- const item = shown.find((i) => (i.related_items ?? []).some((ref) => ref.in_package === false))
180
- ?? shown.find((i) => (i.related_items ?? []).length)
184
+ const related = (i) => i.related_items ?? []
185
+ const item = shown.find((i) => related(i).some(isMonument) && related(i).some((ref) => !isMonument(ref)) && related(i).some((ref) => ref.in_package === false))
186
+ ?? shown.find((i) => related(i).some((ref) => ref.in_package === false))
187
+ ?? shown.find((i) => related(i).length)
181
188
  if (!item) return
182
189
  const { app, host } = await mountSite(`#/item/${item.id}?lang=en`)
183
190
  await vi.waitFor(() => expect(host.querySelector('.mwnf-related-objects__tile')).not.toBeNull(), WAIT)
184
- const block = host.querySelector('.mwnf-related-objects')
185
- expect(block.querySelector('.mwnf-related-objects__heading').textContent).toBe(heading)
186
- expect(block.querySelectorAll('.mwnf-related-objects__tile')).toHaveLength(item.related_items.length)
191
+ const expected = [
192
+ [headings.objects, item.related_items.filter((ref) => !isMonument(ref))],
193
+ [headings.monuments, item.related_items.filter(isMonument)],
194
+ ].filter(([, refs]) => refs.length)
195
+ const blocks = [...host.querySelectorAll('.mwnf-related-objects')]
196
+ expect(blocks.map((block) => block.querySelector('.mwnf-related-objects__heading').textContent)).toEqual(expected.map(([heading]) => heading))
197
+ expected.forEach(([, refs], index) => {
198
+ expect(blocks[index].querySelectorAll('.mwnf-related-objects__tile')).toHaveLength(refs.length)
199
+ })
187
200
  const outside = item.related_items.find((ref) => ref.in_package === false && manifest.projects[ref.project_id]?.home_site)
188
201
  if (outside) {
189
- const hrefs = [...block.querySelectorAll('.mwnf-related-objects__link')].map((a) => a.getAttribute('href') ?? '')
202
+ const hrefs = blocks.flatMap((block) => [...block.querySelectorAll('.mwnf-related-objects__link')].map((a) => a.getAttribute('href') ?? ''))
190
203
  expect(hrefs.some((href) => href.endsWith(`/item/${outside.id}`))).toBe(true)
191
204
  }
192
205
  expect(host.querySelector('.mwnf-sheet-related__references')).toBeNull()
@@ -370,7 +383,7 @@ export function describeGallerySmoke({ config, sharedTexts, ownTexts, manifest,
370
383
  app.unmount()
371
384
  }, 60000)
372
385
 
373
- relatedObjectsTest(mountSite, manifest, sharedTexts.en['gallery.related.objects'])
386
+ relatedObjectsTest(mountSite, manifest, { objects: sharedTexts.en['gallery.related.objects'], monuments: sharedTexts.en['gallery.related.monuments'] })
374
387
 
375
388
  // The Source box takes the colour `projectColors` gives the item's
376
389
  // project, and the citation its name from the manifest.
@@ -704,7 +717,7 @@ export function describeExhibitionSmoke({
704
717
  app.unmount()
705
718
  }, 60000)
706
719
 
707
- relatedObjectsTest(mountSite, manifest, messages.en['exhibition.related.objects'])
720
+ relatedObjectsTest(mountSite, manifest, { objects: messages.en['exhibition.related.objects'], monuments: messages.en['exhibition.related.monuments'] })
708
721
 
709
722
  // On display in: this exhibition's own pages that show the item open
710
723
  // here, as legacy's did.
@@ -1,81 +0,0 @@
1
- import { n as e } from "./chrome-Bv_mLlHM.js";
2
- import { t } from "./legacyFacets-CQw2NYL4.js";
3
- import { partnerView as n, renderInline as r, useSiteConfig as i } from "@museumwnf/viewer-core";
4
- import { useExhibitionCollection as a, useExhibitionData as o, useExhibitionItemDetail as s, useExhibitionPartner as c, useExhibitionThemes as l, useExhibitionTimeline as u } from "@museumwnf/viewer-core/dxa";
5
- // src/dxa/exhibition/data.js
6
- var d = o(), f = a(d), p = u(d, f), m = c(d), h = l(d), { itemDetail: g } = s(d, p), { defaultLang: _, tr: v, md: y, mdInline: b, mdStrip: ee, labelOf: x, loadEnglish: S, exhibition: C, relatedContent: w, items: T, itemById: E, countries: D, timelines: te, visiblePartners: O, visiblePartnerById: k, isHiddenPartner: A, itemRoute: j, partnerRoute: M, partnerObjectsRoute: N, countryLabelFromCode: P, exhibitionTitle: F, exhibitionSubtitle: I, exhibitionHeadline: ne, bannerCaption: L, projectName: R } = d;
7
- function z(t, n = "hi_res") {
8
- return e(i().chrome, t) ?? d.chromeImage(t, n);
9
- }
10
- var { haystack: B, tile: re, countryIdForCode: ie } = f, V = t(f.FACETS), H = {
11
- ...f.collectionResults,
12
- facets: V
13
- }, U = (e, t) => String(e ?? "").localeCompare(String(t ?? ""), "en", { sensitivity: "base" });
14
- function W(e, t) {
15
- let n = String(e ?? "").split(":"), r = String(t ?? "").split(":");
16
- for (let e = 0; e < Math.max(n.length, r.length); e++) {
17
- let t = n[e] ?? "", i = r[e] ?? "";
18
- if (t !== i) return /^\d+$/.test(t) && /^\d+$/.test(i) ? Number(t) - Number(i) : t.localeCompare(i, "en");
19
- }
20
- return 0;
21
- }
22
- function G(e, t) {
23
- return U(x("countries", e.country_id), x("countries", t.country_id)) || U(x("partners", e.partner_id), x("partners", t.partner_id)) || W(e.backward_compatibility, t.backward_compatibility);
24
- }
25
- var K = {
26
- pageSize: 20,
27
- sort: {
28
- undated: "first",
29
- tiebreak: (e, t) => G(e, t)
30
- }
31
- };
32
- function q(e) {
33
- let t = v("items", e.id, _), n = e.type === "monument" ? "" : t.dates ?? "";
34
- return {
35
- id: e.id,
36
- image: e.images?.[0]?.url ?? "",
37
- imageAlt: x("items", e.id),
38
- name: r(t.name ?? e.internal_name ?? ""),
39
- date: n.length > 80 ? `${n.slice(0, 80)}...` : n,
40
- partner: x("partners", e.partner_id),
41
- place: [t.location, x("countries", e.country_id)].filter(Boolean).join(", "),
42
- project: R(e, _) ?? "",
43
- to: j(e)
44
- };
45
- }
46
- var { hasTimeline: J, timelineSpec: Y, timelineGallerySpec: X } = p, { partnerListSpec: Z, partnerSheetSpec: Q } = m, $ = {
47
- countryLabel: (e) => x("countries", e),
48
- md: y,
49
- mdInline: b,
50
- route: M,
51
- objectsRoute: N,
52
- hidden: A
53
- }, ae = {
54
- spec: {
55
- ...Q,
56
- media: () => [],
57
- sourceCredit: !1
58
- },
59
- visible: (e) => !!k(e),
60
- view: (e, t) => n(e, {
61
- ...v("partners", e.id, _),
62
- ...t
63
- }, $),
64
- labels: {
65
- partner: {
66
- objects: "exhibition.action.viewItems",
67
- homepage: "exhibition.partner.homepage"
68
- },
69
- institution: {
70
- objects: "exhibition.action.viewItems",
71
- homepage: "exhibition.action.institutionHomepage"
72
- }
73
- },
74
- className: "mwnf-dxa-exhibition-profile",
75
- media: {
76
- thumbsFrom: 1,
77
- creditCaption: !1
78
- },
79
- legacyMap: { label: "exhibition.partner.mapLabel" }
80
- };
81
- export { Y as A, ae as C, w as D, M as E, k as M, O as N, h as O, y as S, N as T, T as _, D as a, q as b, C as c, F as d, J as f, j as g, g as h, H as i, v as j, X as k, ne as l, E as m, L as n, P as o, B as p, z as r, _ as s, V as t, I as u, x as v, Z as w, S as x, K as y };