@internetarchive/ia-book-actions 0.0.6-3 → 0.0.6-4
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/demo/index.html
CHANGED
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
iaBookActions.userid = '';
|
|
97
97
|
iaBookActions.identifier = identifier;
|
|
98
98
|
iaBookActions.bookTitle = 'Contemporary Black biography. Volume 39 : profiles from the interContemporary Black biography. Volume 39';
|
|
99
|
-
iaBookActions.lendingStatus =
|
|
99
|
+
iaBookActions.lendingStatus = canBrowseAndBorrow;
|
|
100
100
|
iaBookActions.bwbPurchaseUrl = '';
|
|
101
101
|
iaBookActions.barType = '';
|
|
102
102
|
|
package/package.json
CHANGED
|
@@ -33,7 +33,7 @@ export default function ActionsHandlerService(options) {
|
|
|
33
33
|
})
|
|
34
34
|
.then(response => {
|
|
35
35
|
if (baseHost == '/demo/1' || baseHost == '/demo/') {
|
|
36
|
-
return {
|
|
36
|
+
return {"error":"Unexpected error.\nPlease email this link to openlibrary@archive.org with the subject: Unexpected error. Thank you. \nMessage:UNAVAILABLE"};
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// The response is a Response instance.
|
|
@@ -42,7 +42,7 @@ export default function ActionsHandlerService(options) {
|
|
|
42
42
|
})
|
|
43
43
|
.then(data => {
|
|
44
44
|
// `data` is the parsed version of the JSON returned from the above endpoint.
|
|
45
|
-
console.log(data
|
|
45
|
+
console.log('actual reponse for endpoint', data);
|
|
46
46
|
if (!data.error) {
|
|
47
47
|
option?.success(data);
|
|
48
48
|
} else {
|
|
@@ -88,25 +88,25 @@ export default class ActionsHandler extends LitElement {
|
|
|
88
88
|
|
|
89
89
|
handleBrowseIt() {
|
|
90
90
|
const context = 'browse_book';
|
|
91
|
-
this.
|
|
91
|
+
this.toggleActionBarState(context);
|
|
92
92
|
|
|
93
93
|
ActionsHandlerService({
|
|
94
94
|
action: context,
|
|
95
95
|
identifier: this.identifier,
|
|
96
96
|
success: () => {
|
|
97
|
-
|
|
97
|
+
this.handleReadItNow();
|
|
98
98
|
},
|
|
99
99
|
error: data => {
|
|
100
100
|
console.log(data);
|
|
101
101
|
alert(data.error);
|
|
102
|
-
this.
|
|
102
|
+
this.toggleActionBarState(context, data);
|
|
103
103
|
},
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
handleReturnIt() {
|
|
108
108
|
const context = 'return_loan';
|
|
109
|
-
this.
|
|
109
|
+
this.toggleActionBarState(context);
|
|
110
110
|
|
|
111
111
|
ActionsHandlerService({
|
|
112
112
|
action: context,
|
|
@@ -118,14 +118,14 @@ export default class ActionsHandler extends LitElement {
|
|
|
118
118
|
error: data => {
|
|
119
119
|
console.log(data);
|
|
120
120
|
alert(data.error);
|
|
121
|
-
this.
|
|
121
|
+
this.toggleActionBarState(context);
|
|
122
122
|
},
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
handleBorrowIt() {
|
|
127
127
|
const context = 'borrow_book';
|
|
128
|
-
this.
|
|
128
|
+
this.toggleActionBarState(context);
|
|
129
129
|
|
|
130
130
|
ActionsHandlerService({
|
|
131
131
|
action: context,
|
|
@@ -136,14 +136,14 @@ export default class ActionsHandler extends LitElement {
|
|
|
136
136
|
error: data => {
|
|
137
137
|
console.log(data);
|
|
138
138
|
alert(data.error);
|
|
139
|
-
this.
|
|
139
|
+
this.toggleActionBarState(context, data);
|
|
140
140
|
},
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
handleReserveIt() {
|
|
145
145
|
const context = 'join_waitlist';
|
|
146
|
-
this.
|
|
146
|
+
this.toggleActionBarState(context);
|
|
147
147
|
|
|
148
148
|
ActionsHandlerService({
|
|
149
149
|
action: context,
|
|
@@ -154,14 +154,14 @@ export default class ActionsHandler extends LitElement {
|
|
|
154
154
|
error: data => {
|
|
155
155
|
console.log(data);
|
|
156
156
|
alert(data.error);
|
|
157
|
-
this.
|
|
157
|
+
this.toggleActionBarState(context);
|
|
158
158
|
},
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
handleRemoveFromWaitingList() {
|
|
163
163
|
const context = 'leave_waitlist';
|
|
164
|
-
this.
|
|
164
|
+
this.toggleActionBarState(context);
|
|
165
165
|
|
|
166
166
|
ActionsHandlerService({
|
|
167
167
|
action: context,
|
|
@@ -172,7 +172,7 @@ export default class ActionsHandler extends LitElement {
|
|
|
172
172
|
error: data => {
|
|
173
173
|
console.log(data);
|
|
174
174
|
alert(data.error);
|
|
175
|
-
this.
|
|
175
|
+
this.toggleActionBarState(context);
|
|
176
176
|
},
|
|
177
177
|
});
|
|
178
178
|
}
|
|
@@ -227,10 +227,10 @@ export default class ActionsHandler extends LitElement {
|
|
|
227
227
|
document.cookie = cookie;
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
|
|
230
|
+
toggleActionBarState(context, data = {}) {
|
|
231
231
|
this.dispatchEvent(
|
|
232
|
-
new CustomEvent('toggle-
|
|
233
|
-
detail: context,
|
|
232
|
+
new CustomEvent('toggle-action-bar-state', {
|
|
233
|
+
detail: { context, data }
|
|
234
234
|
})
|
|
235
235
|
);
|
|
236
236
|
}
|
package/src/ia-book-actions.js
CHANGED
|
@@ -175,20 +175,23 @@ export default class IABookActions extends LitElement {
|
|
|
175
175
|
.width=${this.width}
|
|
176
176
|
.hasAdminAccess=${this.hasAdminAccess}
|
|
177
177
|
.disabled=${this.disable}
|
|
178
|
-
@toggle-
|
|
178
|
+
@toggle-action-bar-state=${this.toggleActionBarState}
|
|
179
179
|
>
|
|
180
180
|
</collapsible-action-group>
|
|
181
181
|
${this.textGroupTemplate} ${this.infoIconTemplate}
|
|
182
182
|
`;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
|
|
185
|
+
toggleActionBarState(e) {
|
|
186
|
+
console.log(e)
|
|
187
|
+
|
|
188
|
+
// update action bar states is book is not available to browse or borrow.
|
|
189
|
+
if (e?.detail?.data?.error) {
|
|
190
|
+
const errorMsg = e.detail.data.error;
|
|
191
|
+
if (errorMsg.match(/(^|\W)UNAVAILABLE($|\W)/)) {
|
|
192
|
+
const currStatus = { ...this.lendingStatus, available_to_browse: false };
|
|
193
|
+
this.lendingStatus = currStatus;
|
|
194
|
+
}
|
|
192
195
|
}
|
|
193
196
|
|
|
194
197
|
this.disable = !this.disable;
|