@financial-times/n-myft-ui 28.3.0 → 28.3.2
Sign up to get free protection for your applications and to get access to all the features.
package/myft/ui/lists.js
CHANGED
@@ -60,6 +60,9 @@ function updateAfterAddToList (listId, contentId, wasAdded) {
|
|
60
60
|
action: 'copy-success',
|
61
61
|
article_id: contentId,
|
62
62
|
list_id: listId,
|
63
|
+
content: {
|
64
|
+
uuid: contentId
|
65
|
+
},
|
63
66
|
teamName: 'customer-products-us-growth',
|
64
67
|
amplitudeExploratory: true
|
65
68
|
},
|
@@ -85,7 +88,7 @@ function setUpSaveToExistingListListeners (overlay, contentId) {
|
|
85
88
|
const listId = listSelect.options[listSelect.selectedIndex].value;
|
86
89
|
myFtClient.add('list', listId, 'contained', 'content', contentId, { token: csrfToken })
|
87
90
|
.then(detail => {
|
88
|
-
updateAfterAddToList(detail.actorId, detail.
|
91
|
+
updateAfterAddToList(detail.actorId, detail.subject, !!detail.results);
|
89
92
|
overlay.close();
|
90
93
|
});
|
91
94
|
});
|
@@ -252,6 +255,9 @@ function handleRemoveToggleSubmit (event) {
|
|
252
255
|
action: action === 'add' ? 'add-success' : 'remove-success',
|
253
256
|
article_id: contentId,
|
254
257
|
list_id: listId,
|
258
|
+
content: {
|
259
|
+
uuid: contentId
|
260
|
+
},
|
255
261
|
teamName: 'customer-products-us-growth',
|
256
262
|
amplitudeExploratory: true
|
257
263
|
},
|
@@ -21,10 +21,10 @@ export default async function openSaveArticleToListVariant (contentId, options =
|
|
21
21
|
return restoreContent();
|
22
22
|
}
|
23
23
|
|
24
|
-
myFtClient.add('user', null, 'created', 'list', uuid(), { name: newList.name, token: csrfToken })
|
24
|
+
myFtClient.add('user', null, 'created', 'list', uuid(), { name: newList.name, token: csrfToken, isPublic: newList.isPublic })
|
25
25
|
.then(detail => {
|
26
26
|
myFtClient.add('list', detail.subject, 'contained', 'content', contentId, { token: csrfToken }).then((data) => {
|
27
|
-
const createdList = { name: newList.name, uuid: data.actorId, checked: true,
|
27
|
+
const createdList = { name: newList.name, uuid: data.actorId, checked: true, isPublic: !!newList.isPublic };
|
28
28
|
lists.unshift(createdList);
|
29
29
|
const announceListContainer = document.querySelector('.myft-ui-create-list-variant-announcement');
|
30
30
|
announceListContainer.textContent = `${newList.name} created`;
|
@@ -153,44 +153,6 @@ export default async function openSaveArticleToListVariant (contentId, options =
|
|
153
153
|
});
|
154
154
|
}
|
155
155
|
|
156
|
-
function showMessageOverlay () {
|
157
|
-
function onContinue () {
|
158
|
-
messageOverlay.destroy();
|
159
|
-
createListOverlay.show();
|
160
|
-
triggerAcknowledgeMessageEvent();
|
161
|
-
}
|
162
|
-
|
163
|
-
const messageElement = MessageElement(onContinue);
|
164
|
-
|
165
|
-
const messageOverlay = new Overlay('myft-ui-create-list-variant-message', {
|
166
|
-
html: messageElement,
|
167
|
-
modal: false,
|
168
|
-
parentnode: isMobile() ? '.o-share--horizontal' : '.o-share--vertical',
|
169
|
-
class: 'myft-ui-create-list-variant-message',
|
170
|
-
});
|
171
|
-
|
172
|
-
const scrollHandler = getScrollHandler(messageOverlay.wrapper);
|
173
|
-
const resizeHandler = getResizeHandler(messageOverlay.wrapper);
|
174
|
-
|
175
|
-
messageOverlay.open();
|
176
|
-
|
177
|
-
messageOverlay.wrapper.addEventListener('oOverlay.ready', (data) => {
|
178
|
-
positionOverlay(data.currentTarget);
|
179
|
-
|
180
|
-
window.addEventListener('scroll', scrollHandler);
|
181
|
-
|
182
|
-
window.addEventListener('oViewport.resize', resizeHandler);
|
183
|
-
});
|
184
|
-
|
185
|
-
messageOverlay.wrapper.addEventListener('oOverlay.destroy', () => {
|
186
|
-
window.removeEventListener('scroll', scrollHandler);
|
187
|
-
|
188
|
-
window.removeEventListener('oViewport.resize', resizeHandler);
|
189
|
-
});
|
190
|
-
|
191
|
-
return messageOverlay;
|
192
|
-
}
|
193
|
-
|
194
156
|
function getScrollHandler (target) {
|
195
157
|
return realignOverlay(window.scrollY, target);
|
196
158
|
}
|
@@ -214,7 +176,7 @@ function FormElement (createList, showPublicToggle, attachDescription, onListCre
|
|
214
176
|
`<div class="myft-ui-create-list-variant-form-public o-forms-field" role="group">
|
215
177
|
<span class="o-forms-input o-forms-input--toggle">
|
216
178
|
<label>
|
217
|
-
<input class="myft-ui-create-list-variant-form-toggle" type="checkbox" name="is-
|
179
|
+
<input class="myft-ui-create-list-variant-form-toggle" type="checkbox" name="is-public" value="public" checked data-trackable="private-link" text="private">
|
218
180
|
<span class="myft-ui-create-list-variant-form-toggle-label o-forms-input__label">
|
219
181
|
<span class="o-forms-input__label__main">
|
220
182
|
Public
|
@@ -246,23 +208,17 @@ function FormElement (createList, showPublicToggle, attachDescription, onListCre
|
|
246
208
|
event.preventDefault();
|
247
209
|
event.stopPropagation();
|
248
210
|
const inputListName = formElement.querySelector('input[name="list-name"]');
|
249
|
-
const
|
211
|
+
const inputIsPublic = formElement.querySelector('input[name="is-public"]');
|
250
212
|
|
251
213
|
const newList = {
|
252
214
|
name: inputListName.value,
|
253
|
-
|
215
|
+
isPublic: inputIsPublic ? inputIsPublic.checked : false
|
254
216
|
};
|
255
217
|
|
256
218
|
createList(newList, ((contentId, createdList) => {
|
257
219
|
triggerCreateListEvent(contentId, createdList.uuid);
|
258
220
|
triggerAddToListEvent(contentId, createdList.uuid);
|
259
221
|
positionOverlay(createListOverlay.wrapper);
|
260
|
-
|
261
|
-
if (createdList.isShareable) {
|
262
|
-
createListOverlay.close();
|
263
|
-
showMessageOverlay();
|
264
|
-
}
|
265
|
-
|
266
222
|
onListCreated();
|
267
223
|
}));
|
268
224
|
formElement.remove();
|
@@ -294,7 +250,7 @@ function addPublicToggleListener (formElement) {
|
|
294
250
|
triggerPublicToggleEvent(event.target.checked);
|
295
251
|
}
|
296
252
|
|
297
|
-
formElement.querySelector('input[name="is-
|
253
|
+
formElement.querySelector('input[name="is-public"]').addEventListener('click', onPublicToggleClick);
|
298
254
|
}
|
299
255
|
|
300
256
|
function ContentElement (hasDescription, onClick) {
|
@@ -420,28 +376,6 @@ function ListCheckboxElement (addToList, removeFromList) {
|
|
420
376
|
};
|
421
377
|
}
|
422
378
|
|
423
|
-
function MessageElement (onContinue) {
|
424
|
-
const message = `
|
425
|
-
<div class="myft-ui-create-list-variant-message-content" >
|
426
|
-
<div class="myft-ui-create-list-variant-message-text" aria-live="polite">
|
427
|
-
<h3>Thank you for your interest in making a public list</h3>
|
428
|
-
<p>We're currently testing this feature. For now, your list remains private and isn't visible to others.</p>
|
429
|
-
</div>
|
430
|
-
<div class="myft-ui-create-list-variant-message-buttons">
|
431
|
-
<button class="o-buttons o-buttons--big o-buttons--secondary" data-trackable="continue-link" text="continue">
|
432
|
-
Continue
|
433
|
-
</button>
|
434
|
-
</div>
|
435
|
-
</div>
|
436
|
-
`;
|
437
|
-
|
438
|
-
const messageElement = stringToHTMLElement(message);
|
439
|
-
|
440
|
-
messageElement.querySelector('button').addEventListener('click', onContinue);
|
441
|
-
|
442
|
-
return messageElement;
|
443
|
-
}
|
444
|
-
|
445
379
|
function realignOverlay (originalScrollPosition, target) {
|
446
380
|
return function () {
|
447
381
|
const currentScrollPosition = window.scrollY;
|
@@ -495,7 +429,7 @@ async function getLists (contentId) {
|
|
495
429
|
return myFtClient.getListsContent()
|
496
430
|
.then(results => results.items.map(list => {
|
497
431
|
const isChecked = Array.isArray(list.content) && list.content.some(content => content.uuid === contentId);
|
498
|
-
return { name: list.name, uuid: list.uuid, checked: isChecked, content: list.content,
|
432
|
+
return { name: list.name, uuid: list.uuid, checked: isChecked, content: list.content, isPublic: list.isPublic };
|
499
433
|
}));
|
500
434
|
}
|
501
435
|
|
@@ -569,20 +503,6 @@ function triggerAddToNewListEvent () {
|
|
569
503
|
}));
|
570
504
|
}
|
571
505
|
|
572
|
-
// Temporary event on the public toggle feature.
|
573
|
-
// These will be used to build a sanity check dashboard, and will be removed after we get clean-up this test.
|
574
|
-
function triggerAcknowledgeMessageEvent () {
|
575
|
-
document.body.dispatchEvent(new CustomEvent('oTracking.event', {
|
576
|
-
detail: {
|
577
|
-
category: 'publicToggle',
|
578
|
-
action: 'acknowledgeMessage',
|
579
|
-
teamName: 'customer-products-us-growth',
|
580
|
-
amplitudeExploratory: true
|
581
|
-
},
|
582
|
-
bubbles: true
|
583
|
-
}));
|
584
|
-
}
|
585
|
-
|
586
506
|
// Temporary event on the public toggle feature.
|
587
507
|
// These will be used to build a sanity check dashboard, and will be removed after we get clean-up this test.
|
588
508
|
function triggerCancelEvent () {
|