@internetarchive/collection-browser 1.5.0 → 1.5.1

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.
Files changed (67) hide show
  1. package/dist/src/collection-browser.js +3 -1
  2. package/dist/src/collection-browser.js.map +1 -1
  3. package/dist/src/styles/item-image-styles.js +13 -13
  4. package/dist/src/styles/item-image-styles.js.map +1 -1
  5. package/dist/src/tiles/base-tile-component.d.ts +18 -0
  6. package/dist/src/tiles/base-tile-component.js +60 -0
  7. package/dist/src/tiles/base-tile-component.js.map +1 -0
  8. package/dist/src/tiles/grid/account-tile.d.ts +3 -5
  9. package/dist/src/tiles/grid/account-tile.js +19 -11
  10. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  11. package/dist/src/tiles/grid/collection-tile.d.ts +3 -5
  12. package/dist/src/tiles/grid/collection-tile.js +18 -9
  13. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  14. package/dist/src/tiles/grid/item-tile.d.ts +4 -9
  15. package/dist/src/tiles/grid/item-tile.js +24 -22
  16. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  17. package/dist/src/tiles/list/tile-list-compact-header.d.ts +2 -8
  18. package/dist/src/tiles/list/tile-list-compact-header.js +23 -26
  19. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  20. package/dist/src/tiles/list/tile-list-compact.d.ts +4 -13
  21. package/dist/src/tiles/list/tile-list-compact.js +34 -48
  22. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  23. package/dist/src/tiles/list/tile-list.d.ts +3 -13
  24. package/dist/src/tiles/list/tile-list.js +36 -60
  25. package/dist/src/tiles/list/tile-list.js.map +1 -1
  26. package/dist/src/tiles/tile-dispatcher.d.ts +4 -13
  27. package/dist/src/tiles/tile-dispatcher.js +28 -38
  28. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  29. package/dist/src/tiles/tile-display-value-provider.d.ts +43 -0
  30. package/dist/src/tiles/tile-display-value-provider.js +81 -0
  31. package/dist/src/tiles/tile-display-value-provider.js.map +1 -0
  32. package/dist/test/collection-browser.test.js +1 -1
  33. package/dist/test/collection-browser.test.js.map +1 -1
  34. package/dist/test/tiles/grid/item-tile.test.js +13 -0
  35. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  36. package/dist/test/tiles/list/tile-list-compact.test.js +14 -0
  37. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
  38. package/dist/test/tiles/list/tile-list.test.js +4 -2
  39. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  40. package/dist/test/tiles/tile-display-value-provider.test.d.ts +1 -0
  41. package/dist/test/tiles/tile-display-value-provider.test.js +142 -0
  42. package/dist/test/tiles/tile-display-value-provider.test.js.map +1 -0
  43. package/package.json +1 -1
  44. package/src/collection-browser.ts +3 -1
  45. package/src/styles/item-image-styles.ts +13 -13
  46. package/src/tiles/base-tile-component.ts +48 -0
  47. package/src/tiles/grid/account-tile.ts +19 -8
  48. package/src/tiles/grid/collection-tile.ts +18 -14
  49. package/src/tiles/grid/item-tile.ts +25 -24
  50. package/src/tiles/list/tile-list-compact-header.ts +23 -18
  51. package/src/tiles/list/tile-list-compact.ts +34 -29
  52. package/src/tiles/list/tile-list.ts +47 -61
  53. package/src/tiles/tile-dispatcher.ts +34 -27
  54. package/src/tiles/tile-display-value-provider.ts +106 -0
  55. package/test/collection-browser.test.ts +1 -1
  56. package/test/tiles/grid/item-tile.test.ts +15 -0
  57. package/test/tiles/list/tile-list-compact.test.ts +16 -0
  58. package/test/tiles/list/tile-list.test.ts +4 -2
  59. package/test/tiles/tile-display-value-provider.test.ts +172 -0
  60. package/dist/src/tiles/list/account-label.d.ts +0 -1
  61. package/dist/src/tiles/list/account-label.js +0 -7
  62. package/dist/src/tiles/list/account-label.js.map +0 -1
  63. package/dist/src/tiles/list/date-label.d.ts +0 -1
  64. package/dist/src/tiles/list/date-label.js +0 -13
  65. package/dist/src/tiles/list/date-label.js.map +0 -1
  66. package/src/tiles/list/account-label.ts +0 -6
  67. package/src/tiles/list/date-label.ts +0 -12
