@internetarchive/collection-browser 2.7.6-alpha2 → 2.7.6-alpha4
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/dist/src/app-root.d.ts +8 -0
- package/dist/src/app-root.js +30 -9
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +9 -1
- package/dist/src/collection-browser.js +25 -17
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/manage/manage-bar.d.ts +9 -18
- package/dist/src/manage/manage-bar.js +8 -33
- package/dist/src/manage/manage-bar.js.map +1 -1
- package/dist/src/manage/remove-items-modal-content.d.ts +1 -5
- package/dist/src/manage/remove-items-modal-content.js.map +1 -1
- package/dist/src/models.d.ts +9 -0
- package/dist/src/models.js.map +1 -1
- package/dist/test/manage/manage-bar.test.d.ts +1 -0
- package/dist/test/manage/manage-bar.test.js +25 -10
- package/dist/test/manage/manage-bar.test.js.map +1 -1
- package/dist/test/manage/remove-items-modal-content.test.d.ts +1 -0
- package/dist/test/manage/remove-items-modal-content.test.js +66 -0
- package/dist/test/manage/remove-items-modal-content.test.js.map +1 -0
- package/package.json +1 -1
- package/src/app-root.ts +32 -10
- package/src/collection-browser.ts +33 -17
- package/src/manage/manage-bar.ts +13 -49
- package/src/manage/remove-items-modal-content.ts +1 -6
- package/src/models.ts +10 -0
- package/test/manage/manage-bar.test.ts +41 -18
- package/test/manage/remove-items-modal-content.test.ts +82 -0
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { LitElement, TemplateResult, CSSResultGroup
|
|
1
|
+
import { LitElement, TemplateResult, CSSResultGroup } from 'lit';
|
|
2
2
|
import { type ModalManagerInterface } from '@internetarchive/modal-manager';
|
|
3
|
+
import type { ManageableItem } from '../models';
|
|
3
4
|
import './remove-items-modal-content';
|
|
4
|
-
export interface ManageableItem {
|
|
5
|
-
identifier: string;
|
|
6
|
-
title?: string;
|
|
7
|
-
dateStr?: string;
|
|
8
|
-
}
|
|
9
5
|
export declare class ManageBar extends LitElement {
|
|
10
6
|
/**
|
|
11
7
|
* The label displayed in front of the management buttons
|
|
@@ -23,6 +19,10 @@ export declare class ManageBar extends LitElement {
|
|
|
23
19
|
* Array of items that have been selected for management
|
|
24
20
|
*/
|
|
25
21
|
selectedItems: Array<ManageableItem>;
|
|
22
|
+
/**
|
|
23
|
+
* Message shows as note in the modal when removing items
|
|
24
|
+
*/
|
|
25
|
+
manageViewModelMsg?: string;
|
|
26
26
|
/**
|
|
27
27
|
* Whether to show the "Select All" button (default false)
|
|
28
28
|
*/
|
|
@@ -31,25 +31,16 @@ export declare class ManageBar extends LitElement {
|
|
|
31
31
|
* Whether to show the "Unselect All" button (default false)
|
|
32
32
|
*/
|
|
33
33
|
showUnselectAll: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Item removal failure message, if any
|
|
36
|
-
*/
|
|
37
|
-
isItemDeleted: boolean;
|
|
38
34
|
/**
|
|
39
35
|
* Whether to show "Item Manager the items" button (default false)
|
|
40
36
|
*/
|
|
41
|
-
|
|
37
|
+
showItemManageButton: boolean;
|
|
42
38
|
/**
|
|
43
39
|
* Whether to active delete button for selectable items
|
|
44
40
|
*/
|
|
45
41
|
removeAllowed: boolean;
|
|
46
|
-
updated(changed: PropertyValues): void;
|
|
47
42
|
render(): TemplateResult;
|
|
48
43
|
private cancelClicked;
|
|
49
|
-
/**
|
|
50
|
-
* Shows a modal dialog confirming the list of items to be removed
|
|
51
|
-
* @param items Which items to list in the modal
|
|
52
|
-
*/
|
|
53
44
|
private removeItemsClicked;
|
|
54
45
|
private manageItemsClicked;
|
|
55
46
|
private selectAllClicked;
|
|
@@ -62,10 +53,10 @@ export declare class ManageBar extends LitElement {
|
|
|
62
53
|
/**
|
|
63
54
|
* Shows a modal dialog indicating that item removal is being processed
|
|
64
55
|
*/
|
|
65
|
-
|
|
56
|
+
showRemoveItemsProcessingModal(): void;
|
|
66
57
|
/**
|
|
67
58
|
* Shows a modal dialog indicating that an error occurred while removing items
|
|
68
59
|
*/
|
|
69
|
-
|
|
60
|
+
showRemoveItemsErrorModal(): void;
|
|
70
61
|
static get styles(): CSSResultGroup;
|
|
71
62
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { msg } from '@lit/localize';
|
|
3
|
-
import { LitElement, html, css
|
|
3
|
+
import { LitElement, html, css } from 'lit';
|
|
4
4
|
import { customElement, property } from 'lit/decorators.js';
|
|
5
5
|
import { when } from 'lit/directives/when.js';
|
|
6
6
|
import { ModalConfig, } from '@internetarchive/modal-manager';
|
|
@@ -25,32 +25,15 @@ let ManageBar = class ManageBar extends LitElement {
|
|
|
25
25
|
* Whether to show the "Unselect All" button (default false)
|
|
26
26
|
*/
|
|
27
27
|
this.showUnselectAll = false;
|
|
28
|
-
/**
|
|
29
|
-
* Item removal failure message, if any
|
|
30
|
-
*/
|
|
31
|
-
this.isItemDeleted = true;
|
|
32
28
|
/**
|
|
33
29
|
* Whether to show "Item Manager the items" button (default false)
|
|
34
30
|
*/
|
|
35
|
-
this.
|
|
31
|
+
this.showItemManageButton = false;
|
|
36
32
|
/**
|
|
37
33
|
* Whether to active delete button for selectable items
|
|
38
34
|
*/
|
|
39
35
|
this.removeAllowed = false;
|
|
40
36
|
}
|
|
41
|
-
updated(changed) {
|
|
42
|
-
var _a, _b;
|
|
43
|
-
if (changed.has('isItemDeleted')) {
|
|
44
|
-
console.log(this.isItemDeleted);
|
|
45
|
-
if (this.isItemDeleted === false) {
|
|
46
|
-
this.showRemoveItemsErrorModal();
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
(_a = this.modalManager) === null || _a === void 0 ? void 0 : _a.closeModal();
|
|
50
|
-
(_b = this.modalManager) === null || _b === void 0 ? void 0 : _b.classList.remove('remove-items');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
37
|
render() {
|
|
55
38
|
return html `
|
|
56
39
|
<div class="manage-container">
|
|
@@ -66,7 +49,7 @@ let ManageBar = class ManageBar extends LitElement {
|
|
|
66
49
|
>
|
|
67
50
|
${msg('Remove selected items')}
|
|
68
51
|
</button>
|
|
69
|
-
${when(this.
|
|
52
|
+
${when(this.showItemManageButton, () => html ` <button
|
|
70
53
|
class="ia-button warning"
|
|
71
54
|
?disabled=${!this.removeAllowed}
|
|
72
55
|
@click=${this.manageItemsClicked}
|
|
@@ -94,12 +77,7 @@ let ManageBar = class ManageBar extends LitElement {
|
|
|
94
77
|
cancelClicked() {
|
|
95
78
|
this.dispatchEvent(new CustomEvent('cancel'));
|
|
96
79
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Shows a modal dialog confirming the list of items to be removed
|
|
99
|
-
* @param items Which items to list in the modal
|
|
100
|
-
*/
|
|
101
80
|
removeItemsClicked() {
|
|
102
|
-
this.showRemoveItemsProcessingModal();
|
|
103
81
|
this.dispatchEvent(new CustomEvent('removeItems'));
|
|
104
82
|
}
|
|
105
83
|
manageItemsClicked() {
|
|
@@ -117,13 +95,10 @@ let ManageBar = class ManageBar extends LitElement {
|
|
|
117
95
|
*/
|
|
118
96
|
showRemoveItemsModal() {
|
|
119
97
|
var _a, _b;
|
|
120
|
-
const delayMessage = this.activeTabId === 'uploads'
|
|
121
|
-
? msg('Note: it may take a few minutes for these items to stop appearing in your uploads list.')
|
|
122
|
-
: undefined;
|
|
123
98
|
const customModalContent = html `
|
|
124
99
|
<remove-items-modal-content
|
|
125
100
|
.items=${this.selectedItems}
|
|
126
|
-
.message=${
|
|
101
|
+
.message=${this.manageViewModelMsg}
|
|
127
102
|
@confirm=${() => this.removeItemsClicked()}
|
|
128
103
|
></remove-items-modal-content>
|
|
129
104
|
`;
|
|
@@ -243,6 +218,9 @@ __decorate([
|
|
|
243
218
|
__decorate([
|
|
244
219
|
property({ type: Object })
|
|
245
220
|
], ManageBar.prototype, "selectedItems", void 0);
|
|
221
|
+
__decorate([
|
|
222
|
+
property({ type: String })
|
|
223
|
+
], ManageBar.prototype, "manageViewModelMsg", void 0);
|
|
246
224
|
__decorate([
|
|
247
225
|
property({ type: Boolean })
|
|
248
226
|
], ManageBar.prototype, "showSelectAll", void 0);
|
|
@@ -251,10 +229,7 @@ __decorate([
|
|
|
251
229
|
], ManageBar.prototype, "showUnselectAll", void 0);
|
|
252
230
|
__decorate([
|
|
253
231
|
property({ type: Boolean })
|
|
254
|
-
], ManageBar.prototype, "
|
|
255
|
-
__decorate([
|
|
256
|
-
property({ type: Boolean })
|
|
257
|
-
], ManageBar.prototype, "showManageButton", void 0);
|
|
232
|
+
], ManageBar.prototype, "showItemManageButton", void 0);
|
|
258
233
|
__decorate([
|
|
259
234
|
property({ type: Boolean })
|
|
260
235
|
], ManageBar.prototype, "removeAllowed", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manage-bar.js","sourceRoot":"","sources":["../../../src/manage/manage-bar.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EACL,UAAU,EACV,IAAI,EACJ,GAAG,GAIJ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EACL,WAAW,GAEZ,MAAM,gCAAgC,CAAC;AACxC,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,8BAA8B,CAAC;AAStC,IAAa,SAAS,GAAtB,MAAa,SAAU,SAAQ,UAAU;IAAzC;;QACE;;WAEG;QACyB,UAAK,GAAG,GAAG,CAAC,wBAAwB,CAAC,CAAC;QAYlE;;WAEG;QACyB,kBAAa,GAA0B,EAAE,CAAC;QAEtE;;WAEG;QAC0B,kBAAa,GAAG,KAAK,CAAC;QAEnD;;WAEG;QAC0B,oBAAe,GAAG,KAAK,CAAC;QAErD;;WAEG;QAC0B,kBAAa,GAAG,IAAI,CAAC;QAElD;;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CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QACjD,MAAA,IAAI,CAAC,YAAY,0CAAE,SAAS,CAAC;YAC3B,MAAM;YACN,uBAAuB,EAAE,GAAG,EAAE;;gBAC5B,MAAA,IAAI,CAAC,YAAY,0CAAE,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YACtD,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;QACN,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiChB,CAAC;IACJ,CAAC;CACF,CAAA;AA/P6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCAAuC;AAKtC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAsB;AAKrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAsC;AAKrC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAA2C;AAKzC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAuB;AAKtB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAyB;AAKxB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAsB;AAKrB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAA0B;AAKzB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAuB;AA5CxC,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CAmQrB;SAnQY,SAAS","sourcesContent":["import { msg } from '@lit/localize';\nimport {\n LitElement,\n html,\n css,\n TemplateResult,\n CSSResultGroup,\n PropertyValues,\n} from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { when } from 'lit/directives/when.js';\nimport {\n ModalConfig,\n type ModalManagerInterface,\n} from '@internetarchive/modal-manager';\nimport iaButtonStyle from '../styles/ia-button';\nimport './remove-items-modal-content';\n\nexport interface ManageableItem {\n identifier: string;\n title?: string;\n dateStr?: string;\n}\n\n@customElement('manage-bar')\nexport class ManageBar extends LitElement {\n /**\n * The label displayed in front of the management buttons\n */\n @property({ type: String }) label = msg('Select items to remove');\n\n /**\n * Specifies the context in which the collection browser is being used\n */\n @property({ type: String }) activeTabId?: string;\n\n /**\n * The shared modal manager component for displaying modal dialogs on this page\n */\n @property({ type: Object }) modalManager?: ModalManagerInterface;\n\n /**\n * Array of items that have been selected for management\n */\n @property({ type: Object }) selectedItems: Array<ManageableItem> = [];\n\n /**\n * Whether to show the \"Select All\" button (default false)\n */\n @property({ type: Boolean }) showSelectAll = false;\n\n /**\n * Whether to show the \"Unselect All\" button (default false)\n */\n @property({ type: Boolean }) showUnselectAll = false;\n\n /**\n * Item removal failure message, if any\n */\n @property({ type: Boolean }) isItemDeleted = true;\n\n /**\n * Whether to show \"Item Manager the items\" button (default false)\n */\n @property({ type: Boolean }) showManageButton = false;\n\n /**\n * Whether to active delete button for selectable items\n */\n @property({ type: Boolean }) removeAllowed = false;\n\n updated(changed: PropertyValues): void {\n if (changed.has('isItemDeleted')) {\n console.log(this.isItemDeleted)\n if (this.isItemDeleted === false) {\n this.showRemoveItemsErrorModal();\n } else {\n this.modalManager?.closeModal();\n this.modalManager?.classList.remove('remove-items');\n }\n }\n }\n\n render(): TemplateResult {\n return html`\n <div class=\"manage-container\">\n <span class=\"manage-label\">${this.label}</span>\n <div class=\"manage-buttons\">\n <button class=\"ia-button dark\" @click=${this.cancelClicked}>\n ${msg('Cancel')}\n </button>\n <button\n class=\"ia-button danger\"\n ?disabled=${!this.removeAllowed}\n @click=${this.showRemoveItemsModal}\n >\n ${msg('Remove selected items')}\n </button>\n ${when(\n this.showManageButton,\n () => html` <button\n class=\"ia-button warning\"\n ?disabled=${!this.removeAllowed}\n @click=${this.manageItemsClicked}\n >\n ${msg('Item Manager the items')}\n </button>`\n )}\n <div class=\"selection-buttons\">\n ${when(\n this.showSelectAll,\n () => html` <button\n class=\"ia-button link select-all-btn\"\n @click=${this.selectAllClicked}\n >\n ${msg('Select all')}\n </button>`\n )}\n ${when(\n this.showUnselectAll,\n () => html` <button\n class=\"ia-button link unselect-all-btn\"\n @click=${this.unselectAllClicked}\n >\n ${msg('Unselect all')}\n </button>`\n )}\n </div>\n </div>\n </div>\n `;\n }\n\n private cancelClicked(): void {\n this.dispatchEvent(new CustomEvent('cancel'));\n }\n\n /**\n * Shows a modal dialog confirming the list of items to be removed\n * @param items Which items to list in the modal\n */\n private removeItemsClicked(): void {\n this.showRemoveItemsProcessingModal();\n this.dispatchEvent(new CustomEvent('removeItems'));\n }\n\n private manageItemsClicked(): void {\n this.dispatchEvent(new CustomEvent('manageItems'));\n }\n\n private selectAllClicked(): void {\n this.dispatchEvent(new CustomEvent('selectAll'));\n }\n\n private unselectAllClicked(): void {\n this.dispatchEvent(new CustomEvent('unselectAll'));\n }\n\n /**\n * Shows a modal dialog confirming the list of items to be removed\n * @param items Which items to list in the modal\n */\n private showRemoveItemsModal(): void {\n const delayMessage =\n this.activeTabId === 'uploads'\n ? msg(\n 'Note: it may take a few minutes for these items to stop appearing in your uploads list.'\n )\n : undefined;\n\n const customModalContent = html`\n <remove-items-modal-content\n .items=${this.selectedItems}\n .message=${delayMessage}\n @confirm=${() => this.removeItemsClicked()}\n ></remove-items-modal-content>\n `;\n\n const config = new ModalConfig({\n showProcessingIndicator: false,\n processingImageMode: 'processing',\n bodyColor: '#fff',\n headerColor: '#194880',\n showHeaderLogo: false,\n closeOnBackdropClick: true,\n title: html`${msg('Are you sure you want to remove these items?')}`,\n });\n\n this.modalManager?.classList.add('remove-items');\n this.modalManager?.showModal({\n config,\n customModalContent,\n userClosedModalCallback: () => {\n this.modalManager?.classList.remove('remove-items');\n },\n });\n }\n\n /**\n * Shows a modal dialog indicating that item removal is being processed\n */\n private showRemoveItemsProcessingModal(): void {\n const config = new ModalConfig({\n showProcessingIndicator: true,\n processingImageMode: 'processing',\n bodyColor: '#fff',\n headerColor: '#194880',\n showHeaderLogo: false,\n closeOnBackdropClick: true,\n title: html`${msg('Removing selected items...')}`,\n });\n\n this.modalManager?.classList.add('remove-items');\n this.modalManager?.showModal({\n config,\n userClosedModalCallback: () => {\n this.modalManager?.classList.remove('remove-items');\n },\n });\n }\n\n /**\n * Shows a modal dialog indicating that an error occurred while removing items\n */\n private showRemoveItemsErrorModal(): void {\n const config = new ModalConfig({\n showProcessingIndicator: false,\n processingImageMode: 'processing',\n bodyColor: '#fff',\n headerColor: '#691916',\n showHeaderLogo: false,\n closeOnBackdropClick: true,\n title: html`${msg('Error: unable to remove items')}`,\n message: html`${msg(\n 'An error occurred while removing items. Please try again in a few minutes.',\n )}`,\n });\n\n this.modalManager?.classList.add('remove-items');\n this.modalManager?.showModal({\n config,\n userClosedModalCallback: () => {\n this.modalManager?.classList.remove('remove-items');\n },\n });\n }\n\n static get styles(): CSSResultGroup {\n return css`\n ${iaButtonStyle}\n .manage-container {\n display: flex;\n align-items: center;\n column-gap: 5px;\n padding: 20px 0 20px;\n flex-wrap: wrap;\n }\n\n .manage-label {\n display: inline-block;\n font-weight: bold;\n font-size: 1.8rem;\n padding-right: 10px;\n }\n\n .manage-buttons {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n column-gap: 5px;\n }\n\n .selection-buttons {\n display: inherit;\n }\n\n .ia-button,\n button {\n padding: 6px 12px;\n font-size: 1.4rem;\n margin: 3px 0;\n }\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"manage-bar.js","sourceRoot":"","sources":["../../../src/manage/manage-bar.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;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AAY,0CAAE,SAAS,CAAC;YAC3B,MAAM;YACN,uBAAuB,EAAE,GAAG,EAAE;;gBAC5B,MAAA,IAAI,CAAC,YAAY,0CAAE,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YACtD,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;QACN,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiChB,CAAC;IACJ,CAAC;CACF,CAAA;AAvO6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCAAuC;AAKtC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAsB;AAKrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAsC;AAKrC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAA2C;AAK1C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAA6B;AAK3B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAuB;AAKtB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAyB;AAKxB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAA8B;AAK7B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAuB;AA5CxC,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CA2OrB;SA3OY,SAAS","sourcesContent":["import { msg } from '@lit/localize';\nimport { LitElement, html, css, TemplateResult, CSSResultGroup } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { when } from 'lit/directives/when.js';\nimport {\n ModalConfig,\n type ModalManagerInterface,\n} from '@internetarchive/modal-manager';\nimport type { ManageableItem } from '../models';\nimport iaButtonStyle from '../styles/ia-button';\nimport './remove-items-modal-content';\n\n@customElement('manage-bar')\nexport class ManageBar extends LitElement {\n /**\n * The label displayed in front of the management buttons\n */\n @property({ type: String }) label = msg('Select items to remove');\n\n /**\n * Specifies the context in which the collection browser is being used\n */\n @property({ type: String }) activeTabId?: string;\n\n /**\n * The shared modal manager component for displaying modal dialogs on this page\n */\n @property({ type: Object }) modalManager?: ModalManagerInterface;\n\n /**\n * Array of items that have been selected for management\n */\n @property({ type: Object }) selectedItems: Array<ManageableItem> = [];\n\n /**\n * Message shows as note in the modal when removing items\n */\n @property({ type: String }) manageViewModelMsg?: string;\n\n /**\n * Whether to show the \"Select All\" button (default false)\n */\n @property({ type: Boolean }) showSelectAll = false;\n\n /**\n * Whether to show the \"Unselect All\" button (default false)\n */\n @property({ type: Boolean }) showUnselectAll = false;\n\n /**\n * Whether to show \"Item Manager the items\" button (default false)\n */\n @property({ type: Boolean }) showItemManageButton = false;\n\n /**\n * Whether to active delete button for selectable items\n */\n @property({ type: Boolean }) removeAllowed = false;\n\n render(): TemplateResult {\n return html`\n <div class=\"manage-container\">\n <span class=\"manage-label\">${this.label}</span>\n <div class=\"manage-buttons\">\n <button class=\"ia-button dark\" @click=${this.cancelClicked}>\n ${msg('Cancel')}\n </button>\n <button\n class=\"ia-button danger\"\n ?disabled=${!this.removeAllowed}\n @click=${this.showRemoveItemsModal}\n >\n ${msg('Remove selected items')}\n </button>\n ${when(\n this.showItemManageButton,\n () => html` <button\n class=\"ia-button warning\"\n ?disabled=${!this.removeAllowed}\n @click=${this.manageItemsClicked}\n >\n ${msg('Item Manager the items')}\n </button>`\n )}\n <div class=\"selection-buttons\">\n ${when(\n this.showSelectAll,\n () => html` <button\n class=\"ia-button link select-all-btn\"\n @click=${this.selectAllClicked}\n >\n ${msg('Select all')}\n </button>`\n )}\n ${when(\n this.showUnselectAll,\n () => html` <button\n class=\"ia-button link unselect-all-btn\"\n @click=${this.unselectAllClicked}\n >\n ${msg('Unselect all')}\n </button>`\n )}\n </div>\n </div>\n </div>\n `;\n }\n\n private cancelClicked(): void {\n this.dispatchEvent(new CustomEvent('cancel'));\n }\n\n private removeItemsClicked(): void {\n this.dispatchEvent(new CustomEvent('removeItems'));\n }\n\n private manageItemsClicked(): void {\n this.dispatchEvent(new CustomEvent('manageItems'));\n }\n\n private selectAllClicked(): void {\n this.dispatchEvent(new CustomEvent('selectAll'));\n }\n\n private unselectAllClicked(): void {\n this.dispatchEvent(new CustomEvent('unselectAll'));\n }\n\n /**\n * Shows a modal dialog confirming the list of items to be removed\n * @param items Which items to list in the modal\n */\n private showRemoveItemsModal(): void {\n const customModalContent = html`\n <remove-items-modal-content\n .items=${this.selectedItems}\n .message=${this.manageViewModelMsg}\n @confirm=${() => this.removeItemsClicked()}\n ></remove-items-modal-content>\n `;\n\n const config = new ModalConfig({\n showProcessingIndicator: false,\n processingImageMode: 'processing',\n bodyColor: '#fff',\n headerColor: '#194880',\n showHeaderLogo: false,\n closeOnBackdropClick: true,\n title: html`${msg('Are you sure you want to remove these items?')}`,\n });\n\n this.modalManager?.classList.add('remove-items');\n this.modalManager?.showModal({\n config,\n customModalContent,\n userClosedModalCallback: () => {\n this.modalManager?.classList.remove('remove-items');\n },\n });\n }\n\n /**\n * Shows a modal dialog indicating that item removal is being processed\n */\n showRemoveItemsProcessingModal(): void {\n const config = new ModalConfig({\n showProcessingIndicator: true,\n processingImageMode: 'processing',\n bodyColor: '#fff',\n headerColor: '#194880',\n showHeaderLogo: false,\n closeOnBackdropClick: true,\n title: html`${msg('Removing selected items...')}`,\n });\n\n this.modalManager?.classList.add('remove-items');\n this.modalManager?.showModal({\n config,\n userClosedModalCallback: () => {\n this.modalManager?.classList.remove('remove-items');\n },\n });\n }\n\n /**\n * Shows a modal dialog indicating that an error occurred while removing items\n */\n showRemoveItemsErrorModal(): void {\n const config = new ModalConfig({\n showProcessingIndicator: false,\n processingImageMode: 'processing',\n bodyColor: '#fff',\n headerColor: '#691916',\n showHeaderLogo: false,\n closeOnBackdropClick: true,\n title: html`${msg('Error: unable to remove items')}`,\n message: html`${msg(\n 'An error occurred while removing items. Please try again in a few minutes.'\n )}`,\n });\n\n this.modalManager?.classList.add('remove-items');\n this.modalManager?.showModal({\n config,\n userClosedModalCallback: () => {\n this.modalManager?.classList.remove('remove-items');\n },\n });\n }\n\n static get styles(): CSSResultGroup {\n return css`\n ${iaButtonStyle}\n .manage-container {\n display: flex;\n align-items: center;\n column-gap: 5px;\n padding: 20px 0 20px;\n flex-wrap: wrap;\n }\n\n .manage-label {\n display: inline-block;\n font-weight: bold;\n font-size: 1.8rem;\n padding-right: 10px;\n }\n\n .manage-buttons {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n column-gap: 5px;\n }\n\n .selection-buttons {\n display: inherit;\n }\n\n .ia-button,\n button {\n padding: 6px 12px;\n font-size: 1.4rem;\n margin: 3px 0;\n }\n `;\n }\n}\n"]}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { LitElement, TemplateResult, CSSResult } from 'lit';
|
|
2
|
-
|
|
3
|
-
identifier: string;
|
|
4
|
-
title?: string;
|
|
5
|
-
date?: string;
|
|
6
|
-
}
|
|
2
|
+
import type { ManageableItem } from '../models';
|
|
7
3
|
export declare class RemoveItemsModalContent extends LitElement {
|
|
8
4
|
items: ManageableItem[];
|
|
9
5
|
message?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-items-modal-content.js","sourceRoot":"","sources":["../../../src/manage/remove-items-modal-content.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAA6B,MAAM,KAAK,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
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A3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAA8B;AAE7B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAAkB;AAHlC,uBAAuB;IADnC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,uBAAuB,CA8FnC;SA9FY,uBAAuB","sourcesContent":["import { LitElement, html, css, nothing, TemplateResult, CSSResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { msg } from '@lit/localize';\nimport { map } from 'lit/directives/map.js';\nimport type { ManageableItem } from '../models';\n\n@customElement('remove-items-modal-content')\nexport class RemoveItemsModalContent extends LitElement {\n @property({ type: Object }) items: ManageableItem[] = [];\n\n @property({ type: String }) message?: string;\n\n render(): TemplateResult {\n return html`\n <ul>\n ${map(\n this.items,\n ({ title, date }) => html`\n <li>\n <span class=\"item-title\">${title ?? '[untitled]'}</span>\n <span class=\"item-date\">${date ?? ''}</span>\n </li>\n `\n )}\n </ul>\n ${this.message ? html`<p class=\"message\">${this.message}</p>` : nothing}\n <div class=\"button-bar\">\n <button class=\"remove-items-btn\" @click=${this.removeItemsBtnClicked}>\n ${msg('Remove items')}\n </button>\n </div>\n `;\n }\n\n private removeItemsBtnClicked(): void {\n this.dispatchEvent(\n new CustomEvent<{ items: ManageableItem[] }>('confirm', {\n detail: {\n items: this.items,\n },\n })\n );\n }\n\n static get styles(): CSSResult {\n return css`\n ul {\n margin: 0;\n padding: 0 10px;\n font-size: 1.4rem;\n list-style-type: none;\n max-height: min(400px, 40vh);\n overflow-y: auto;\n }\n\n li {\n display: flex;\n justify-content: space-between;\n padding: 2px 0;\n }\n li:not(:last-of-type) {\n border-bottom: 1px solid rgb(232, 232, 232);\n }\n\n .item-title {\n word-break: break-word;\n }\n\n .item-date {\n white-space: nowrap;\n }\n\n .message {\n font-size: 1.4rem;\n padding: 5px 10px;\n }\n\n .button-bar {\n display: flex;\n justify-content: center;\n margin: 10px 5px;\n }\n\n .remove-items-btn {\n margin-bottom: 10px;\n padding: 10px;\n border: 1px solid var(--primaryErrorCTABorder, #d43f3a);\n border-radius: 4px;\n color: white;\n background: var(--primaryErrorCTAFill, #d9534f);\n appearance: none;\n cursor: pointer;\n }\n .remove-items-btn:hover {\n background: rgba(var(--primaryErrorCTAFillRGB, 229, 28, 38), 0.9);\n }\n .remove-items-btn:active {\n background: rgba(var(--primaryErrorCTAFillRGB, 229, 28, 38), 0.7);\n }\n `;\n }\n}\n"]}
|
package/dist/src/models.d.ts
CHANGED
|
@@ -217,3 +217,12 @@ export declare const lendingFacetDisplayNames: Partial<Record<LendingFacetKey, s
|
|
|
217
217
|
* as facets or in an item's list of collections.
|
|
218
218
|
*/
|
|
219
219
|
export declare const suppressedCollections: Record<string, boolean>;
|
|
220
|
+
/**
|
|
221
|
+
* A record of manageable item
|
|
222
|
+
*/
|
|
223
|
+
export interface ManageableItem {
|
|
224
|
+
identifier: string;
|
|
225
|
+
title?: string;
|
|
226
|
+
dateStr?: string;
|
|
227
|
+
date?: string;
|
|
228
|
+
}
|
package/dist/src/models.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EACL,mBAAmB,GAIpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAe/D,MAAM,CAAC,MAAM,iBAAiB,GAAoC;IAChE,gBAAgB,EAAE,GAAG,CAAC,0BAA0B,CAAC;IACjD,iBAAiB,EAAE,GAAG,CAAC,8BAA8B,CAAC;CACvD,CAAC;AA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,OAAO,EAAE,IAAI;CACd,CAAC","sourcesContent":["import type { TemplateResult } from 'lit';\nimport { msg } from '@lit/localize';\nimport type { MediaType } from '@internetarchive/field-parsers';\nimport {\n AggregationSortType,\n Review,\n SearchResult,\n SortDirection,\n} from '@internetarchive/search-service';\nimport { collapseRepeatedQuotes } from './utils/collapse-repeated-quotes';\nimport { resolveMediatype } from './utils/resolve-mediatype';\n\nimport { loginRequiredIcon } from './assets/img/icons/login-required';\nimport { restrictedIcon } from './assets/img/icons/restricted';\n\n/**\n * Flags that can affect the visibility of content on a tile\n */\ninterface TileFlags {\n loginRequired: boolean;\n contentWarning: boolean;\n}\n\n/**\n * Different types of tile overlays, corresponding to the above flags.\n */\nexport type TileOverlayType = 'login-required' | 'content-warning';\n\nexport const TILE_OVERLAY_TEXT: Record<TileOverlayType, string> = {\n 'login-required': msg('Log in to view this item'),\n 'content-warning': msg('Content may be inappropriate'),\n};\n\nexport const TILE_OVERLAY_ICONS: Record<TileOverlayType, TemplateResult> = {\n 'login-required': loginRequiredIcon,\n 'content-warning': restrictedIcon,\n};\n\n/**\n * Class for converting & storing raw search results in the correct format for UI tiles.\n */\nexport class TileModel {\n averageRating?: number;\n\n captureDates?: Date[]; // List of capture dates for a URL, used on profile Web Archives tiles\n\n checked: boolean; // Whether this tile is currently checked for item management functions\n\n collectionIdentifier?: string;\n\n collectionName?: string;\n\n collectionFilesCount: number;\n\n collections: string[];\n\n collectionSize: number;\n\n commentCount: number;\n\n creator?: string;\n\n creators: string[];\n\n dateStr?: string; // A string representation of the publication date, used strictly for passing preformatted dates to the parent\n\n dateAdded?: Date; // Date added to public search (software-defined) [from: addeddate]\n\n dateArchived?: Date; // Date archived (software-defined) item created on archive.org [from: publicdate]\n\n datePublished?: Date; // Date work published in the world (user-defined) [from: date]\n\n dateReviewed?: Date; // Date reviewed (user-created) most recent review [from: reviewdate]\n\n description?: string;\n\n favCount: number;\n\n href?: string;\n\n identifier?: string;\n\n issue?: string;\n\n itemCount: number;\n\n mediatype: MediaType;\n\n review?: Review;\n\n source?: string;\n\n snippets?: string[];\n\n subjects: string[];\n\n title: string;\n\n viewCount?: number;\n\n volume?: string;\n\n weeklyViewCount?: number;\n\n loginRequired: boolean;\n\n contentWarning: boolean;\n\n constructor(result: SearchResult) {\n const flags = this.getFlags(result);\n\n this.averageRating = result.avg_rating?.value;\n this.captureDates = result.capture_dates?.values;\n this.checked = false;\n this.collections = result.collection?.values ?? [];\n this.collectionFilesCount = result.collection_files_count?.value ?? 0;\n this.collectionSize = result.collection_size?.value ?? 0;\n this.commentCount = result.num_reviews?.value ?? 0;\n this.creator = result.creator?.value;\n this.creators = result.creator?.values ?? [];\n this.dateAdded = result.addeddate?.value;\n this.dateArchived = result.publicdate?.value;\n this.datePublished = result.date?.value;\n this.dateReviewed = result.reviewdate?.value;\n this.description = result.description?.values.join('\\n');\n this.favCount = result.num_favorites?.value ?? 0;\n this.href = collapseRepeatedQuotes(\n result.review?.__href__ ?? result.__href__?.value\n );\n this.identifier = TileModel.cleanIdentifier(result.identifier);\n this.issue = result.issue?.value;\n this.itemCount = result.item_count?.value ?? 0;\n this.mediatype = resolveMediatype(result);\n this.review = result.review;\n this.snippets = result.highlight?.values ?? [];\n this.source = result.source?.value;\n this.subjects = result.subject?.values ?? [];\n this.title = result.title?.value ?? '';\n this.volume = result.volume?.value;\n this.viewCount = result.downloads?.value;\n this.weeklyViewCount = result.week?.value;\n this.loginRequired = flags.loginRequired;\n this.contentWarning = flags.contentWarning;\n }\n\n /**\n * Copies the contents of this TileModel onto a new instance\n */\n clone(): TileModel {\n const cloned = new TileModel({});\n cloned.averageRating = this.averageRating;\n cloned.captureDates = this.captureDates;\n cloned.checked = this.checked;\n cloned.collections = this.collections;\n cloned.collectionFilesCount = this.collectionFilesCount;\n cloned.collectionSize = this.collectionSize;\n cloned.commentCount = this.commentCount;\n cloned.creator = this.creator;\n cloned.creators = this.creators;\n cloned.dateStr = this.dateStr;\n cloned.dateAdded = this.dateAdded;\n cloned.dateArchived = this.dateArchived;\n cloned.datePublished = this.datePublished;\n cloned.dateReviewed = this.dateReviewed;\n cloned.description = this.description;\n cloned.favCount = this.favCount;\n cloned.href = this.href;\n cloned.identifier = this.identifier;\n cloned.issue = this.issue;\n cloned.itemCount = this.itemCount;\n cloned.mediatype = this.mediatype;\n cloned.snippets = this.snippets;\n cloned.source = this.source;\n cloned.subjects = this.subjects;\n cloned.title = this.title;\n cloned.volume = this.volume;\n cloned.viewCount = this.viewCount;\n cloned.weeklyViewCount = this.weeklyViewCount;\n cloned.loginRequired = this.loginRequired;\n cloned.contentWarning = this.contentWarning;\n return cloned;\n }\n\n /**\n * Determines the appropriate tile flags for the given search result\n * (login required and/or content warning)\n */\n private getFlags(result: SearchResult): TileFlags {\n const flags: TileFlags = {\n loginRequired: false,\n contentWarning: false,\n };\n\n // Check if item and item in \"modifying\" collection, setting above flags\n if (\n result.collection?.values.length &&\n result.mediatype?.value !== 'collection'\n ) {\n for (const collection of result.collection?.values ?? []) {\n if (collection === 'loggedin') {\n flags.loginRequired = true;\n if (flags.contentWarning) break;\n }\n if (collection === 'no-preview') {\n flags.contentWarning = true;\n if (flags.loginRequired) break;\n }\n }\n }\n\n return flags;\n }\n\n private static cleanIdentifier(\n identifier: string | undefined\n ): string | undefined {\n // Some identifiers (e.g., from Whisper) represent documents rather than items, and\n // are suffixed with values that need to be stripped. Those values are separated\n // from the item identifier itself with '|'.\n const barIndex = identifier?.indexOf('|') ?? -1;\n const cleaned = barIndex > 0 ? identifier?.slice(0, barIndex) : identifier;\n return cleaned;\n }\n}\n\nexport type RequestKind = 'full' | 'hits' | 'aggregations';\n\nexport type CollectionDisplayMode = 'grid' | 'list-compact' | 'list-detail';\n\nexport type TileDisplayMode =\n | 'grid'\n | 'list-compact'\n | 'list-detail'\n | 'list-header';\n\n/**\n * This is mainly used to set the cookies for the collection display mode.\n *\n * It allows the user to set different modes for different contexts (collection page, search page, profile page etc).\n */\nexport type CollectionBrowserContext = 'collection' | 'search' | 'profile';\n\n/**\n * The sort fields shown in the sort filter bar\n */\nexport enum SortField {\n 'default' = 'default',\n 'unrecognized' = 'unrecognized',\n 'relevance' = 'relevance',\n 'alltimeview' = 'alltimeview',\n 'weeklyview' = 'weeklyview',\n 'title' = 'title',\n 'date' = 'date',\n 'datearchived' = 'datearchived',\n 'datereviewed' = 'datereviewed',\n 'dateadded' = 'dateadded',\n 'datefavorited' = 'datefavorited',\n 'creator' = 'creator',\n}\n\nexport interface SortOption {\n /**\n * The SortField enum member corresponding to this option.\n */\n field: SortField;\n\n /**\n * The default sort direction to apply when this sort option is first selected.\n */\n defaultSortDirection: SortDirection | null;\n\n /**\n * Whether this sort option allows its sort direction to be changed from the default.\n */\n canSetDirection: boolean;\n\n /**\n * Whether this sort option may appear in the sort bar.\n */\n shownInSortBar: boolean;\n\n /**\n * Whether this sort option should be saved to the URL.\n * If false, then no `sort` param will be added to the URL when this sort option\n * is selected.\n */\n shownInURL: boolean;\n\n /**\n * Whether this sort option is passed to the search service.\n * If false, then no sort param will be passed to the search service at all when\n * this sort option is selected.\n */\n handledBySearchService: boolean;\n\n /**\n * The string identifying this sort field to the search service & backend API.\n */\n searchServiceKey?: string;\n\n /**\n * The human-readable name to use for this option in the sort bar (if applicable).\n */\n displayName: string;\n\n /**\n * A list of URL param keys that should be mapped to this sort option.\n * E.g., both `title` and `titleSorter` in the URL map to the `SortField.title` option.\n */\n urlNames: (string | null | undefined)[];\n}\n\nexport const SORT_OPTIONS: Record<SortField, SortOption> = {\n // Default sort is the case where the user has not specified a sort option via the sort bar or URL.\n // In these cases, we defer to whatever sort the backend chooses.\n // For the search page, the default is always relevance sort.\n // For collection pages _without a query_, the default is usually weekly views, but this can be\n // overridden by the collection's `sort-by` metadata entry. If a query _is_ specified, then the\n // default is again relevance sort.\n // For fav-* collections only, the default is instead sorting by date favorited.\n [SortField.default]: {\n field: SortField.default,\n defaultSortDirection: null,\n canSetDirection: false,\n shownInSortBar: false,\n shownInURL: false,\n handledBySearchService: false, // We rely on the PPS default sort handling in these cases\n displayName: '',\n urlNames: ['', null, undefined], // Empty or nullish sort params result in default sorting\n },\n // Unrecognized sort is the case where the user has specified a sort in the URL, but it is not\n // one of the options listed in this map. We still want these unrecognized sorts to be applied\n // when searching, but they are not displayed in the sort bar and we do not actively manage\n // their URL param beyond flipping the direction as needed.\n [SortField.unrecognized]: {\n field: SortField.unrecognized,\n defaultSortDirection: null,\n canSetDirection: true,\n shownInSortBar: false,\n shownInURL: false,\n handledBySearchService: true, // The unrecognized sort param is passed along as-is\n displayName: '',\n urlNames: [],\n },\n // Relevance sort is unique in that it does not produce a URL param when it is set.\n // It is only available when there is a user-specified query that relevancy can be scored against.\n // Therefore, it does not appear as a sort bar option when browsing a collection with no query set.\n [SortField.relevance]: {\n field: SortField.relevance,\n defaultSortDirection: null,\n canSetDirection: false,\n shownInSortBar: true,\n shownInURL: false,\n handledBySearchService: false,\n displayName: 'Relevance',\n urlNames: ['_score'],\n },\n [SortField.alltimeview]: {\n field: SortField.alltimeview,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'downloads',\n displayName: 'All-time views',\n urlNames: ['downloads'],\n },\n [SortField.weeklyview]: {\n field: SortField.weeklyview,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'week',\n displayName: 'Weekly views',\n urlNames: ['week'],\n },\n [SortField.title]: {\n field: SortField.title,\n defaultSortDirection: 'asc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'titleSorter',\n displayName: 'Title',\n urlNames: ['title', 'titleSorter'],\n },\n [SortField.date]: {\n field: SortField.date,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'date',\n displayName: 'Date published',\n urlNames: ['date'],\n },\n [SortField.datearchived]: {\n field: SortField.datearchived,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'publicdate',\n displayName: 'Date archived',\n urlNames: ['publicdate'],\n },\n [SortField.datereviewed]: {\n field: SortField.datereviewed,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'reviewdate',\n displayName: 'Date reviewed',\n urlNames: ['reviewdate'],\n },\n [SortField.dateadded]: {\n field: SortField.dateadded,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'addeddate',\n displayName: 'Date added',\n urlNames: ['addeddate'],\n },\n [SortField.datefavorited]: {\n field: SortField.datefavorited,\n defaultSortDirection: 'desc',\n canSetDirection: false,\n shownInSortBar: true, // But only when viewing fav-* collections\n shownInURL: false,\n handledBySearchService: false,\n searchServiceKey: 'favoritedate',\n displayName: 'Date favorited',\n urlNames: ['favoritedate'],\n },\n [SortField.creator]: {\n field: SortField.creator,\n defaultSortDirection: 'asc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'creatorSorter',\n displayName: 'Creator',\n urlNames: ['creator', 'creatorSorter'],\n },\n};\n\n/**\n * Returns the SortOption corresponding to the given API sort name, or\n * the \"unrecognized\" SortOption if none matches.\n */\nexport function sortOptionFromAPIString(sortName?: string | null): SortOption {\n return (\n Object.values(SORT_OPTIONS).find(opt =>\n opt.urlNames.some(name => sortName === name)\n ) ?? SORT_OPTIONS[SortField.unrecognized]\n );\n}\n\nexport const defaultProfileElementSorts: Record<\n string,\n Exclude<SortField, SortField.default>\n> = {\n uploads: SortField.datearchived,\n reviews: SortField.datereviewed,\n collections: SortField.datearchived,\n web_archives: SortField.datearchived,\n};\n\n/** A union of the fields that permit prefix filtering (e.g., alphabetical filtering) */\nexport type PrefixFilterType = 'title' | 'creator';\n\n/** A map from prefixes (e.g., initial letters) to the number of items matching that prefix */\nexport type PrefixFilterCounts = Record<string, number>;\n\n/**\n * A map from prefix filter types to the corresponding aggregation keys\n * that are needed to fetch the filter counts from the backend.\n */\nexport const prefixFilterAggregationKeys: Record<PrefixFilterType, string> = {\n title: 'firstTitle',\n creator: 'firstCreator',\n};\n\n/**\n * Different facet loading strategies that can be used with collection browser.\n * - `eager`: Facet data is always loaded as soon as a search is performed\n * - `lazy-mobile`: In the desktop layout, functions exactly as `eager`.\n * In the mobile layout, facet data will only be loaded once the \"Filters\" accordion is opened.\n * - `opt-in-or-login`: Same as `opt-in` for guest users not logged into an account, but same as `eager` for\n * any logged in user.\n * - `opt-in`: In the desktop layout, facet data will only be loaded after the user presses a \"Load Facets\" button.\n * In the mobile layout, functions exactly as `lazy-mobile`.\n * - `off`: Facet data will never be loaded, and a message will be displayed in place of facets\n * indicating that they are unavailable.\n */\nexport type FacetLoadStrategy =\n | 'eager'\n | 'lazy-mobile'\n | 'opt-in-or-login'\n | 'opt-in'\n | 'off';\n\n/**\n * Union of the facet types that are available in the sidebar.\n */\nexport type FacetOption =\n | 'subject'\n | 'lending'\n | 'mediatype'\n | 'language'\n | 'creator'\n | 'collection'\n | 'year';\n\nexport type SelectedFacetState = 'selected' | 'hidden';\n\nexport type FacetState = SelectedFacetState | 'none';\n\nexport interface FacetBucket {\n // for some facets, we augment the key with a display value\n displayText?: string;\n key: string;\n count: number;\n state: FacetState;\n}\n\nexport interface FacetGroup {\n title: string;\n key: FacetOption;\n buckets: FacetBucket[];\n}\n\n/**\n * Information about a user interaction event on a facet.\n */\nexport type FacetEventDetails = {\n /**\n * The type of facet that was interacted with (e.g., 'mediatype', 'language', ...).\n */\n facetType: FacetOption;\n /**\n * The bucket corresponding to the facet that was interacted with, including the\n * updated state of the facet after the interaction.\n */\n bucket: FacetBucket;\n /**\n * Whether the interaction occurred on a negative facet.\n */\n negative: boolean;\n};\n\nexport type FacetValue = string;\n\nexport type SelectedFacets = Record<\n FacetOption,\n Record<FacetValue, FacetBucket>\n>;\n\nexport const getDefaultSelectedFacets = (): SelectedFacets => ({\n subject: {},\n lending: {},\n mediatype: {},\n language: {},\n creator: {},\n collection: {},\n year: {},\n});\n\nexport const facetDisplayOrder: FacetOption[] = [\n 'mediatype',\n // 'lending', Commenting this out removes the lending facet from the sidebar for now\n 'year',\n 'subject',\n 'collection',\n 'creator',\n 'language',\n];\n\nexport const facetTitles: Record<FacetOption, string> = {\n subject: 'Subject',\n lending: 'Availability',\n mediatype: 'Media Type',\n language: 'Language',\n creator: 'Creator',\n collection: 'Collection',\n year: 'Year',\n};\n\n/**\n * The default sort type to use for each facet type\n */\nexport const defaultFacetSort: Record<FacetOption, AggregationSortType> = {\n subject: AggregationSortType.COUNT,\n lending: AggregationSortType.COUNT,\n mediatype: AggregationSortType.COUNT,\n language: AggregationSortType.COUNT,\n creator: AggregationSortType.COUNT,\n collection: AggregationSortType.COUNT,\n year: AggregationSortType.NUMERIC,\n};\n\n/**\n * The sort type corresponding to facet bucket values, for each facet type\n * (i.e., the opposite of \"sort by count\" for that type).\n */\nexport const valueFacetSort: Record<FacetOption, AggregationSortType> = {\n subject: AggregationSortType.ALPHABETICAL,\n lending: AggregationSortType.ALPHABETICAL,\n mediatype: AggregationSortType.ALPHABETICAL,\n language: AggregationSortType.ALPHABETICAL,\n creator: AggregationSortType.ALPHABETICAL,\n collection: AggregationSortType.ALPHABETICAL,\n year: AggregationSortType.NUMERIC,\n};\n\nexport type LendingFacetKey =\n | 'is_lendable'\n | 'is_borrowable'\n | 'available_to_borrow'\n | 'is_browsable'\n | 'available_to_browse'\n | 'is_readable'\n | 'available_to_waitlist';\n\n/**\n * Maps valid lending keys to whether they should be visible in the facet sidebar\n */\nexport const lendingFacetKeysVisibility: Record<LendingFacetKey, boolean> = {\n is_lendable: true,\n is_borrowable: false,\n available_to_borrow: true,\n is_browsable: false,\n available_to_browse: false,\n is_readable: true,\n available_to_waitlist: false,\n};\n\n/**\n * Maps valid, visible lending keys to their facet sidebar display text\n */\nexport const lendingFacetDisplayNames: Partial<\n Record<LendingFacetKey, string>\n> = {\n is_lendable: 'Lending Library',\n available_to_borrow: 'Borrow 14 Days',\n is_readable: 'Always Available',\n};\n\n/**\n * A record of which admin-only collections should be suppressed from being displayed\n * as facets or in an item's list of collections.\n */\nexport const suppressedCollections: Record<string, boolean> = {\n deemphasize: true,\n community: true,\n stream_only: true,\n samples_only: true,\n test_collection: true,\n printdisabled: true,\n 'openlibrary-ol': true,\n nationalemergencylibrary: true,\n china: true,\n americana: true,\n toronto: true,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EACL,mBAAmB,GAIpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAe/D,MAAM,CAAC,MAAM,iBAAiB,GAAoC;IAChE,gBAAgB,EAAE,GAAG,CAAC,0BAA0B,CAAC;IACjD,iBAAiB,EAAE,GAAG,CAAC,8BAA8B,CAAC;CACvD,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAA4C;IACzE,gBAAgB,EAAE,iBAAiB;IACnC,iBAAiB,EAAE,cAAc;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,SAAS;IAmEpB,YAAY,MAAoB;;QAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEpC,IAAI,CAAC,aAAa,GAAG,MAAA,MAAM,CAAC,UAAU,0CAAE,KAAK,CAA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,EAAE,mBAAmB,CAAC,YAAY;IACzC,SAAS,EAAE,mBAAmB,CAAC,YAAY;IAC3C,QAAQ,EAAE,mBAAmB,CAAC,YAAY;IAC1C,OAAO,EAAE,mBAAmB,CAAC,YAAY;IACzC,UAAU,EAAE,mBAAmB,CAAC,YAAY;IAC5C,IAAI,EAAE,mBAAmB,CAAC,OAAO;CAClC,CAAC;AAWF;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAqC;IAC1E,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,KAAK;IACpB,mBAAmB,EAAE,IAAI;IACzB,YAAY,EAAE,KAAK;IACnB,mBAAmB,EAAE,KAAK;IAC1B,WAAW,EAAE,IAAI;IACjB,qBAAqB,EAAE,KAAK;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAEjC;IACF,WAAW,EAAE,iBAAiB;IAC9B,mBAAmB,EAAE,gBAAgB;IACrC,WAAW,EAAE,kBAAkB;CAChC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA4B;IAC5D,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE,IAAI;IACrB,aAAa,EAAE,IAAI;IACnB,gBAAgB,EAAE,IAAI;IACtB,wBAAwB,EAAE,IAAI;IAC9B,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;CACd,CAAC","sourcesContent":["import type { TemplateResult } from 'lit';\nimport { msg } from '@lit/localize';\nimport type { MediaType } from '@internetarchive/field-parsers';\nimport {\n AggregationSortType,\n Review,\n SearchResult,\n SortDirection,\n} from '@internetarchive/search-service';\nimport { collapseRepeatedQuotes } from './utils/collapse-repeated-quotes';\nimport { resolveMediatype } from './utils/resolve-mediatype';\n\nimport { loginRequiredIcon } from './assets/img/icons/login-required';\nimport { restrictedIcon } from './assets/img/icons/restricted';\n\n/**\n * Flags that can affect the visibility of content on a tile\n */\ninterface TileFlags {\n loginRequired: boolean;\n contentWarning: boolean;\n}\n\n/**\n * Different types of tile overlays, corresponding to the above flags.\n */\nexport type TileOverlayType = 'login-required' | 'content-warning';\n\nexport const TILE_OVERLAY_TEXT: Record<TileOverlayType, string> = {\n 'login-required': msg('Log in to view this item'),\n 'content-warning': msg('Content may be inappropriate'),\n};\n\nexport const TILE_OVERLAY_ICONS: Record<TileOverlayType, TemplateResult> = {\n 'login-required': loginRequiredIcon,\n 'content-warning': restrictedIcon,\n};\n\n/**\n * Class for converting & storing raw search results in the correct format for UI tiles.\n */\nexport class TileModel {\n averageRating?: number;\n\n captureDates?: Date[]; // List of capture dates for a URL, used on profile Web Archives tiles\n\n checked: boolean; // Whether this tile is currently checked for item management functions\n\n collectionIdentifier?: string;\n\n collectionName?: string;\n\n collectionFilesCount: number;\n\n collections: string[];\n\n collectionSize: number;\n\n commentCount: number;\n\n creator?: string;\n\n creators: string[];\n\n dateStr?: string; // A string representation of the publication date, used strictly for passing preformatted dates to the parent\n\n dateAdded?: Date; // Date added to public search (software-defined) [from: addeddate]\n\n dateArchived?: Date; // Date archived (software-defined) item created on archive.org [from: publicdate]\n\n datePublished?: Date; // Date work published in the world (user-defined) [from: date]\n\n dateReviewed?: Date; // Date reviewed (user-created) most recent review [from: reviewdate]\n\n description?: string;\n\n favCount: number;\n\n href?: string;\n\n identifier?: string;\n\n issue?: string;\n\n itemCount: number;\n\n mediatype: MediaType;\n\n review?: Review;\n\n source?: string;\n\n snippets?: string[];\n\n subjects: string[];\n\n title: string;\n\n viewCount?: number;\n\n volume?: string;\n\n weeklyViewCount?: number;\n\n loginRequired: boolean;\n\n contentWarning: boolean;\n\n constructor(result: SearchResult) {\n const flags = this.getFlags(result);\n\n this.averageRating = result.avg_rating?.value;\n this.captureDates = result.capture_dates?.values;\n this.checked = false;\n this.collections = result.collection?.values ?? [];\n this.collectionFilesCount = result.collection_files_count?.value ?? 0;\n this.collectionSize = result.collection_size?.value ?? 0;\n this.commentCount = result.num_reviews?.value ?? 0;\n this.creator = result.creator?.value;\n this.creators = result.creator?.values ?? [];\n this.dateAdded = result.addeddate?.value;\n this.dateArchived = result.publicdate?.value;\n this.datePublished = result.date?.value;\n this.dateReviewed = result.reviewdate?.value;\n this.description = result.description?.values.join('\\n');\n this.favCount = result.num_favorites?.value ?? 0;\n this.href = collapseRepeatedQuotes(\n result.review?.__href__ ?? result.__href__?.value\n );\n this.identifier = TileModel.cleanIdentifier(result.identifier);\n this.issue = result.issue?.value;\n this.itemCount = result.item_count?.value ?? 0;\n this.mediatype = resolveMediatype(result);\n this.review = result.review;\n this.snippets = result.highlight?.values ?? [];\n this.source = result.source?.value;\n this.subjects = result.subject?.values ?? [];\n this.title = result.title?.value ?? '';\n this.volume = result.volume?.value;\n this.viewCount = result.downloads?.value;\n this.weeklyViewCount = result.week?.value;\n this.loginRequired = flags.loginRequired;\n this.contentWarning = flags.contentWarning;\n }\n\n /**\n * Copies the contents of this TileModel onto a new instance\n */\n clone(): TileModel {\n const cloned = new TileModel({});\n cloned.averageRating = this.averageRating;\n cloned.captureDates = this.captureDates;\n cloned.checked = this.checked;\n cloned.collections = this.collections;\n cloned.collectionFilesCount = this.collectionFilesCount;\n cloned.collectionSize = this.collectionSize;\n cloned.commentCount = this.commentCount;\n cloned.creator = this.creator;\n cloned.creators = this.creators;\n cloned.dateStr = this.dateStr;\n cloned.dateAdded = this.dateAdded;\n cloned.dateArchived = this.dateArchived;\n cloned.datePublished = this.datePublished;\n cloned.dateReviewed = this.dateReviewed;\n cloned.description = this.description;\n cloned.favCount = this.favCount;\n cloned.href = this.href;\n cloned.identifier = this.identifier;\n cloned.issue = this.issue;\n cloned.itemCount = this.itemCount;\n cloned.mediatype = this.mediatype;\n cloned.snippets = this.snippets;\n cloned.source = this.source;\n cloned.subjects = this.subjects;\n cloned.title = this.title;\n cloned.volume = this.volume;\n cloned.viewCount = this.viewCount;\n cloned.weeklyViewCount = this.weeklyViewCount;\n cloned.loginRequired = this.loginRequired;\n cloned.contentWarning = this.contentWarning;\n return cloned;\n }\n\n /**\n * Determines the appropriate tile flags for the given search result\n * (login required and/or content warning)\n */\n private getFlags(result: SearchResult): TileFlags {\n const flags: TileFlags = {\n loginRequired: false,\n contentWarning: false,\n };\n\n // Check if item and item in \"modifying\" collection, setting above flags\n if (\n result.collection?.values.length &&\n result.mediatype?.value !== 'collection'\n ) {\n for (const collection of result.collection?.values ?? []) {\n if (collection === 'loggedin') {\n flags.loginRequired = true;\n if (flags.contentWarning) break;\n }\n if (collection === 'no-preview') {\n flags.contentWarning = true;\n if (flags.loginRequired) break;\n }\n }\n }\n\n return flags;\n }\n\n private static cleanIdentifier(\n identifier: string | undefined\n ): string | undefined {\n // Some identifiers (e.g., from Whisper) represent documents rather than items, and\n // are suffixed with values that need to be stripped. Those values are separated\n // from the item identifier itself with '|'.\n const barIndex = identifier?.indexOf('|') ?? -1;\n const cleaned = barIndex > 0 ? identifier?.slice(0, barIndex) : identifier;\n return cleaned;\n }\n}\n\nexport type RequestKind = 'full' | 'hits' | 'aggregations';\n\nexport type CollectionDisplayMode = 'grid' | 'list-compact' | 'list-detail';\n\nexport type TileDisplayMode =\n | 'grid'\n | 'list-compact'\n | 'list-detail'\n | 'list-header';\n\n/**\n * This is mainly used to set the cookies for the collection display mode.\n *\n * It allows the user to set different modes for different contexts (collection page, search page, profile page etc).\n */\nexport type CollectionBrowserContext = 'collection' | 'search' | 'profile';\n\n/**\n * The sort fields shown in the sort filter bar\n */\nexport enum SortField {\n 'default' = 'default',\n 'unrecognized' = 'unrecognized',\n 'relevance' = 'relevance',\n 'alltimeview' = 'alltimeview',\n 'weeklyview' = 'weeklyview',\n 'title' = 'title',\n 'date' = 'date',\n 'datearchived' = 'datearchived',\n 'datereviewed' = 'datereviewed',\n 'dateadded' = 'dateadded',\n 'datefavorited' = 'datefavorited',\n 'creator' = 'creator',\n}\n\nexport interface SortOption {\n /**\n * The SortField enum member corresponding to this option.\n */\n field: SortField;\n\n /**\n * The default sort direction to apply when this sort option is first selected.\n */\n defaultSortDirection: SortDirection | null;\n\n /**\n * Whether this sort option allows its sort direction to be changed from the default.\n */\n canSetDirection: boolean;\n\n /**\n * Whether this sort option may appear in the sort bar.\n */\n shownInSortBar: boolean;\n\n /**\n * Whether this sort option should be saved to the URL.\n * If false, then no `sort` param will be added to the URL when this sort option\n * is selected.\n */\n shownInURL: boolean;\n\n /**\n * Whether this sort option is passed to the search service.\n * If false, then no sort param will be passed to the search service at all when\n * this sort option is selected.\n */\n handledBySearchService: boolean;\n\n /**\n * The string identifying this sort field to the search service & backend API.\n */\n searchServiceKey?: string;\n\n /**\n * The human-readable name to use for this option in the sort bar (if applicable).\n */\n displayName: string;\n\n /**\n * A list of URL param keys that should be mapped to this sort option.\n * E.g., both `title` and `titleSorter` in the URL map to the `SortField.title` option.\n */\n urlNames: (string | null | undefined)[];\n}\n\nexport const SORT_OPTIONS: Record<SortField, SortOption> = {\n // Default sort is the case where the user has not specified a sort option via the sort bar or URL.\n // In these cases, we defer to whatever sort the backend chooses.\n // For the search page, the default is always relevance sort.\n // For collection pages _without a query_, the default is usually weekly views, but this can be\n // overridden by the collection's `sort-by` metadata entry. If a query _is_ specified, then the\n // default is again relevance sort.\n // For fav-* collections only, the default is instead sorting by date favorited.\n [SortField.default]: {\n field: SortField.default,\n defaultSortDirection: null,\n canSetDirection: false,\n shownInSortBar: false,\n shownInURL: false,\n handledBySearchService: false, // We rely on the PPS default sort handling in these cases\n displayName: '',\n urlNames: ['', null, undefined], // Empty or nullish sort params result in default sorting\n },\n // Unrecognized sort is the case where the user has specified a sort in the URL, but it is not\n // one of the options listed in this map. We still want these unrecognized sorts to be applied\n // when searching, but they are not displayed in the sort bar and we do not actively manage\n // their URL param beyond flipping the direction as needed.\n [SortField.unrecognized]: {\n field: SortField.unrecognized,\n defaultSortDirection: null,\n canSetDirection: true,\n shownInSortBar: false,\n shownInURL: false,\n handledBySearchService: true, // The unrecognized sort param is passed along as-is\n displayName: '',\n urlNames: [],\n },\n // Relevance sort is unique in that it does not produce a URL param when it is set.\n // It is only available when there is a user-specified query that relevancy can be scored against.\n // Therefore, it does not appear as a sort bar option when browsing a collection with no query set.\n [SortField.relevance]: {\n field: SortField.relevance,\n defaultSortDirection: null,\n canSetDirection: false,\n shownInSortBar: true,\n shownInURL: false,\n handledBySearchService: false,\n displayName: 'Relevance',\n urlNames: ['_score'],\n },\n [SortField.alltimeview]: {\n field: SortField.alltimeview,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'downloads',\n displayName: 'All-time views',\n urlNames: ['downloads'],\n },\n [SortField.weeklyview]: {\n field: SortField.weeklyview,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'week',\n displayName: 'Weekly views',\n urlNames: ['week'],\n },\n [SortField.title]: {\n field: SortField.title,\n defaultSortDirection: 'asc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'titleSorter',\n displayName: 'Title',\n urlNames: ['title', 'titleSorter'],\n },\n [SortField.date]: {\n field: SortField.date,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'date',\n displayName: 'Date published',\n urlNames: ['date'],\n },\n [SortField.datearchived]: {\n field: SortField.datearchived,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'publicdate',\n displayName: 'Date archived',\n urlNames: ['publicdate'],\n },\n [SortField.datereviewed]: {\n field: SortField.datereviewed,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'reviewdate',\n displayName: 'Date reviewed',\n urlNames: ['reviewdate'],\n },\n [SortField.dateadded]: {\n field: SortField.dateadded,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'addeddate',\n displayName: 'Date added',\n urlNames: ['addeddate'],\n },\n [SortField.datefavorited]: {\n field: SortField.datefavorited,\n defaultSortDirection: 'desc',\n canSetDirection: false,\n shownInSortBar: true, // But only when viewing fav-* collections\n shownInURL: false,\n handledBySearchService: false,\n searchServiceKey: 'favoritedate',\n displayName: 'Date favorited',\n urlNames: ['favoritedate'],\n },\n [SortField.creator]: {\n field: SortField.creator,\n defaultSortDirection: 'asc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'creatorSorter',\n displayName: 'Creator',\n urlNames: ['creator', 'creatorSorter'],\n },\n};\n\n/**\n * Returns the SortOption corresponding to the given API sort name, or\n * the \"unrecognized\" SortOption if none matches.\n */\nexport function sortOptionFromAPIString(sortName?: string | null): SortOption {\n return (\n Object.values(SORT_OPTIONS).find(opt =>\n opt.urlNames.some(name => sortName === name)\n ) ?? SORT_OPTIONS[SortField.unrecognized]\n );\n}\n\nexport const defaultProfileElementSorts: Record<\n string,\n Exclude<SortField, SortField.default>\n> = {\n uploads: SortField.datearchived,\n reviews: SortField.datereviewed,\n collections: SortField.datearchived,\n web_archives: SortField.datearchived,\n};\n\n/** A union of the fields that permit prefix filtering (e.g., alphabetical filtering) */\nexport type PrefixFilterType = 'title' | 'creator';\n\n/** A map from prefixes (e.g., initial letters) to the number of items matching that prefix */\nexport type PrefixFilterCounts = Record<string, number>;\n\n/**\n * A map from prefix filter types to the corresponding aggregation keys\n * that are needed to fetch the filter counts from the backend.\n */\nexport const prefixFilterAggregationKeys: Record<PrefixFilterType, string> = {\n title: 'firstTitle',\n creator: 'firstCreator',\n};\n\n/**\n * Different facet loading strategies that can be used with collection browser.\n * - `eager`: Facet data is always loaded as soon as a search is performed\n * - `lazy-mobile`: In the desktop layout, functions exactly as `eager`.\n * In the mobile layout, facet data will only be loaded once the \"Filters\" accordion is opened.\n * - `opt-in-or-login`: Same as `opt-in` for guest users not logged into an account, but same as `eager` for\n * any logged in user.\n * - `opt-in`: In the desktop layout, facet data will only be loaded after the user presses a \"Load Facets\" button.\n * In the mobile layout, functions exactly as `lazy-mobile`.\n * - `off`: Facet data will never be loaded, and a message will be displayed in place of facets\n * indicating that they are unavailable.\n */\nexport type FacetLoadStrategy =\n | 'eager'\n | 'lazy-mobile'\n | 'opt-in-or-login'\n | 'opt-in'\n | 'off';\n\n/**\n * Union of the facet types that are available in the sidebar.\n */\nexport type FacetOption =\n | 'subject'\n | 'lending'\n | 'mediatype'\n | 'language'\n | 'creator'\n | 'collection'\n | 'year';\n\nexport type SelectedFacetState = 'selected' | 'hidden';\n\nexport type FacetState = SelectedFacetState | 'none';\n\nexport interface FacetBucket {\n // for some facets, we augment the key with a display value\n displayText?: string;\n key: string;\n count: number;\n state: FacetState;\n}\n\nexport interface FacetGroup {\n title: string;\n key: FacetOption;\n buckets: FacetBucket[];\n}\n\n/**\n * Information about a user interaction event on a facet.\n */\nexport type FacetEventDetails = {\n /**\n * The type of facet that was interacted with (e.g., 'mediatype', 'language', ...).\n */\n facetType: FacetOption;\n /**\n * The bucket corresponding to the facet that was interacted with, including the\n * updated state of the facet after the interaction.\n */\n bucket: FacetBucket;\n /**\n * Whether the interaction occurred on a negative facet.\n */\n negative: boolean;\n};\n\nexport type FacetValue = string;\n\nexport type SelectedFacets = Record<\n FacetOption,\n Record<FacetValue, FacetBucket>\n>;\n\nexport const getDefaultSelectedFacets = (): SelectedFacets => ({\n subject: {},\n lending: {},\n mediatype: {},\n language: {},\n creator: {},\n collection: {},\n year: {},\n});\n\nexport const facetDisplayOrder: FacetOption[] = [\n 'mediatype',\n // 'lending', Commenting this out removes the lending facet from the sidebar for now\n 'year',\n 'subject',\n 'collection',\n 'creator',\n 'language',\n];\n\nexport const facetTitles: Record<FacetOption, string> = {\n subject: 'Subject',\n lending: 'Availability',\n mediatype: 'Media Type',\n language: 'Language',\n creator: 'Creator',\n collection: 'Collection',\n year: 'Year',\n};\n\n/**\n * The default sort type to use for each facet type\n */\nexport const defaultFacetSort: Record<FacetOption, AggregationSortType> = {\n subject: AggregationSortType.COUNT,\n lending: AggregationSortType.COUNT,\n mediatype: AggregationSortType.COUNT,\n language: AggregationSortType.COUNT,\n creator: AggregationSortType.COUNT,\n collection: AggregationSortType.COUNT,\n year: AggregationSortType.NUMERIC,\n};\n\n/**\n * The sort type corresponding to facet bucket values, for each facet type\n * (i.e., the opposite of \"sort by count\" for that type).\n */\nexport const valueFacetSort: Record<FacetOption, AggregationSortType> = {\n subject: AggregationSortType.ALPHABETICAL,\n lending: AggregationSortType.ALPHABETICAL,\n mediatype: AggregationSortType.ALPHABETICAL,\n language: AggregationSortType.ALPHABETICAL,\n creator: AggregationSortType.ALPHABETICAL,\n collection: AggregationSortType.ALPHABETICAL,\n year: AggregationSortType.NUMERIC,\n};\n\nexport type LendingFacetKey =\n | 'is_lendable'\n | 'is_borrowable'\n | 'available_to_borrow'\n | 'is_browsable'\n | 'available_to_browse'\n | 'is_readable'\n | 'available_to_waitlist';\n\n/**\n * Maps valid lending keys to whether they should be visible in the facet sidebar\n */\nexport const lendingFacetKeysVisibility: Record<LendingFacetKey, boolean> = {\n is_lendable: true,\n is_borrowable: false,\n available_to_borrow: true,\n is_browsable: false,\n available_to_browse: false,\n is_readable: true,\n available_to_waitlist: false,\n};\n\n/**\n * Maps valid, visible lending keys to their facet sidebar display text\n */\nexport const lendingFacetDisplayNames: Partial<\n Record<LendingFacetKey, string>\n> = {\n is_lendable: 'Lending Library',\n available_to_borrow: 'Borrow 14 Days',\n is_readable: 'Always Available',\n};\n\n/**\n * A record of which admin-only collections should be suppressed from being displayed\n * as facets or in an item's list of collections.\n */\nexport const suppressedCollections: Record<string, boolean> = {\n deemphasize: true,\n community: true,\n stream_only: true,\n samples_only: true,\n test_collection: true,\n printdisabled: true,\n 'openlibrary-ol': true,\n nationalemergencylibrary: true,\n china: true,\n americana: true,\n toronto: true,\n};\n\n/**\n * A record of manageable item\n */\nexport interface ManageableItem {\n identifier: string;\n title?: string;\n dateStr?: string;\n date?: string;\n}\n"]}
|
|
@@ -3,6 +3,9 @@ import { expect, fixture } from '@open-wc/testing';
|
|
|
3
3
|
import { html } from 'lit';
|
|
4
4
|
import Sinon from 'sinon';
|
|
5
5
|
import '../../src/manage/manage-bar';
|
|
6
|
+
import { ModalManager, } from '@internetarchive/modal-manager';
|
|
7
|
+
import '@internetarchive/modal-manager';
|
|
8
|
+
import { msg } from '@lit/localize';
|
|
6
9
|
describe('Manage bar', () => {
|
|
7
10
|
it('renders basic component', async () => {
|
|
8
11
|
var _a, _b, _c, _d;
|
|
@@ -30,7 +33,7 @@ describe('Manage bar', () => {
|
|
|
30
33
|
});
|
|
31
34
|
it('render item manager button for /search/ page', async () => {
|
|
32
35
|
var _a;
|
|
33
|
-
const el = await fixture(html `<manage-bar
|
|
36
|
+
const el = await fixture(html `<manage-bar showItemManageButton></manage-bar>`);
|
|
34
37
|
expect((_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.ia-button.warning')).to.exist;
|
|
35
38
|
});
|
|
36
39
|
it('includes Select All button when requested', async () => {
|
|
@@ -61,15 +64,6 @@ describe('Manage bar', () => {
|
|
|
61
64
|
cancelBtn.click();
|
|
62
65
|
expect(spy.callCount).to.equal(1);
|
|
63
66
|
});
|
|
64
|
-
it('emits event when Remove Items button clicked', async () => {
|
|
65
|
-
var _a;
|
|
66
|
-
const spy = Sinon.spy();
|
|
67
|
-
const el = await fixture(html `<manage-bar @removeItems=${spy} removeAllowed></manage-bar>`);
|
|
68
|
-
const removeItemsBtn = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.ia-button.danger');
|
|
69
|
-
expect(removeItemsBtn).to.exist;
|
|
70
|
-
removeItemsBtn.click();
|
|
71
|
-
expect(spy.callCount).to.equal(1);
|
|
72
|
-
});
|
|
73
67
|
it('emits event when Select All button clicked', async () => {
|
|
74
68
|
var _a;
|
|
75
69
|
const spy = Sinon.spy();
|
|
@@ -88,5 +82,26 @@ describe('Manage bar', () => {
|
|
|
88
82
|
unselectAllBtn.click();
|
|
89
83
|
expect(spy.callCount).to.equal(1);
|
|
90
84
|
});
|
|
85
|
+
it('opens the remove items modal when showRemoveItemsModal is clicked', async () => {
|
|
86
|
+
var _a, _b, _c, _d;
|
|
87
|
+
const el = await fixture(html `
|
|
88
|
+
<manage-bar
|
|
89
|
+
.modalManager=${new ModalManager()}
|
|
90
|
+
.selectedItems=${[{ identifier: '1', title: 'Item 1' }]}
|
|
91
|
+
removeAllowed
|
|
92
|
+
></manage-bar>
|
|
93
|
+
`);
|
|
94
|
+
await el.updateComplete;
|
|
95
|
+
const removeButton = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.ia-button.danger');
|
|
96
|
+
expect(removeButton).to.exist;
|
|
97
|
+
const showModalSpy = Sinon.spy(el.modalManager, 'showModal');
|
|
98
|
+
await el.updateComplete;
|
|
99
|
+
removeButton === null || removeButton === void 0 ? void 0 : removeButton.click();
|
|
100
|
+
console.log((_b = showModalSpy.args[0][0].config.title) === null || _b === void 0 ? void 0 : _b.values[0]);
|
|
101
|
+
expect(showModalSpy.callCount).to.equal(1);
|
|
102
|
+
expect((_c = el.modalManager) === null || _c === void 0 ? void 0 : _c.classList.contains('remove-items')).to.be;
|
|
103
|
+
expect((_d = showModalSpy.args[0][0].config.title) === null || _d === void 0 ? void 0 : _d.values[0]).to.equal(msg('Are you sure you want to remove these items?'));
|
|
104
|
+
expect(showModalSpy.args[0][0].customModalContent).to.exist;
|
|
105
|
+
});
|
|
91
106
|
});
|
|
92
107
|
//# sourceMappingURL=manage-bar.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manage-bar.test.js","sourceRoot":"","sources":["../../../test/manage/manage-bar.test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,CAAC,KAAK,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable import/no-duplicates */\nimport { expect, fixture } from '@open-wc/testing';\nimport { html } from 'lit';\nimport Sinon from 'sinon';\nimport type { ManageBar } from '../../src/manage/manage-bar';\n\nimport '../../src/manage/manage-bar';\n\ndescribe('Manage bar', () => {\n it('renders basic component', async () => {\n const el = await fixture<ManageBar>(html`<manage-bar></manage-bar>`);\n\n expect(el.shadowRoot?.querySelector('.manage-label')).to.exist;\n expect(el.shadowRoot?.querySelector('.manage-buttons')).to.exist;\n expect(el.shadowRoot?.querySelector('.ia-button.dark')).to.exist;\n expect(el.shadowRoot?.querySelector('.ia-button.danger')).to.exist;\n });\n\n it('can set the label', async () => {\n const el = await fixture<ManageBar>(\n html`<manage-bar label=\"foo bar\"></manage-bar>`\n );\n expect(el.shadowRoot?.querySelector('.manage-label')?.textContent).to.equal(\n 'foo bar'\n );\n });\n\n it('does not include Select All/Unselect All buttons by default', async () => {\n const el = await fixture<ManageBar>(html`<manage-bar></manage-bar>`);\n expect(el.shadowRoot?.querySelector('.select-all-btn')).not.to.exist;\n expect(el.shadowRoot?.querySelector('.unselect-all-btn')).not.to.exist;\n });\n\n it('does not render item manager button except /search/ page', async () => {\n const el = await fixture<ManageBar>(html`<manage-bar></manage-bar>`);\n expect(el.shadowRoot?.querySelector('.ia-button.warning')).not.to.exist;\n });\n\n it('render item manager button for /search/ page', async () => {\n const el = await fixture<ManageBar>(\n html`<manage-bar .pageContext=${'search'}></manage-bar>`\n );\n expect(el.shadowRoot?.querySelector('.ia-button.warning')).to.exist;\n });\n\n it('includes Select All button when requested', async () => {\n const el = await fixture<ManageBar>(\n html`<manage-bar showSelectAll></manage-bar>`\n );\n expect(el.shadowRoot?.querySelector('.select-all-btn')).to.exist;\n });\n\n it('includes Unselect All button when requested', async () => {\n const el = await fixture<ManageBar>(\n html`<manage-bar showUnselectAll></manage-bar>`\n );\n expect(el.shadowRoot?.querySelector('.unselect-all-btn')).to.exist;\n });\n\n it('default and toggle state of remove button', async () => {\n const el = await fixture<ManageBar>(html`<manage-bar></manage-bar>`);\n\n expect(el.shadowRoot?.querySelector('.ia-button.danger:disabled')).to.exist;\n\n el.removeAllowed = true;\n await el.updateComplete;\n\n expect(el.shadowRoot?.querySelector('.ia-button.danger:disabled')).to.not\n .exist;\n });\n\n it('emits event when Cancel button clicked', async () => {\n const spy = Sinon.spy();\n const el = await fixture<ManageBar>(\n html`<manage-bar @cancel=${spy}></manage-bar>`\n );\n\n const cancelBtn = el.shadowRoot?.querySelector(\n '.ia-button.dark'\n ) as HTMLButtonElement;\n expect(cancelBtn).to.exist;\n\n cancelBtn.click();\n expect(spy.callCount).to.equal(1);\n });\n\n it('emits event when Remove Items button clicked', async () => {\n const spy = Sinon.spy();\n const el = await fixture<ManageBar>(\n html`<manage-bar @removeItems=${spy} removeAllowed></manage-bar>`\n );\n\n const removeItemsBtn = el.shadowRoot?.querySelector(\n '.ia-button.danger'\n ) as HTMLButtonElement;\n expect(removeItemsBtn).to.exist;\n\n removeItemsBtn.click();\n expect(spy.callCount).to.equal(1);\n });\n\n it('emits event when Select All button clicked', async () => {\n const spy = Sinon.spy();\n const el = await fixture<ManageBar>(\n html`<manage-bar showSelectAll @selectAll=${spy}></manage-bar>`\n );\n\n const selectAllBtn = el.shadowRoot?.querySelector(\n '.select-all-btn'\n ) as HTMLButtonElement;\n expect(selectAllBtn).to.exist;\n\n selectAllBtn.click();\n expect(spy.callCount).to.equal(1);\n });\n\n it('emits event when Unselect All button clicked', async () => {\n const spy = Sinon.spy();\n const el = await fixture<ManageBar>(\n html`<manage-bar showUnselectAll @unselectAll=${spy}></manage-bar>`\n );\n\n const unselectAllBtn = el.shadowRoot?.querySelector(\n '.unselect-all-btn'\n ) as HTMLButtonElement;\n expect(unselectAllBtn).to.exist;\n\n unselectAllBtn.click();\n expect(spy.callCount).to.equal(1);\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"manage-bar.test.js","sourceRoot":"","sources":["../../../test/manage/manage-bar.test.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,6BAA6B,CAAC;AACrC,OAAO,EACL,YAAY,GAEb,MAAM,gCAAgC,CAAC;AACxC,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;;QACvC,MAAM,EAAE,GAAG,MAAM,OAAO,CAAY,IAAI,CAAA,2BAA2B,CAAC,CAAC;QAErE,MAAM,CAAC,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC/D,MAAM,CAAC,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACjE,MAAM,CAAC,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACjE,MAAM,CAAC,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;IACrE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;;QACjC,MAAM,EAAE,GAAG,MAAM,OAAO,CACtB,IAAI,CAAA,2CAA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AAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable import/no-duplicates */\nimport { expect, fixture } from '@open-wc/testing';\nimport { html } from 'lit';\nimport Sinon from 'sinon';\nimport '../../src/manage/manage-bar';\nimport {\n ModalManager,\n ModalManagerInterface,\n} from '@internetarchive/modal-manager';\nimport '@internetarchive/modal-manager';\nimport { msg } from '@lit/localize';\nimport type { ManageBar } from '../../src/manage/manage-bar';\n\ndescribe('Manage bar', () => {\n it('renders basic component', async () => {\n const el = await fixture<ManageBar>(html`<manage-bar></manage-bar>`);\n\n expect(el.shadowRoot?.querySelector('.manage-label')).to.exist;\n expect(el.shadowRoot?.querySelector('.manage-buttons')).to.exist;\n expect(el.shadowRoot?.querySelector('.ia-button.dark')).to.exist;\n expect(el.shadowRoot?.querySelector('.ia-button.danger')).to.exist;\n });\n\n it('can set the label', async () => {\n const el = await fixture<ManageBar>(\n html`<manage-bar label=\"foo bar\"></manage-bar>`\n );\n expect(el.shadowRoot?.querySelector('.manage-label')?.textContent).to.equal(\n 'foo bar'\n );\n });\n\n it('does not include Select All/Unselect All buttons by default', async () => {\n const el = await fixture<ManageBar>(html`<manage-bar></manage-bar>`);\n expect(el.shadowRoot?.querySelector('.select-all-btn')).not.to.exist;\n expect(el.shadowRoot?.querySelector('.unselect-all-btn')).not.to.exist;\n });\n\n it('does not render item manager button except /search/ page', async () => {\n const el = await fixture<ManageBar>(html`<manage-bar></manage-bar>`);\n expect(el.shadowRoot?.querySelector('.ia-button.warning')).not.to.exist;\n });\n\n it('render item manager button for /search/ page', async () => {\n const el = await fixture<ManageBar>(\n html`<manage-bar showItemManageButton></manage-bar>`\n );\n expect(el.shadowRoot?.querySelector('.ia-button.warning')).to.exist;\n });\n\n it('includes Select All button when requested', async () => {\n const el = await fixture<ManageBar>(\n html`<manage-bar showSelectAll></manage-bar>`\n );\n expect(el.shadowRoot?.querySelector('.select-all-btn')).to.exist;\n });\n\n it('includes Unselect All button when requested', async () => {\n const el = await fixture<ManageBar>(\n html`<manage-bar showUnselectAll></manage-bar>`\n );\n expect(el.shadowRoot?.querySelector('.unselect-all-btn')).to.exist;\n });\n\n it('default and toggle state of remove button', async () => {\n const el = await fixture<ManageBar>(html`<manage-bar></manage-bar>`);\n\n expect(el.shadowRoot?.querySelector('.ia-button.danger:disabled')).to.exist;\n\n el.removeAllowed = true;\n await el.updateComplete;\n\n expect(el.shadowRoot?.querySelector('.ia-button.danger:disabled')).to.not\n .exist;\n });\n\n it('emits event when Cancel button clicked', async () => {\n const spy = Sinon.spy();\n const el = await fixture<ManageBar>(\n html`<manage-bar @cancel=${spy}></manage-bar>`\n );\n\n const cancelBtn = el.shadowRoot?.querySelector(\n '.ia-button.dark'\n ) as HTMLButtonElement;\n expect(cancelBtn).to.exist;\n\n cancelBtn.click();\n expect(spy.callCount).to.equal(1);\n });\n\n it('emits event when Select All button clicked', async () => {\n const spy = Sinon.spy();\n const el = await fixture<ManageBar>(\n html`<manage-bar showSelectAll @selectAll=${spy}></manage-bar>`\n );\n\n const selectAllBtn = el.shadowRoot?.querySelector(\n '.select-all-btn'\n ) as HTMLButtonElement;\n expect(selectAllBtn).to.exist;\n\n selectAllBtn.click();\n expect(spy.callCount).to.equal(1);\n });\n\n it('emits event when Unselect All button clicked', async () => {\n const spy = Sinon.spy();\n const el = await fixture<ManageBar>(\n html`<manage-bar showUnselectAll @unselectAll=${spy}></manage-bar>`\n );\n\n const unselectAllBtn = el.shadowRoot?.querySelector(\n '.unselect-all-btn'\n ) as HTMLButtonElement;\n expect(unselectAllBtn).to.exist;\n\n unselectAllBtn.click();\n expect(spy.callCount).to.equal(1);\n });\n\n it('opens the remove items modal when showRemoveItemsModal is clicked', async () => {\n const el = await fixture<ManageBar>(html`\n <manage-bar\n .modalManager=${new ModalManager()}\n .selectedItems=${[{ identifier: '1', title: 'Item 1' }]}\n removeAllowed\n ></manage-bar>\n `);\n await el.updateComplete;\n\n const removeButton = el.shadowRoot?.querySelector(\n '.ia-button.danger'\n ) as HTMLButtonElement;\n expect(removeButton).to.exist;\n\n const showModalSpy = Sinon.spy(\n el.modalManager as ModalManagerInterface,\n 'showModal'\n );\n\n await el.updateComplete;\n removeButton?.click();\n\n console.log(showModalSpy.args[0][0].config.title?.values[0]);\n\n expect(showModalSpy.callCount).to.equal(1);\n expect(el.modalManager?.classList.contains('remove-items')).to.be;\n expect(showModalSpy.args[0][0].config.title?.values[0]).to.equal(\n msg('Are you sure you want to remove these items?')\n );\n expect(showModalSpy.args[0][0].customModalContent).to.exist;\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../src/manage/remove-items-modal-content';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* eslint-disable import/no-duplicates */
|
|
2
|
+
import { expect, fixture } from '@open-wc/testing';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
import Sinon from 'sinon';
|
|
5
|
+
import '../../src/manage/remove-items-modal-content';
|
|
6
|
+
describe('RemoveItemsModalContent', () => {
|
|
7
|
+
const items = [
|
|
8
|
+
{ identifier: '1', title: 'Item 1', date: '2022-01-01' },
|
|
9
|
+
{ identifier: '2', title: 'Item 2', date: '2022-01-02' },
|
|
10
|
+
];
|
|
11
|
+
it('renders basic component', async () => {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
const el = await fixture(html `
|
|
14
|
+
<remove-items-modal-content
|
|
15
|
+
.items=${items}
|
|
16
|
+
.message=${''}
|
|
17
|
+
></remove-items-modal-content>
|
|
18
|
+
`);
|
|
19
|
+
expect((_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('ul')).to.exist;
|
|
20
|
+
expect((_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.button-bar')).to.exist;
|
|
21
|
+
expect((_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('.remove-items-btn')).to.exist;
|
|
22
|
+
});
|
|
23
|
+
it('renders list of items', async () => {
|
|
24
|
+
var _a;
|
|
25
|
+
const el = await fixture(html `
|
|
26
|
+
<remove-items-modal-content
|
|
27
|
+
.items=${items}
|
|
28
|
+
.message=${''}
|
|
29
|
+
></remove-items-modal-content>
|
|
30
|
+
`);
|
|
31
|
+
const listItems = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('li');
|
|
32
|
+
expect(listItems).to.have.lengthOf(2);
|
|
33
|
+
listItems === null || listItems === void 0 ? void 0 : listItems.forEach((item, index) => {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
expect((_a = item.querySelector('.item-title')) === null || _a === void 0 ? void 0 : _a.textContent).to.equal(items[index].title);
|
|
36
|
+
expect((_b = item.querySelector('.item-date')) === null || _b === void 0 ? void 0 : _b.textContent).to.equal(items[index].date);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
it('renders message', async () => {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
const message = 'This is a test message';
|
|
42
|
+
const el = await fixture(html `
|
|
43
|
+
<remove-items-modal-content
|
|
44
|
+
.items=${[]}
|
|
45
|
+
.message=${message}
|
|
46
|
+
></remove-items-modal-content>
|
|
47
|
+
`);
|
|
48
|
+
expect((_b = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.message')) === null || _b === void 0 ? void 0 : _b.textContent).to.equal(message);
|
|
49
|
+
});
|
|
50
|
+
it('dispatches confirm event when remove items button is clicked', async () => {
|
|
51
|
+
var _a;
|
|
52
|
+
const el = await fixture(html `
|
|
53
|
+
<remove-items-modal-content
|
|
54
|
+
.items=${items}
|
|
55
|
+
.message=${''}
|
|
56
|
+
></remove-items-modal-content>
|
|
57
|
+
`);
|
|
58
|
+
const spy = Sinon.spy();
|
|
59
|
+
el.addEventListener('confirm', spy);
|
|
60
|
+
const button = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.remove-items-btn');
|
|
61
|
+
button === null || button === void 0 ? void 0 : button.click();
|
|
62
|
+
expect(spy.calledOnce).to.be.true;
|
|
63
|
+
expect(spy.args[0][0].detail.items).to.deep.equal(items);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=remove-items-modal-content.test.js.map
|