@internetarchive/ia-book-actions 0.0.30-alpha1 → 0.0.30-alpha2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/collapsible-action-group.js +8 -8
- package/src/components/text-group.js +2 -2
- package/src/core/services/actions-handler/actions-handler-service.js +3 -0
- package/src/core/services/actions-handler/actions-handler.js +10 -0
- package/src/ia-book-actions.js +21 -5
package/package.json
CHANGED
|
@@ -102,9 +102,9 @@ export class CollapsibleActionGroup extends ActionsHandler {
|
|
|
102
102
|
return html`
|
|
103
103
|
<div
|
|
104
104
|
class="${classMap({
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
actiongroup: true,
|
|
106
|
+
disabled: this.disabled,
|
|
107
|
+
})}"
|
|
108
108
|
>
|
|
109
109
|
${this.getLoaderIcon}
|
|
110
110
|
<section class="action-buttons primary">
|
|
@@ -163,8 +163,8 @@ export class CollapsibleActionGroup extends ActionsHandler {
|
|
|
163
163
|
href="${action.url}"
|
|
164
164
|
target=${action.target}
|
|
165
165
|
@click=${() => {
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
this.clickHandler(action.id, action.analyticsEvent);
|
|
167
|
+
}}
|
|
168
168
|
>
|
|
169
169
|
${action.id === 'purchaseBook' ? purchaseIcon : ''} ${action.text}
|
|
170
170
|
<small>${action.subText}</small>
|
|
@@ -244,9 +244,9 @@ export class CollapsibleActionGroup extends ActionsHandler {
|
|
|
244
244
|
get getLoaderIcon() {
|
|
245
245
|
return html`<img
|
|
246
246
|
class="${classMap({
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
actionloader: true,
|
|
248
|
+
disabled: this.disabled,
|
|
249
|
+
})}"
|
|
250
250
|
alt=""
|
|
251
251
|
src="${this.loaderIcon}"
|
|
252
252
|
/>`;
|
|
@@ -20,8 +20,8 @@ export class TextGroup extends LitElement {
|
|
|
20
20
|
return html`
|
|
21
21
|
<span class="variable-texts ${this.textClass}">
|
|
22
22
|
${this.hasAdminBorrowedAccess
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
? html`<slot name="sticky-access-checkbox">${this.texts}</slot>`
|
|
24
|
+
: this.texts}
|
|
25
25
|
</span>
|
|
26
26
|
`;
|
|
27
27
|
}
|
|
@@ -30,6 +30,9 @@ export default async function ActionsHandlerService(options) {
|
|
|
30
30
|
let formData = new FormData();
|
|
31
31
|
formData.append('action', option.action);
|
|
32
32
|
formData.append('identifier', option.identifier);
|
|
33
|
+
formData.append('sticky-admin', option.stickyAccess);
|
|
34
|
+
console.log(option.stickyAccess);
|
|
35
|
+
|
|
33
36
|
try {
|
|
34
37
|
await fetch(baseHost, {
|
|
35
38
|
method: 'POST',
|
|
@@ -98,6 +98,16 @@ export default class ActionsHandler extends LitElement {
|
|
|
98
98
|
const { category, action } = detail.event;
|
|
99
99
|
this.sendEvent(category, action);
|
|
100
100
|
});
|
|
101
|
+
|
|
102
|
+
document.addEventListener('stickyAdminAccessToggled', ({ detail }) => {
|
|
103
|
+
ActionsHandlerService({
|
|
104
|
+
action: 'toggleAdminStickyAccess',
|
|
105
|
+
stickyAccess: detail.hasStickyAdminAccess,
|
|
106
|
+
identifier: this.identifier,
|
|
107
|
+
success: () => {},
|
|
108
|
+
error: () => {},
|
|
109
|
+
});
|
|
110
|
+
});
|
|
101
111
|
}
|
|
102
112
|
|
|
103
113
|
handleBrowseIt() {
|
package/src/ia-book-actions.js
CHANGED
|
@@ -12,7 +12,7 @@ import './components/info-icon.js';
|
|
|
12
12
|
import { GetLendingActions } from './core/services/get-lending-actions.js';
|
|
13
13
|
import { mobileContainerWidth } from './core/config/constants.js';
|
|
14
14
|
import { LoanTokenPoller } from './core/services/loan-token-poller.js';
|
|
15
|
-
import {
|
|
15
|
+
import { setItem } from './core/services/doc-cookies.js';
|
|
16
16
|
|
|
17
17
|
export const events = {
|
|
18
18
|
browseExpired: 'IABookReader:BrowsingHasExpired',
|
|
@@ -37,6 +37,7 @@ export default class IABookActions extends LitElement {
|
|
|
37
37
|
disableActionGroup: { type: Boolean },
|
|
38
38
|
modal: { Object },
|
|
39
39
|
tokenDelay: { type: Number },
|
|
40
|
+
hasStickyAdminAccess: { Boolean },
|
|
40
41
|
};
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -49,12 +50,13 @@ export default class IABookActions extends LitElement {
|
|
|
49
50
|
this.lendingStatus = {};
|
|
50
51
|
this.width = 0;
|
|
51
52
|
this.bwbPurchaseUrl = '';
|
|
52
|
-
this.lendingBarPostInit = () => {
|
|
53
|
+
this.lendingBarPostInit = () => {};
|
|
53
54
|
this.barType = 'action'; // 'title'|'action'
|
|
54
55
|
this.sharedObserver = undefined;
|
|
55
56
|
this.disableActionGroup = false;
|
|
56
57
|
this.modal = undefined;
|
|
57
58
|
this.tokenDelay = 120000; // 2 minutes
|
|
59
|
+
this.hasStickyAdminAccess = false;
|
|
58
60
|
|
|
59
61
|
// private props
|
|
60
62
|
this.primaryActions = [];
|
|
@@ -77,6 +79,9 @@ export default class IABookActions extends LitElement {
|
|
|
77
79
|
this.sharedObserver = new SharedResizeObserver();
|
|
78
80
|
this.setupResizeObserver();
|
|
79
81
|
}
|
|
82
|
+
|
|
83
|
+
// manage sticky-admin-acces by cookie
|
|
84
|
+
// this.hasStickyAdminAccess = getItem('sticky-admin-access') === 'true';
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
updated(changed) {
|
|
@@ -354,7 +359,7 @@ export default class IABookActions extends LitElement {
|
|
|
354
359
|
Please ${refreshButton} to try again or send us an email to
|
|
355
360
|
<a
|
|
356
361
|
href="mailto:info@archive.org?subject=Help: cannot access my borrowed book: ${this
|
|
357
|
-
|
|
362
|
+
.identifier}"
|
|
358
363
|
>info@archive.org</a
|
|
359
364
|
>`;
|
|
360
365
|
}
|
|
@@ -366,8 +371,18 @@ export default class IABookActions extends LitElement {
|
|
|
366
371
|
|
|
367
372
|
// eslint-disable-next-line class-methods-use-this
|
|
368
373
|
toggleStickyAdminAccess() {
|
|
369
|
-
|
|
370
|
-
|
|
374
|
+
this.hasStickyAdminAccess = !this.hasStickyAdminAccess;
|
|
375
|
+
|
|
376
|
+
// set in cookies
|
|
377
|
+
setItem('sticky-admin-access', this.hasStickyAdminAccess);
|
|
378
|
+
|
|
379
|
+
document.dispatchEvent(
|
|
380
|
+
new CustomEvent('stickyAdminAccessToggled', {
|
|
381
|
+
detail: {
|
|
382
|
+
hasStickyAdminAccess: this.hasStickyAdminAccess,
|
|
383
|
+
},
|
|
384
|
+
})
|
|
385
|
+
);
|
|
371
386
|
}
|
|
372
387
|
|
|
373
388
|
get iconClass() {
|
|
@@ -403,6 +418,7 @@ export default class IABookActions extends LitElement {
|
|
|
403
418
|
type="checkbox"
|
|
404
419
|
id="sticky-admin-access"
|
|
405
420
|
aria-label="Checkbox"
|
|
421
|
+
?checked=${this.hasStickyAdminAccess}
|
|
406
422
|
@click=${this.toggleStickyAdminAccess}
|
|
407
423
|
/>
|
|
408
424
|
<span>${this.primaryTitle}</span>
|