@@ -1,4 +1,4 @@
1
- import { css, html, LitElement, nothing, PropertyValues } from 'lit';
1
+ import { css, html, nothing, PropertyValues } from 'lit';
2
2
  import { customElement, property, query } from 'lit/decorators.js';
3
3
  import { ifDefined } from 'lit/directives/if-defined.js';
4
4
  import type {
@@ -6,8 +6,7 @@ import type {
6
6
  SharedResizeObserverResizeHandlerInterface,
7
7
  } from '@internetarchive/shared-resize-observer';
8
8
  import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
9
- import type { SortParam } from '@internetarchive/search-service';
10
- import type { TileDisplayMode, TileModel } from '../models';
9
+ import type { TileDisplayMode } from '../models';
11
10
  import './grid/collection-tile';
12
11
  import './grid/item-tile';
13
12
  import './grid/account-tile';
@@ -16,6 +15,7 @@ import './list/tile-list';
16
15
  import './list/tile-list-compact';
17
16
  import './list/tile-list-compact-header';
18
17
  import type { TileHoverPane } from './hover/tile-hover-pane';
18
+ import { BaseTileComponent } from './base-tile-component';
19
19
  import {
20
20
  HoverPaneController,
21
21
  HoverPaneControllerInterface,
@@ -25,39 +25,35 @@ import {
25
25
 
26
26
  @customElement('tile-dispatcher')
27
27
  export class TileDispatcher
28
- extends LitElement
28
+ extends BaseTileComponent
29
29
  implements
30
30
  SharedResizeObserverResizeHandlerInterface,
31
31
  HoverPaneProviderInterface
32
32
  {
33
- @property({ type: String }) tileDisplayMode?: TileDisplayMode;
34
-
35
- @property({ type: Object }) model?: TileModel;
36
-
37
- @property({ type: String }) baseNavigationUrl?: string;
38
-
39
- @property({ type: Number }) currentWidth?: number;
33
+ /*
34
+ * Reactive properties inherited from BaseTileComponent:
35
+ * - model?: TileModel;
36
+ * - currentWidth?: number;
37
+ * - currentHeight?: number;
38
+ * - baseNavigationUrl?: string;
39
+ * - baseImageUrl?: string;
40
+ * - collectionPagePath?: string;
41
+ * - sortParam: SortParam | null = null;
42
+ * - creatorFilter?: string;
43
+ * - mobileBreakpoint?: number;
44
+ * - loggedIn = false;
45
+ */
40
46
 
41
- @property({ type: Number }) currentHeight?: number;
47
+ @property({ type: String }) tileDisplayMode?: TileDisplayMode;
42
48
 
43
49
  @property({ type: Object }) resizeObserver?: SharedResizeObserverInterface;
44
50
 
45
51
  @property({ type: Object })
46
52
  collectionNameCache?: CollectionNameCacheInterface;
47
53
 
48
- @property({ type: Object }) sortParam: SortParam | null = null;
49
-
50
- @property({ type: Number }) mobileBreakpoint?: number;
51
-
52
- @property({ type: String }) baseImageUrl?: string;
53
-
54
- @property({ type: Boolean }) loggedIn = false;
55
-
56
54
  /** Whether this tile should include a hover pane at all (for applicable tile modes) */
57
55
  @property({ type: Boolean }) enableHoverPane = false;
58
56
 
59
- @property({ type: String }) collectionPagePath: string = '/details/';
60
-
61
57
  private hoverPaneController?: HoverPaneControllerInterface;
62
58
 
63
59
  @query('#container')
@@ -149,9 +145,10 @@ export class TileDispatcher
149
145
  return `${this.baseNavigationUrl}${this.model.href}`;
150
146
  }
151
147
 
152
- const isCollection = this.model.mediatype === 'collection';
153
- const basePath = isCollection ? this.collectionPagePath : '/details/';
154
- return `${this.baseNavigationUrl}${basePath}${this.model.identifier}`;
148
+ return this.displayValueProvider.itemPageUrl(
149
+ this.model.identifier,
150
+ this.model.mediatype === 'collection'
151
+ );
155
152
  }
156
153
 
157
154
  /**
@@ -226,10 +223,12 @@ export class TileDispatcher
226
223
  private get tile() {
227
224
  const {
228
225
  model,
226
+ collectionPagePath,
229
227
  baseNavigationUrl,
230
228
  currentWidth,
231
229
  currentHeight,
232
230
  sortParam,
231
+ creatorFilter,
233
232
  mobileBreakpoint,
234
233
  } = this;
235
234
 
@@ -241,9 +240,11 @@ export class TileDispatcher
241
240
  case 'collection':
242
241
  return html`<collection-tile
243
242
  .model=${model}
243
+ .collectionPagePath=${collectionPagePath}
244
244
  .baseImageUrl=${this.baseImageUrl}
245
245
  .currentWidth=${currentWidth}
246
246
  .currentHeight=${currentHeight}
247
+ .creatorFilter=${creatorFilter}
247
248
  ?showInfoButton=${!this.isHoverEnabled}
248
249
  @infoButtonPressed=${this.tileInfoButtonPressed}
249
250
  >
@@ -251,9 +252,11 @@ export class TileDispatcher
251
252
  case 'account':
252
253
  return html`<account-tile
253
254
  .model=${model}
255
+ .collectionPagePath=${collectionPagePath}
254
256
  .baseImageUrl=${this.baseImageUrl}
255
257
  .currentWidth=${currentWidth}
256
258
  .currentHeight=${currentHeight}
259
+ .creatorFilter=${creatorFilter}
257
260
  ?showInfoButton=${!this.isHoverEnabled}
258
261
  @infoButtonPressed=${this.tileInfoButtonPressed}
259
262
  >
@@ -261,11 +264,13 @@ export class TileDispatcher
261
264
  default:
262
265
  return html`<item-tile
263
266
  .model=${model}
267
+ .collectionPagePath=${collectionPagePath}
264
268
  .currentWidth=${this.currentWidth}
265
269
  .currentHeight=${this.currentHeight}
266
270
  .collectionNameCache=${this.collectionNameCache}
267
271
  .baseImageUrl=${this.baseImageUrl}
268
272
  .sortParam=${sortParam}
273
+ .creatorFilter=${creatorFilter}
269
274
  .loggedIn=${this.loggedIn}
270
275
  ?showInfoButton=${!this.isHoverEnabled}
271
276
  @infoButtonPressed=${this.tileInfoButtonPressed}
@@ -275,11 +280,12 @@ export class TileDispatcher
275
280
  case 'list-compact':
276
281
  return html`<tile-list-compact
277
282
  .model=${model}
278
- .collectionPagePath=${this.collectionPagePath}
283
+ .collectionPagePath=${collectionPagePath}
279
284
  .currentWidth=${currentWidth}
280
285
  .currentHeight=${currentHeight}
281
286
  .baseNavigationUrl=${baseNavigationUrl}
282
287
  .sortParam=${sortParam}
288
+ .creatorFilter=${creatorFilter}
283
289
  .mobileBreakpoint=${mobileBreakpoint}
284
290
  .baseImageUrl=${this.baseImageUrl}
285
291
  .loggedIn=${this.loggedIn}
@@ -288,12 +294,13 @@ export class TileDispatcher
288
294
  case 'list-detail':
289
295
  return html`<tile-list
290
296
  .model=${model}
291
- .collectionPagePath=${this.collectionPagePath}
297
+ .collectionPagePath=${collectionPagePath}
292
298
  .collectionNameCache=${this.collectionNameCache}
293
299
  .currentWidth=${currentWidth}
294
300
  .currentHeight=${currentHeight}
295
301
  .baseNavigationUrl=${baseNavigationUrl}
296
302
  .sortParam=${sortParam}
303
+ .creatorFilter=${creatorFilter}
297
304
  .mobileBreakpoint=${mobileBreakpoint}
298
305
  .baseImageUrl=${this.baseImageUrl}
299
306
  .loggedIn=${this.loggedIn}
@@ -0,0 +1,106 @@
1
+ import { nothing } from 'lit';
2
+ import { msg, str } from '@lit/localize';
3
+ import type { SortParam } from '@internetarchive/search-service';
4
+ import type { TileModel } from '../models';
5
+
6
+ /**
7
+ * A class encapsulating shared logic for converting model values into display values
8
+ * across different types of tiles.
9
+ */
10
+ export class TileDisplayValueProvider {
11
+ private model?: TileModel;
12
+
13
+ private baseNavigationUrl?: string;
14
+
15
+ private collectionPagePath?: string;
16
+
17
+ private sortParam?: SortParam;
18
+
19
+ private creatorFilter?: string;
20
+
21
+ constructor(
22
+ options: {
23
+ model?: TileModel;
24
+ baseNavigationUrl?: string;
25
+ collectionPagePath?: string;
26
+ sortParam?: SortParam;
27
+ creatorFilter?: string;
28
+ } = {}
29
+ ) {
30
+ this.model = options.model;
31
+ this.baseNavigationUrl = options.baseNavigationUrl;
32
+ this.collectionPagePath = options.collectionPagePath ?? '/details/';
33
+ this.sortParam = options.sortParam;
34
+ this.creatorFilter = options.creatorFilter;
35
+ }
36
+
37
+ /**
38
+ * Examines the creator(s) for the given tile model, returning
39
+ * the first creator whose name matches the provided filter
40
+ * (or simply the first creator overall if no filter is provided).
41
+ */
42
+ get firstCreatorMatchingFilter(): string | undefined {
43
+ let matchingCreator;
44
+
45
+ // If we're filtering by creator initial and have multiple creators, we want
46
+ // to surface the first creator who matches the filter.
47
+ if (this.creatorFilter && this.model?.creators.length) {
48
+ const firstLetter = this.creatorFilter; // This is just to satisfy tsc
49
+ matchingCreator = this.model.creators.find(creator =>
50
+ // Decompose combining characters first, so that e.g., filtering on E matches É too.
51
+ // Then remove anything that isn't strictly alphabetic, since our filters currently
52
+ // only handle A-Z. The first such letter (if one exists) is what needs to match.
53
+ creator
54
+ .normalize('NFD')
55
+ .replace(/[^A-Z]+/gi, '')
56
+ .toUpperCase()
57
+ .startsWith(firstLetter)
58
+ );
59
+ }
60
+
61
+ return matchingCreator ?? this.model?.creator;
62
+ }
63
+
64
+ /**
65
+ * The label indicating what year an account item was created.
66
+ * E.g., "Archivist since 2015"
67
+ */
68
+ get accountLabel(): string {
69
+ return this.model?.dateAdded
70
+ ? msg(str`Archivist since ${this.model.dateAdded.getFullYear()}`)
71
+ : '';
72
+ }
73
+
74
+ /**
75
+ * The readable label for the current sort if it is a type of date sort,
76
+ * or the empty string otherwise.
77
+ */
78
+ get dateLabel(): string {
79
+ switch (this.sortParam?.field) {
80
+ case 'publicdate':
81
+ return msg('Archived');
82
+ case 'reviewdate':
83
+ return msg('Reviewed');
84
+ case 'addeddate':
85
+ return msg('Added');
86
+ case 'date':
87
+ return msg('Published');
88
+ default:
89
+ return '';
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Produces a URL pointing at the item page for the given identifier,
95
+ * using the current base URL and the correct path based on whether the
96
+ * item is specified to be a collection (default false).
97
+ */
98
+ itemPageUrl(
99
+ identifier: string,
100
+ isCollection = false
101
+ ): string | typeof nothing {
102
+ if (!identifier || this.baseNavigationUrl == null) return nothing;
103
+ const basePath = isCollection ? this.collectionPagePath : '/details/';
104
+ return `${this.baseNavigationUrl}${basePath}${identifier}`;
105
+ }
106
+ }
@@ -973,7 +973,7 @@ describe('Collection Browser', () => {
973
973
  await el.updateComplete;
974
974
  await el.initialSearchComplete;
975
975
  await el.updateComplete;
976
- await nextTick();
976
+ await aTimeout(50);
977
977
 
978
978
  const infiniteScroller = el.shadowRoot?.querySelector('infinite-scroller');
979
979
  expect(infiniteScroller).to.exist;
@@ -297,6 +297,21 @@ describe('Item Tile', () => {
297
297
  expect(dateSortedBy?.textContent?.trim()).to.equal('reviewed Jan 01, 2013');
298
298
  });
299
299
 
300
+ it('should show the first creator matching the letter filter, if defined', async () => {
301
+ const model: Partial<TileModel> = {
302
+ creator: 'foo',
303
+ creators: ['foo', 'bar', 'baz'],
304
+ };
305
+
306
+ const el = await fixture<ItemTile>(html`
307
+ <item-tile .model=${model} .creatorFilter=${'B'}> </item-tile>
308
+ `);
309
+
310
+ const creator = el.shadowRoot?.querySelector('.created-by');
311
+ expect(creator).to.exist;
312
+ expect(creator?.textContent?.trim()).to.match(/by\s+bar/);
313
+ });
314
+
300
315
  it('should render with snippet block when it has snippets', async () => {
301
316
  const el = await fixture<ItemTile>(html`
302
317
  <item-tile .model=${{ snippets: ['some {{{snippet}}} text'] }}>
@@ -210,4 +210,20 @@ describe('List Tile Compact', () => {
210
210
  expect(dateColumn).to.exist;
211
211
  expect(dateColumn?.textContent?.trim()).to.equal('Jan 01, 2013');
212
212
  });
213
+
214
+ it('should show the first creator matching the letter filter, if defined', async () => {
215
+ const model: Partial<TileModel> = {
216
+ creator: 'foo',
217
+ creators: ['foo', 'bar', 'baz'],
218
+ };
219
+
220
+ const el = await fixture<TileListCompact>(html`
221
+ <tile-list-compact .model=${model} .creatorFilter=${'B'}>
222
+ </tile-list-compact>
223
+ `);
224
+
225
+ const creator = el.shadowRoot?.getElementById('creator');
226
+ expect(creator).to.exist;
227
+ expect(creator?.textContent?.trim()).to.equal('bar');
228
+ });
213
229
  });
@@ -87,6 +87,7 @@ describe('List Tile', () => {
87
87
  const el = await fixture<TileList>(html`
88
88
  <tile-list
89
89
  .model=${{ collections: ['deemphasize', 'community', 'foo'] }}
90
+ .baseNavigationUrl=${'base'}
90
91
  .collectionNameCache=${collectionNameCache}
91
92
  >
92
93
  </tile-list>
@@ -98,7 +99,7 @@ describe('List Tile', () => {
98
99
  const collectionLinks = collectionsRow?.querySelectorAll('a[href]');
99
100
  expect(collectionLinks?.length).to.equal(1);
100
101
  expect(collectionLinks?.item(0).getAttribute('href')).to.equal(
101
- '/details/foo'
102
+ 'base/details/foo'
102
103
  );
103
104
  });
104
105
 
@@ -107,6 +108,7 @@ describe('List Tile', () => {
107
108
  const el = await fixture<TileList>(html`
108
109
  <tile-list
109
110
  .model=${{ collections: ['fav-foo', 'bar'] }}
111
+ .baseNavigationUrl=${'base'}
110
112
  .collectionNameCache=${collectionNameCache}
111
113
  >
112
114
  </tile-list>
@@ -118,7 +120,7 @@ describe('List Tile', () => {
118
120
  const collectionLinks = collectionsRow?.querySelectorAll('a[href]');
119
121
  expect(collectionLinks?.length).to.equal(1);
120
122
  expect(collectionLinks?.item(0).getAttribute('href')).to.equal(
121
- '/details/bar'
123
+ 'base/details/bar'
122
124
  );
123
125
  });
124
126
 
@@ -0,0 +1,172 @@
1
+ import { expect } from '@open-wc/testing';
2
+ import { nothing } from 'lit';
3
+ import { TileDisplayValueProvider } from '../../src/tiles/tile-display-value-provider';
4
+ import type { TileModel } from '../../src/models';
5
+
6
+ describe('Tile Display Value Provider', () => {
7
+ describe('basic construction', () => {
8
+ it('constructs w/ no options', () => {
9
+ const provider = new TileDisplayValueProvider();
10
+ expect(provider).to.exist;
11
+ });
12
+
13
+ it('constructs w/ options', () => {
14
+ const provider = new TileDisplayValueProvider({
15
+ model: {} as TileModel,
16
+ baseNavigationUrl: 'foo',
17
+ collectionPagePath: 'bar',
18
+ sortParam: { field: 'baz', direction: 'asc' },
19
+ creatorFilter: 'X',
20
+ });
21
+ expect(provider).to.exist;
22
+ });
23
+ });
24
+
25
+ describe('firstCreatorMatchingFilter', () => {
26
+ it('provides undefined creator when no model set', () => {
27
+ const provider = new TileDisplayValueProvider();
28
+ expect(provider.firstCreatorMatchingFilter).to.be.undefined;
29
+ });
30
+
31
+ it('provides creator from model with no filter', () => {
32
+ const provider = new TileDisplayValueProvider({
33
+ model: { creator: 'foo', creators: ['foo', 'bar', 'baz'] } as TileModel,
34
+ });
35
+
36
+ expect(provider.firstCreatorMatchingFilter).to.equal('foo');
37
+ });
38
+
39
+ it('provides first creator matching filter when present', () => {
40
+ const provider = new TileDisplayValueProvider({
41
+ model: { creator: 'foo', creators: ['foo', 'bar', 'baz'] } as TileModel,
42
+ creatorFilter: 'B',
43
+ });
44
+
45
+ expect(provider.firstCreatorMatchingFilter).to.equal('bar');
46
+ });
47
+
48
+ it('matches letters with diacritics', () => {
49
+ const provider = new TileDisplayValueProvider({
50
+ model: {
51
+ creator: 'foo',
52
+ creators: ['foo', 'émile', 'ernest'],
53
+ } as TileModel,
54
+ creatorFilter: 'E',
55
+ });
56
+
57
+ expect(provider.firstCreatorMatchingFilter).to.equal('émile');
58
+ });
59
+
60
+ it('ignores non-alphabetical characters when matching', () => {
61
+ const provider = new TileDisplayValueProvider({
62
+ model: {
63
+ creator: 'foo',
64
+ creators: ['foo', '"(bar)"', 'baz'],
65
+ } as TileModel,
66
+ creatorFilter: 'B',
67
+ });
68
+
69
+ expect(provider.firstCreatorMatchingFilter).to.equal('"(bar)"');
70
+ });
71
+ });
72
+
73
+ describe('accountLabel', () => {
74
+ it('provides empty account label when no model', () => {
75
+ const provider = new TileDisplayValueProvider();
76
+ expect(provider.accountLabel).to.equal('');
77
+ });
78
+
79
+ it('provides empty account label when no date added', () => {
80
+ const provider = new TileDisplayValueProvider({ model: {} as TileModel });
81
+ expect(provider.accountLabel).to.equal('');
82
+ });
83
+
84
+ it('provides Archivist label from date added', () => {
85
+ const provider = new TileDisplayValueProvider({
86
+ model: { dateAdded: new Date(2010, 1, 2) } as TileModel,
87
+ });
88
+
89
+ expect(provider.accountLabel).to.equal('Archivist since 2010');
90
+ });
91
+ });
92
+
93
+ describe('dateLabel', () => {
94
+ it('provides empty date label when no sort param', () => {
95
+ const provider = new TileDisplayValueProvider();
96
+ expect(provider.dateLabel).to.equal('');
97
+ });
98
+
99
+ it('provides empty date label when sorting by non-date', () => {
100
+ const provider = new TileDisplayValueProvider({
101
+ sortParam: { field: 'downloads', direction: 'desc' },
102
+ });
103
+ expect(provider.dateLabel).to.equal('');
104
+ });
105
+
106
+ it('provides correct date label for publicdate', () => {
107
+ const provider = new TileDisplayValueProvider({
108
+ sortParam: { field: 'publicdate', direction: 'asc' },
109
+ });
110
+
111
+ expect(provider.dateLabel).to.equal('Archived');
112
+ });
113
+
114
+ it('provides correct date label for reviewdate', () => {
115
+ const provider = new TileDisplayValueProvider({
116
+ sortParam: { field: 'reviewdate', direction: 'asc' },
117
+ });
118
+
119
+ expect(provider.dateLabel).to.equal('Reviewed');
120
+ });
121
+
122
+ it('provides correct date label for addeddate', () => {
123
+ const provider = new TileDisplayValueProvider({
124
+ sortParam: { field: 'addeddate', direction: 'asc' },
125
+ });
126
+
127
+ expect(provider.dateLabel).to.equal('Added');
128
+ });
129
+
130
+ it('provides correct date label for published date', () => {
131
+ const provider = new TileDisplayValueProvider({
132
+ sortParam: { field: 'date', direction: 'asc' },
133
+ });
134
+
135
+ expect(provider.dateLabel).to.equal('Published');
136
+ });
137
+ });
138
+
139
+ describe('itemPageUrl', () => {
140
+ it('provides nothing when no base url set', () => {
141
+ const provider = new TileDisplayValueProvider();
142
+ expect(provider.itemPageUrl('foo')).to.equal(nothing);
143
+ });
144
+
145
+ it('provides nothing when identifier is empty', () => {
146
+ const provider = new TileDisplayValueProvider({
147
+ baseNavigationUrl: 'foo',
148
+ });
149
+ expect(provider.itemPageUrl('')).to.equal(nothing);
150
+ });
151
+
152
+ it('builds correct url from base and identifier', () => {
153
+ const provider = new TileDisplayValueProvider({
154
+ baseNavigationUrl: 'base',
155
+ });
156
+ expect(provider.itemPageUrl('foo')).to.equal('base/details/foo');
157
+ });
158
+
159
+ it('allows base url to be empty', () => {
160
+ const provider = new TileDisplayValueProvider({ baseNavigationUrl: '' });
161
+ expect(provider.itemPageUrl('foo')).to.equal('/details/foo');
162
+ });
163
+
164
+ it('uses provided collection base path for collections', () => {
165
+ const provider = new TileDisplayValueProvider({
166
+ baseNavigationUrl: 'base',
167
+ collectionPagePath: '/collection/',
168
+ });
169
+ expect(provider.itemPageUrl('foo', true)).to.equal('base/collection/foo');
170
+ });
171
+ });
172
+ });
@@ -1 +0,0 @@
1
- export declare function accountLabel(date: Date | undefined): string;
@@ -1,7 +0,0 @@
1
- export function accountLabel(date) {
2
- if (!date) {
3
- return '';
4
- }
5
- return `Archivist since ${date.getFullYear()}`;
6
- }
7
- //# sourceMappingURL=account-label.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"account-label.js","sourceRoot":"","sources":["../../../../src/tiles/list/account-label.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAC,IAAsB;IACjD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,CAAC;KACX;IACD,OAAO,mBAAmB,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;AACjD,CAAC","sourcesContent":["export function accountLabel(date: Date | undefined): string {\n if (!date) {\n return '';\n }\n return `Archivist since ${date.getFullYear()}`;\n}\n"]}
@@ -1 +0,0 @@
1
- export declare function dateLabel(sortField: string | undefined): string;
@@ -1,13 +0,0 @@
1
- export function dateLabel(sortField) {
2
- switch (sortField) {
3
- case 'publicdate':
4
- return 'Archived';
5
- case 'reviewdate':
6
- return 'Reviewed';
7
- case 'addeddate':
8
- return 'Added';
9
- default:
10
- return 'Published';
11
- }
12
- }
13
- //# sourceMappingURL=date-label.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"date-label.js","sourceRoot":"","sources":["../../../../src/tiles/list/date-label.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,SAA6B;IACrD,QAAQ,SAAS,EAAE;QACjB,KAAK,YAAY;YACf,OAAO,UAAU,CAAC;QACpB,KAAK,YAAY;YACf,OAAO,UAAU,CAAC;QACpB,KAAK,WAAW;YACd,OAAO,OAAO,CAAC;QACjB;YACE,OAAO,WAAW,CAAC;KACtB;AACH,CAAC","sourcesContent":["export function dateLabel(sortField: string | undefined): string {\n switch (sortField) {\n case 'publicdate':\n return 'Archived';\n case 'reviewdate':\n return 'Reviewed';\n case 'addeddate':\n return 'Added';\n default:\n return 'Published';\n }\n}\n"]}
@@ -1,6 +0,0 @@
1
- export function accountLabel(date: Date | undefined): string {
2
- if (!date) {
3
- return '';
4
- }
5
- return `Archivist since ${date.getFullYear()}`;
6
- }
@@ -1,12 +0,0 @@
1
- export function dateLabel(sortField: string | undefined): string {
2
- switch (sortField) {
3
- case 'publicdate':
4
- return 'Archived';
5
- case 'reviewdate':
6
- return 'Reviewed';
7
- case 'addeddate':
8
- return 'Added';
9
- default:
10
- return 'Published';
11
- }
12
- }