@internetarchive/ia-book-actions 0.1.11-b6 → 0.1.11-b7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ export default async function ActionsHandlerService(options) {
|
|
|
21
21
|
const tokenError = 'loan token not found. please try again later.';
|
|
22
22
|
const borrowError =
|
|
23
23
|
'This book is not available to borrow at this time. Please try again later.';
|
|
24
|
-
const erroneousActions = ['browse_book', 'borrow_book', 'create_token'];
|
|
24
|
+
const erroneousActions = ['browse_book', 'borrow_book', 'create_token', 'renew_loan'];
|
|
25
25
|
const shouldReturnError =
|
|
26
26
|
location?.href?.indexOf('?error=true') !== -1 &&
|
|
27
27
|
location?.hostname !== 'archive.org';
|
|
@@ -142,7 +142,13 @@ export default class ActionsHandler extends LitElement {
|
|
|
142
142
|
action,
|
|
143
143
|
identifier: this.identifier,
|
|
144
144
|
success: data => {
|
|
145
|
-
console.log(
|
|
145
|
+
console.log(
|
|
146
|
+
'RENEW_LOAN --- ',
|
|
147
|
+
data,
|
|
148
|
+
action,
|
|
149
|
+
data.loan,
|
|
150
|
+
this.identifier
|
|
151
|
+
);
|
|
146
152
|
if (data?.success === true && data?.loan?.renewal === true) {
|
|
147
153
|
this.setBrowseTimeSession();
|
|
148
154
|
this.dispatchEvent(
|
package/src/ia-book-actions.js
CHANGED
|
@@ -308,19 +308,18 @@ export default class IABookActions extends LitElement {
|
|
|
308
308
|
this.loanRenewResult = this.loanRenewHelper.result;
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
-
/**
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (!this.modal) this.modal = document.createElement('modal-manager');
|
|
311
|
+
/** @returns HTMLElement */
|
|
312
|
+
get modal() {
|
|
313
|
+
let modalOnDom = document.querySelector('modal-manager');
|
|
314
|
+
|
|
315
|
+
if (!modalOnDom) {
|
|
316
|
+
const newModal = document.createElement('modal-manager');
|
|
317
|
+
document.body.appendChild(newModal);
|
|
318
|
+
modalOnDom = newModal;
|
|
320
319
|
}
|
|
321
320
|
|
|
322
321
|
this.modal.id = 'action-bar-modal';
|
|
323
|
-
|
|
322
|
+
return modalOnDom;
|
|
324
323
|
}
|
|
325
324
|
|
|
326
325
|
/**
|
|
@@ -328,7 +327,6 @@ export default class IABookActions extends LitElement {
|
|
|
328
327
|
*/
|
|
329
328
|
async showWarningModal() {
|
|
330
329
|
console.log('****** showWarningModal ******');
|
|
331
|
-
await this.useModalManager();
|
|
332
330
|
|
|
333
331
|
// if secondsLeft < 60, consider it 1 minute
|
|
334
332
|
let { secondsLeft } = this.loanRenewResult;
|
|
@@ -338,16 +336,17 @@ export default class IABookActions extends LitElement {
|
|
|
338
336
|
secondsLeft = secondsLeft > 60 ? secondsLeft : 60;
|
|
339
337
|
}
|
|
340
338
|
|
|
341
|
-
const config = new ModalConfig(
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
339
|
+
const config = new ModalConfig({
|
|
340
|
+
headline: 'Are you still here?',
|
|
341
|
+
showCloseButton: false,
|
|
342
|
+
closeOnBackdropClick: false,
|
|
343
|
+
message: this.loanRenewHelper?.getMessageTexts(
|
|
344
|
+
this.loanRenewResult.texts,
|
|
345
|
+
secondsLeft
|
|
346
|
+
)
|
|
347
|
+
});
|
|
349
348
|
|
|
350
|
-
const
|
|
349
|
+
const customModalContent = html`<br />
|
|
351
350
|
<div id="custom-buttons" style="display:flex;justify-content:center;">
|
|
352
351
|
<button
|
|
353
352
|
style="${modalButtonStyle.iaButton} ${modalButtonStyle.renew}"
|
|
@@ -367,7 +366,7 @@ export default class IABookActions extends LitElement {
|
|
|
367
366
|
</button>
|
|
368
367
|
</div> `;
|
|
369
368
|
|
|
370
|
-
this.modal?.showModal({ config, customModalContent
|
|
369
|
+
this.modal?.showModal({ config, customModalContent });
|
|
371
370
|
}
|
|
372
371
|
|
|
373
372
|
async patronWantsToRenewBook(event) {
|
|
@@ -403,15 +402,15 @@ export default class IABookActions extends LitElement {
|
|
|
403
402
|
*/
|
|
404
403
|
async showExpiredModal() {
|
|
405
404
|
console.log('showExpiredModal()');
|
|
406
|
-
await this.useModalManager();
|
|
407
405
|
|
|
408
|
-
const config = new ModalConfig(
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
406
|
+
const config = new ModalConfig({
|
|
407
|
+
headline: '',
|
|
408
|
+
showCloseButton: false,
|
|
409
|
+
closeOnBackdropClick: false,
|
|
410
|
+
message: 'This book has been returned due to inactivity.'
|
|
411
|
+
});
|
|
413
412
|
|
|
414
|
-
const
|
|
413
|
+
const customModalContent = html`<br />
|
|
415
414
|
<div style="text-align: center">
|
|
416
415
|
<button
|
|
417
416
|
style="${modalButtonStyle.iaButton} ${modalButtonStyle.renew}"
|
|
@@ -423,7 +422,7 @@ export default class IABookActions extends LitElement {
|
|
|
423
422
|
</button>
|
|
424
423
|
</div> `;
|
|
425
424
|
|
|
426
|
-
this.modal?.showModal({ config, customModalContent
|
|
425
|
+
this.modal?.showModal({ config, customModalContent });
|
|
427
426
|
}
|
|
428
427
|
|
|
429
428
|
/**
|
|
@@ -669,6 +668,7 @@ export default class IABookActions extends LitElement {
|
|
|
669
668
|
await this.resetTimerCountState();
|
|
670
669
|
|
|
671
670
|
// close the modal
|
|
671
|
+
this.modal.removeAttribute('id');
|
|
672
672
|
this.modal?.remove();
|
|
673
673
|
this.modal?.showModal({ config: {}, customModalContent: `` });
|
|
674
674
|
|
|
@@ -908,7 +908,6 @@ export default class IABookActions extends LitElement {
|
|
|
908
908
|
|
|
909
909
|
/* show error message if something went wrong */
|
|
910
910
|
async showErrorModal(errorMsg, action) {
|
|
911
|
-
await this.useModalManager();
|
|
912
911
|
|
|
913
912
|
const modalConfig = new ModalConfig({
|
|
914
913
|
title: 'Lending error',
|