@internetarchive/collection-browser 3.3.3 → 3.3.4-alpha-webdev7761.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/collection-browser.d.ts +10 -2
- package/dist/src/collection-browser.js +112 -10
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-row.js +141 -140
- package/dist/src/collection-facets/facet-row.js.map +1 -1
- package/dist/src/collection-facets/models.js.map +1 -1
- package/dist/src/collection-facets.js +12 -0
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source-interface.d.ts +10 -1
- package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.d.ts +19 -1
- package/dist/src/data-source/collection-browser-data-source.js +36 -18
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.d.ts +1 -2
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
- package/dist/src/data-source/models.d.ts +11 -0
- package/dist/src/data-source/models.js.map +1 -1
- package/dist/src/manage/manage-bar.js +77 -77
- package/dist/src/manage/manage-bar.js.map +1 -1
- package/dist/src/models.d.ts +2 -6
- package/dist/src/models.js +8 -12
- package/dist/src/models.js.map +1 -1
- package/dist/src/restoration-state-handler.d.ts +1 -2
- package/dist/src/restoration-state-handler.js +3 -9
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/tiles/grid/search-tile.js +42 -42
- package/dist/src/tiles/grid/search-tile.js.map +1 -1
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +119 -119
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
- package/dist/test/collection-browser.test.js +19 -9
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/facet-row.test.js +23 -23
- package/dist/test/collection-facets/facet-row.test.js.map +1 -1
- package/dist/test/collection-facets.test.js +20 -20
- package/dist/test/collection-facets.test.js.map +1 -1
- package/dist/test/restoration-state-handler.test.js +5 -37
- package/dist/test/restoration-state-handler.test.js.map +1 -1
- package/package.json +1 -1
- package/src/collection-browser.ts +132 -7
- package/src/collection-facets/facet-row.ts +299 -296
- package/src/collection-facets/models.ts +10 -10
- package/src/collection-facets.ts +11 -0
- package/src/data-source/collection-browser-data-source-interface.ts +345 -333
- package/src/data-source/collection-browser-data-source.ts +59 -19
- package/src/data-source/collection-browser-query-state.ts +1 -7
- package/src/data-source/models.ts +13 -0
- package/src/manage/manage-bar.ts +247 -247
- package/src/models.ts +866 -870
- package/src/restoration-state-handler.ts +542 -544
- package/src/tiles/grid/search-tile.ts +90 -90
- package/src/tiles/grid/styles/tile-grid-shared-styles.ts +130 -130
- package/test/collection-browser.test.ts +21 -11
- package/test/collection-facets/facet-row.test.ts +375 -375
- package/test/collection-facets.test.ts +928 -928
- package/test/restoration-state-handler.test.ts +480 -510
|
@@ -24,7 +24,11 @@ import {
|
|
|
24
24
|
SORT_OPTIONS,
|
|
25
25
|
HitRequestSource,
|
|
26
26
|
} from '../models';
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
FACETLESS_PAGE_ELEMENTS,
|
|
29
|
+
TVChannelMaps,
|
|
30
|
+
type PageSpecifierParams,
|
|
31
|
+
} from './models';
|
|
28
32
|
import type { CollectionBrowserDataSourceInterface } from './collection-browser-data-source-interface';
|
|
29
33
|
import type { CollectionBrowserSearchInterface } from './collection-browser-query-state';
|
|
30
34
|
import { sha1 } from '../utils/sha1';
|
|
@@ -121,6 +125,11 @@ export class CollectionBrowserDataSource
|
|
|
121
125
|
*/
|
|
122
126
|
collectionTitles = new Map<string, string>();
|
|
123
127
|
|
|
128
|
+
/**
|
|
129
|
+
* @inheritdoc
|
|
130
|
+
*/
|
|
131
|
+
tvChannelMaps: TVChannelMaps = {};
|
|
132
|
+
|
|
124
133
|
/**
|
|
125
134
|
* @inheritdoc
|
|
126
135
|
*/
|
|
@@ -162,6 +171,11 @@ export class CollectionBrowserDataSource
|
|
|
162
171
|
*/
|
|
163
172
|
queryErrorMessage?: string;
|
|
164
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Internal property to store the promise for any current TV channel maps fetch.
|
|
176
|
+
*/
|
|
177
|
+
private _tvMapsPromise?: Promise<TVChannelMaps>;
|
|
178
|
+
|
|
165
179
|
/**
|
|
166
180
|
* Internal property to store the private value backing the `initialSearchComplete` getter.
|
|
167
181
|
*/
|
|
@@ -773,24 +787,6 @@ export class CollectionBrowserDataSource
|
|
|
773
787
|
);
|
|
774
788
|
}
|
|
775
789
|
|
|
776
|
-
// Add any TV clip type filter, if applicable
|
|
777
|
-
if (this.host.searchType === SearchType.TV) {
|
|
778
|
-
switch (this.host.tvClipFilter) {
|
|
779
|
-
case 'commercials':
|
|
780
|
-
builder.addFilter('ad_id', '*', FilterConstraint.INCLUDE);
|
|
781
|
-
break;
|
|
782
|
-
case 'factchecks':
|
|
783
|
-
builder.addFilter('factcheck', '*', FilterConstraint.INCLUDE);
|
|
784
|
-
break;
|
|
785
|
-
case 'quotes':
|
|
786
|
-
builder.addFilter('clip', '1', FilterConstraint.INCLUDE);
|
|
787
|
-
break;
|
|
788
|
-
case 'all':
|
|
789
|
-
default:
|
|
790
|
-
break;
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
|
|
794
790
|
const filterMap = builder.build();
|
|
795
791
|
return filterMap;
|
|
796
792
|
}
|
|
@@ -1398,4 +1394,48 @@ export class CollectionBrowserDataSource
|
|
|
1398
1394
|
this.updatePrefixFiltersForCurrentSort();
|
|
1399
1395
|
this.requestHostUpdate();
|
|
1400
1396
|
}
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1399
|
+
* @inheritdoc
|
|
1400
|
+
*/
|
|
1401
|
+
populateTVChannelMaps(): Promise<TVChannelMaps> {
|
|
1402
|
+
// To ensure that we only make these requests once, cache the Promise returned by the
|
|
1403
|
+
// first call, and return the same Promise on repeated calls.
|
|
1404
|
+
// Resolves once both maps have been retrieved and saved in the data source.
|
|
1405
|
+
if (!this._tvMapsPromise) {
|
|
1406
|
+
this._tvMapsPromise = this._fetchTVChannelMaps();
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
return this._tvMapsPromise;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* Internal function implementing the actual fetches for TV channel mappings.
|
|
1414
|
+
* This should only called by the public populateTVChannelMaps method, which is guarded so
|
|
1415
|
+
* that we do not make extra requests for these rather large mappings.
|
|
1416
|
+
*/
|
|
1417
|
+
private async _fetchTVChannelMaps(): Promise<TVChannelMaps> {
|
|
1418
|
+
const baseURL = 'https://av.archive.org/etc';
|
|
1419
|
+
const dateStr = new Date().toISOString().slice(0, 10); // YYYY-MM-DD
|
|
1420
|
+
const chan2networkPromise = fetch(
|
|
1421
|
+
`${baseURL}/chan2network.json?date=${dateStr}`,
|
|
1422
|
+
);
|
|
1423
|
+
const program2chansPromise = fetch(
|
|
1424
|
+
`${baseURL}/program2chans.json?date=${dateStr}`,
|
|
1425
|
+
);
|
|
1426
|
+
|
|
1427
|
+
const [chan2networkResponse, program2chansResponse] = await Promise.all([
|
|
1428
|
+
chan2networkPromise,
|
|
1429
|
+
program2chansPromise,
|
|
1430
|
+
]);
|
|
1431
|
+
this.tvChannelMaps.channelToNetwork = new Map(
|
|
1432
|
+
Object.entries(await chan2networkResponse.json()),
|
|
1433
|
+
);
|
|
1434
|
+
this.tvChannelMaps.programToChannels = new Map(
|
|
1435
|
+
Object.entries(await program2chansResponse.json()),
|
|
1436
|
+
);
|
|
1437
|
+
|
|
1438
|
+
this.requestHostUpdate();
|
|
1439
|
+
return this.tvChannelMaps;
|
|
1440
|
+
}
|
|
1401
1441
|
}
|
|
@@ -6,12 +6,7 @@ import type {
|
|
|
6
6
|
SortDirection,
|
|
7
7
|
SortParam,
|
|
8
8
|
} from '@internetarchive/search-service';
|
|
9
|
-
import type {
|
|
10
|
-
FacetLoadStrategy,
|
|
11
|
-
SelectedFacets,
|
|
12
|
-
SortField,
|
|
13
|
-
TvClipFilterType,
|
|
14
|
-
} from '../models';
|
|
9
|
+
import type { FacetLoadStrategy, SelectedFacets, SortField } from '../models';
|
|
15
10
|
import type { CollectionBrowserDataSourceInterface } from './collection-browser-data-source-interface';
|
|
16
11
|
|
|
17
12
|
/**
|
|
@@ -30,7 +25,6 @@ export interface CollectionBrowserQueryState {
|
|
|
30
25
|
maxSelectedDate?: string;
|
|
31
26
|
selectedTitleFilter: string | null;
|
|
32
27
|
selectedCreatorFilter: string | null;
|
|
33
|
-
tvClipFilter?: TvClipFilterType;
|
|
34
28
|
selectedSort?: SortField;
|
|
35
29
|
sortDirection: SortDirection | null;
|
|
36
30
|
}
|
|
@@ -13,6 +13,19 @@ export type CollectionTitles = Map<string, string>;
|
|
|
13
13
|
*/
|
|
14
14
|
export type TVChannelAliases = Map<string, string>;
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* A Map from program (show) names to a mapping of all the channels that run them.
|
|
18
|
+
*/
|
|
19
|
+
export type TVProgramChannels = Map<string, Record<string, number>>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Object storing the different TV channel mappings used by the data source.
|
|
23
|
+
*/
|
|
24
|
+
export type TVChannelMaps = {
|
|
25
|
+
channelToNetwork?: TVChannelAliases;
|
|
26
|
+
programToChannels?: TVProgramChannels;
|
|
27
|
+
};
|
|
28
|
+
|
|
16
29
|
/**
|
|
17
30
|
* The subset of search service params that uniquely specify the type of results
|
|
18
31
|
* that are sought by an instance of collection browser.
|
package/src/manage/manage-bar.ts
CHANGED
|
@@ -1,247 +1,247 @@
|
|
|
1
|
-
import { msg } from '@lit/localize';
|
|
2
|
-
import { LitElement, html, css, TemplateResult, CSSResultGroup } from 'lit';
|
|
3
|
-
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
-
import { when } from 'lit/directives/when.js';
|
|
5
|
-
import {
|
|
6
|
-
ModalConfig,
|
|
7
|
-
type ModalManagerInterface,
|
|
8
|
-
} from '@internetarchive/modal-manager';
|
|
9
|
-
import type { ManageableItem } from '../models';
|
|
10
|
-
import iaButtonStyle from '../styles/ia-button';
|
|
11
|
-
import './remove-items-modal-content';
|
|
12
|
-
|
|
13
|
-
@customElement('manage-bar')
|
|
14
|
-
export class ManageBar extends LitElement {
|
|
15
|
-
/**
|
|
16
|
-
* The label displayed in front of the management buttons
|
|
17
|
-
*/
|
|
18
|
-
@property({ type: String }) label = msg('Select items to remove');
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The shared modal manager component for displaying modal dialogs on this page
|
|
22
|
-
*/
|
|
23
|
-
@property({ type: Object }) modalManager?: ModalManagerInterface;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Array of items that have been selected for management
|
|
27
|
-
*/
|
|
28
|
-
@property({ type: Object }) selectedItems: Array<ManageableItem> = [];
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Message shows as note in the modal when removing items
|
|
32
|
-
*/
|
|
33
|
-
@property({ type: String }) manageViewModalMsg?: string;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Whether to show the "Select All" button (default false)
|
|
37
|
-
*/
|
|
38
|
-
@property({ type: Boolean }) showSelectAll = false;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Whether to show the "Unselect All" button (default false)
|
|
42
|
-
*/
|
|
43
|
-
@property({ type: Boolean }) showUnselectAll = false;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Whether to show "Item Manager the items" button (default false)
|
|
47
|
-
*/
|
|
48
|
-
@property({ type: Boolean }) showItemManageButton = false;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Whether to active delete button for selectable items
|
|
52
|
-
*/
|
|
53
|
-
@property({ type: Boolean }) removeAllowed = false;
|
|
54
|
-
|
|
55
|
-
render(): TemplateResult {
|
|
56
|
-
return html`
|
|
57
|
-
<div class="manage-container">
|
|
58
|
-
<span class="manage-label">${this.label}</span>
|
|
59
|
-
<div class="manage-buttons">
|
|
60
|
-
<button class="ia-button dark" @click=${this.cancelClicked}>
|
|
61
|
-
${msg('Cancel')}
|
|
62
|
-
</button>
|
|
63
|
-
<button
|
|
64
|
-
class="ia-button danger"
|
|
65
|
-
?disabled=${!this.removeAllowed}
|
|
66
|
-
@click=${this.showRemoveItemsModal}
|
|
67
|
-
>
|
|
68
|
-
${msg('Remove selected items')} (${this.selectedItems.length})...
|
|
69
|
-
</button>
|
|
70
|
-
${when(
|
|
71
|
-
this.showItemManageButton,
|
|
72
|
-
() =>
|
|
73
|
-
html` <button
|
|
74
|
-
class="ia-button warning"
|
|
75
|
-
?disabled=${!this.removeAllowed}
|
|
76
|
-
@click=${this.manageItemsClicked}
|
|
77
|
-
>
|
|
78
|
-
${msg('Item Manager the items')} (${this.selectedItems.length})
|
|
79
|
-
</button>`,
|
|
80
|
-
)}
|
|
81
|
-
<div class="selection-buttons">
|
|
82
|
-
${when(
|
|
83
|
-
this.showSelectAll,
|
|
84
|
-
() =>
|
|
85
|
-
html` <button
|
|
86
|
-
class="ia-button link select-all-btn"
|
|
87
|
-
@click=${this.selectAllClicked}
|
|
88
|
-
>
|
|
89
|
-
${msg('Select all')}
|
|
90
|
-
</button>`,
|
|
91
|
-
)}
|
|
92
|
-
${when(
|
|
93
|
-
this.showUnselectAll,
|
|
94
|
-
() =>
|
|
95
|
-
html` <button
|
|
96
|
-
class="ia-button link unselect-all-btn"
|
|
97
|
-
@click=${this.unselectAllClicked}
|
|
98
|
-
>
|
|
99
|
-
${msg('Unselect all')}
|
|
100
|
-
</button>`,
|
|
101
|
-
)}
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
</div>
|
|
105
|
-
`;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
private cancelClicked(): void {
|
|
109
|
-
this.dispatchEvent(new CustomEvent('cancel'));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
private removeItemsClicked(): void {
|
|
113
|
-
this.dispatchEvent(new CustomEvent('removeItems'));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
private manageItemsClicked(): void {
|
|
117
|
-
this.dispatchEvent(new CustomEvent('manageItems'));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
private selectAllClicked(): void {
|
|
121
|
-
this.dispatchEvent(new CustomEvent('selectAll'));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
private unselectAllClicked(): void {
|
|
125
|
-
this.dispatchEvent(new CustomEvent('unselectAll'));
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Shows a modal dialog confirming the list of items to be removed
|
|
130
|
-
* @param items Which items to list in the modal
|
|
131
|
-
*/
|
|
132
|
-
private showRemoveItemsModal(): void {
|
|
133
|
-
const customModalContent = html`
|
|
134
|
-
<remove-items-modal-content
|
|
135
|
-
.items=${this.selectedItems}
|
|
136
|
-
.message=${this.manageViewModalMsg}
|
|
137
|
-
@confirm=${() => this.removeItemsClicked()}
|
|
138
|
-
></remove-items-modal-content>
|
|
139
|
-
`;
|
|
140
|
-
|
|
141
|
-
const config = new ModalConfig({
|
|
142
|
-
showProcessingIndicator: false,
|
|
143
|
-
processingImageMode: 'processing',
|
|
144
|
-
bodyColor: '#fff',
|
|
145
|
-
headerColor: '#194880',
|
|
146
|
-
showHeaderLogo: false,
|
|
147
|
-
closeOnBackdropClick: true,
|
|
148
|
-
title: html`${msg('Are you sure you want to remove these items?')}`,
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
this.modalManager?.classList.add('remove-items');
|
|
152
|
-
this.modalManager?.showModal({
|
|
153
|
-
config,
|
|
154
|
-
customModalContent,
|
|
155
|
-
userClosedModalCallback: () => {
|
|
156
|
-
this.modalManager?.classList.remove('remove-items');
|
|
157
|
-
},
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Shows a modal dialog indicating that item removal is being processed
|
|
163
|
-
*/
|
|
164
|
-
showRemoveItemsProcessingModal(): void {
|
|
165
|
-
const config = new ModalConfig({
|
|
166
|
-
showProcessingIndicator: true,
|
|
167
|
-
processingImageMode: 'processing',
|
|
168
|
-
bodyColor: '#fff',
|
|
169
|
-
headerColor: '#194880',
|
|
170
|
-
showHeaderLogo: false,
|
|
171
|
-
closeOnBackdropClick: true,
|
|
172
|
-
title: html`${msg('Removing selected items...')}`,
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
this.modalManager?.classList.add('remove-items');
|
|
176
|
-
this.modalManager?.showModal({
|
|
177
|
-
config,
|
|
178
|
-
userClosedModalCallback: () => {
|
|
179
|
-
this.modalManager?.classList.remove('remove-items');
|
|
180
|
-
},
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Shows a modal dialog indicating that an error occurred while removing items
|
|
186
|
-
*/
|
|
187
|
-
showRemoveItemsErrorModal(): void {
|
|
188
|
-
const config = new ModalConfig({
|
|
189
|
-
showProcessingIndicator: false,
|
|
190
|
-
processingImageMode: 'processing',
|
|
191
|
-
bodyColor: '#fff',
|
|
192
|
-
headerColor: '#691916',
|
|
193
|
-
showHeaderLogo: false,
|
|
194
|
-
closeOnBackdropClick: true,
|
|
195
|
-
title: html`${msg('Error: unable to remove items')}`,
|
|
196
|
-
message: html`${msg(
|
|
197
|
-
'An error occurred while removing items. Please try again in a few minutes.',
|
|
198
|
-
)}`,
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
this.modalManager?.classList.add('remove-items');
|
|
202
|
-
this.modalManager?.showModal({
|
|
203
|
-
config,
|
|
204
|
-
userClosedModalCallback: () => {
|
|
205
|
-
this.modalManager?.classList.remove('remove-items');
|
|
206
|
-
},
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
static get styles(): CSSResultGroup {
|
|
211
|
-
return css`
|
|
212
|
-
${iaButtonStyle}
|
|
213
|
-
.manage-container {
|
|
214
|
-
display: flex;
|
|
215
|
-
align-items: center;
|
|
216
|
-
column-gap: 5px;
|
|
217
|
-
padding: 20px 0 20px;
|
|
218
|
-
flex-wrap: wrap;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
.manage-label {
|
|
222
|
-
display: inline-block;
|
|
223
|
-
font-weight: bold;
|
|
224
|
-
font-size: 1.8rem;
|
|
225
|
-
padding-right: 10px;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.manage-buttons {
|
|
229
|
-
display: flex;
|
|
230
|
-
flex-wrap: wrap;
|
|
231
|
-
align-items: center;
|
|
232
|
-
column-gap: 5px;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
.selection-buttons {
|
|
236
|
-
display: inherit;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
.ia-button,
|
|
240
|
-
button {
|
|
241
|
-
padding: 6px 12px;
|
|
242
|
-
font-size: 1.4rem;
|
|
243
|
-
margin: 3px 0;
|
|
244
|
-
}
|
|
245
|
-
`;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
1
|
+
import { msg } from '@lit/localize';
|
|
2
|
+
import { LitElement, html, css, TemplateResult, CSSResultGroup } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { when } from 'lit/directives/when.js';
|
|
5
|
+
import {
|
|
6
|
+
ModalConfig,
|
|
7
|
+
type ModalManagerInterface,
|
|
8
|
+
} from '@internetarchive/modal-manager';
|
|
9
|
+
import type { ManageableItem } from '../models';
|
|
10
|
+
import iaButtonStyle from '../styles/ia-button';
|
|
11
|
+
import './remove-items-modal-content';
|
|
12
|
+
|
|
13
|
+
@customElement('manage-bar')
|
|
14
|
+
export class ManageBar extends LitElement {
|
|
15
|
+
/**
|
|
16
|
+
* The label displayed in front of the management buttons
|
|
17
|
+
*/
|
|
18
|
+
@property({ type: String }) label = msg('Select items to remove');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The shared modal manager component for displaying modal dialogs on this page
|
|
22
|
+
*/
|
|
23
|
+
@property({ type: Object }) modalManager?: ModalManagerInterface;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Array of items that have been selected for management
|
|
27
|
+
*/
|
|
28
|
+
@property({ type: Object }) selectedItems: Array<ManageableItem> = [];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Message shows as note in the modal when removing items
|
|
32
|
+
*/
|
|
33
|
+
@property({ type: String }) manageViewModalMsg?: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Whether to show the "Select All" button (default false)
|
|
37
|
+
*/
|
|
38
|
+
@property({ type: Boolean }) showSelectAll = false;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Whether to show the "Unselect All" button (default false)
|
|
42
|
+
*/
|
|
43
|
+
@property({ type: Boolean }) showUnselectAll = false;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether to show "Item Manager the items" button (default false)
|
|
47
|
+
*/
|
|
48
|
+
@property({ type: Boolean }) showItemManageButton = false;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Whether to active delete button for selectable items
|
|
52
|
+
*/
|
|
53
|
+
@property({ type: Boolean }) removeAllowed = false;
|
|
54
|
+
|
|
55
|
+
render(): TemplateResult {
|
|
56
|
+
return html`
|
|
57
|
+
<div class="manage-container">
|
|
58
|
+
<span class="manage-label">${this.label}</span>
|
|
59
|
+
<div class="manage-buttons">
|
|
60
|
+
<button class="ia-button dark" @click=${this.cancelClicked}>
|
|
61
|
+
${msg('Cancel')}
|
|
62
|
+
</button>
|
|
63
|
+
<button
|
|
64
|
+
class="ia-button danger"
|
|
65
|
+
?disabled=${!this.removeAllowed}
|
|
66
|
+
@click=${this.showRemoveItemsModal}
|
|
67
|
+
>
|
|
68
|
+
${msg('Remove selected items')} (${this.selectedItems.length})...
|
|
69
|
+
</button>
|
|
70
|
+
${when(
|
|
71
|
+
this.showItemManageButton,
|
|
72
|
+
() =>
|
|
73
|
+
html` <button
|
|
74
|
+
class="ia-button warning"
|
|
75
|
+
?disabled=${!this.removeAllowed}
|
|
76
|
+
@click=${this.manageItemsClicked}
|
|
77
|
+
>
|
|
78
|
+
${msg('Item Manager the items')} (${this.selectedItems.length})
|
|
79
|
+
</button>`,
|
|
80
|
+
)}
|
|
81
|
+
<div class="selection-buttons">
|
|
82
|
+
${when(
|
|
83
|
+
this.showSelectAll,
|
|
84
|
+
() =>
|
|
85
|
+
html` <button
|
|
86
|
+
class="ia-button link select-all-btn"
|
|
87
|
+
@click=${this.selectAllClicked}
|
|
88
|
+
>
|
|
89
|
+
${msg('Select all')}
|
|
90
|
+
</button>`,
|
|
91
|
+
)}
|
|
92
|
+
${when(
|
|
93
|
+
this.showUnselectAll,
|
|
94
|
+
() =>
|
|
95
|
+
html` <button
|
|
96
|
+
class="ia-button link unselect-all-btn"
|
|
97
|
+
@click=${this.unselectAllClicked}
|
|
98
|
+
>
|
|
99
|
+
${msg('Unselect all')}
|
|
100
|
+
</button>`,
|
|
101
|
+
)}
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private cancelClicked(): void {
|
|
109
|
+
this.dispatchEvent(new CustomEvent('cancel'));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private removeItemsClicked(): void {
|
|
113
|
+
this.dispatchEvent(new CustomEvent('removeItems'));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private manageItemsClicked(): void {
|
|
117
|
+
this.dispatchEvent(new CustomEvent('manageItems'));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
private selectAllClicked(): void {
|
|
121
|
+
this.dispatchEvent(new CustomEvent('selectAll'));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private unselectAllClicked(): void {
|
|
125
|
+
this.dispatchEvent(new CustomEvent('unselectAll'));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Shows a modal dialog confirming the list of items to be removed
|
|
130
|
+
* @param items Which items to list in the modal
|
|
131
|
+
*/
|
|
132
|
+
private showRemoveItemsModal(): void {
|
|
133
|
+
const customModalContent = html`
|
|
134
|
+
<remove-items-modal-content
|
|
135
|
+
.items=${this.selectedItems}
|
|
136
|
+
.message=${this.manageViewModalMsg}
|
|
137
|
+
@confirm=${() => this.removeItemsClicked()}
|
|
138
|
+
></remove-items-modal-content>
|
|
139
|
+
`;
|
|
140
|
+
|
|
141
|
+
const config = new ModalConfig({
|
|
142
|
+
showProcessingIndicator: false,
|
|
143
|
+
processingImageMode: 'processing',
|
|
144
|
+
bodyColor: '#fff',
|
|
145
|
+
headerColor: '#194880',
|
|
146
|
+
showHeaderLogo: false,
|
|
147
|
+
closeOnBackdropClick: true,
|
|
148
|
+
title: html`${msg('Are you sure you want to remove these items?')}`,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
this.modalManager?.classList.add('remove-items');
|
|
152
|
+
this.modalManager?.showModal({
|
|
153
|
+
config,
|
|
154
|
+
customModalContent,
|
|
155
|
+
userClosedModalCallback: () => {
|
|
156
|
+
this.modalManager?.classList.remove('remove-items');
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Shows a modal dialog indicating that item removal is being processed
|
|
163
|
+
*/
|
|
164
|
+
showRemoveItemsProcessingModal(): void {
|
|
165
|
+
const config = new ModalConfig({
|
|
166
|
+
showProcessingIndicator: true,
|
|
167
|
+
processingImageMode: 'processing',
|
|
168
|
+
bodyColor: '#fff',
|
|
169
|
+
headerColor: '#194880',
|
|
170
|
+
showHeaderLogo: false,
|
|
171
|
+
closeOnBackdropClick: true,
|
|
172
|
+
title: html`${msg('Removing selected items...')}`,
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
this.modalManager?.classList.add('remove-items');
|
|
176
|
+
this.modalManager?.showModal({
|
|
177
|
+
config,
|
|
178
|
+
userClosedModalCallback: () => {
|
|
179
|
+
this.modalManager?.classList.remove('remove-items');
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Shows a modal dialog indicating that an error occurred while removing items
|
|
186
|
+
*/
|
|
187
|
+
showRemoveItemsErrorModal(): void {
|
|
188
|
+
const config = new ModalConfig({
|
|
189
|
+
showProcessingIndicator: false,
|
|
190
|
+
processingImageMode: 'processing',
|
|
191
|
+
bodyColor: '#fff',
|
|
192
|
+
headerColor: '#691916',
|
|
193
|
+
showHeaderLogo: false,
|
|
194
|
+
closeOnBackdropClick: true,
|
|
195
|
+
title: html`${msg('Error: unable to remove items')}`,
|
|
196
|
+
message: html`${msg(
|
|
197
|
+
'An error occurred while removing items. Please try again in a few minutes.',
|
|
198
|
+
)}`,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
this.modalManager?.classList.add('remove-items');
|
|
202
|
+
this.modalManager?.showModal({
|
|
203
|
+
config,
|
|
204
|
+
userClosedModalCallback: () => {
|
|
205
|
+
this.modalManager?.classList.remove('remove-items');
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
static get styles(): CSSResultGroup {
|
|
211
|
+
return css`
|
|
212
|
+
${iaButtonStyle}
|
|
213
|
+
.manage-container {
|
|
214
|
+
display: flex;
|
|
215
|
+
align-items: center;
|
|
216
|
+
column-gap: 5px;
|
|
217
|
+
padding: 20px 0 20px;
|
|
218
|
+
flex-wrap: wrap;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.manage-label {
|
|
222
|
+
display: inline-block;
|
|
223
|
+
font-weight: bold;
|
|
224
|
+
font-size: 1.8rem;
|
|
225
|
+
padding-right: 10px;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.manage-buttons {
|
|
229
|
+
display: flex;
|
|
230
|
+
flex-wrap: wrap;
|
|
231
|
+
align-items: center;
|
|
232
|
+
column-gap: 5px;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.selection-buttons {
|
|
236
|
+
display: inherit;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.ia-button,
|
|
240
|
+
button {
|
|
241
|
+
padding: 6px 12px;
|
|
242
|
+
font-size: 1.4rem;
|
|
243
|
+
margin: 3px 0;
|
|
244
|
+
}
|
|
245
|
+
`;
|
|
246
|
+
}
|
|
247
|
+
}
|