@salesforcedevs/dw-components 0.66.4 → 0.68.2-alpha.22
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/lwc.config.json +0 -1
- package/package.json +2 -3
- package/src/modules/dw/blogsGrid/blogsGrid.html +1 -1
- package/src/modules/dw/contentArchive/contentArchive.html +7 -5
- package/src/modules/dw/contentArchive/contentArchive.ts +110 -83
- package/src/modules/dw/contentArchive/contentArchive.types.ts +13 -9
- package/src/modules/dw/contentArchive/utils.ts +49 -18
- package/src/modules/dw/deSignupForm/deSignupForm.css +5 -0
- package/src/modules/dw/deSignupForm/deSignupForm.html +22 -4
- package/src/modules/dw/podcastsGrid/podcastsGrid.html +1 -1
- package/src/modules/dw/searchResults/coveo.css +0 -18989
- package/src/modules/dw/searchResults/searchResults.css +0 -387
- package/src/modules/dw/searchResults/searchResults.html +0 -104
- package/src/modules/dw/searchResults/searchResults.ts +0 -187
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dw-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.68.2-alpha.22+dc9e7409",
|
|
4
4
|
"description": "Lightning web components for https://developer.salesforce.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"classnames": "^2.2.6",
|
|
14
|
-
"coveo-search-ui": "^2.10082.5",
|
|
15
14
|
"lodash.clonedeep": "^4.5.0",
|
|
16
15
|
"lodash.orderby": "^4.6.0",
|
|
17
16
|
"lodash.uniqby": "^4.7.0",
|
|
@@ -23,5 +22,5 @@
|
|
|
23
22
|
"@types/lodash.orderby": "^4.6.7",
|
|
24
23
|
"@types/lodash.uniqby": "^4.7.7"
|
|
25
24
|
},
|
|
26
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "dc9e74091d9f224cc819c9171fe8fb152bfd6a41"
|
|
27
26
|
}
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
</button>
|
|
27
27
|
</div>
|
|
28
28
|
<dx-filter-menu
|
|
29
|
-
name="
|
|
29
|
+
name="content-type"
|
|
30
30
|
title={contentTypeTitle}
|
|
31
31
|
options={contentTypeList}
|
|
32
32
|
onchange={handleUpdateSiteFilter}
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
title={dateTitle}
|
|
37
37
|
options={dateList}
|
|
38
38
|
variant="nested"
|
|
39
|
+
filters-dates-loading={filtersDatesLoading}
|
|
39
40
|
onchange={handleFiltersEvent}
|
|
40
41
|
></dx-filter-menu>
|
|
41
42
|
<template if:false={hideBlogFilters}>
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
</button>
|
|
74
75
|
</div>
|
|
75
76
|
<dx-filter-menu
|
|
76
|
-
name="
|
|
77
|
+
name="contentType"
|
|
77
78
|
title={contentTypeTitle}
|
|
78
79
|
options={contentTypeList}
|
|
79
80
|
onchange={handleUpdateSiteFilter}
|
|
@@ -82,6 +83,7 @@
|
|
|
82
83
|
name="dates"
|
|
83
84
|
title={dateTitle}
|
|
84
85
|
options={dateList}
|
|
86
|
+
filters-dates-loading={filtersDatesLoading}
|
|
85
87
|
variant="nested"
|
|
86
88
|
onchange={handleFiltersEvent}
|
|
87
89
|
></dx-filter-menu>
|
|
@@ -156,17 +158,17 @@
|
|
|
156
158
|
</template>
|
|
157
159
|
</div>
|
|
158
160
|
<div class="filter-chips-container">
|
|
159
|
-
<template if:true={selectedFilterMenuData.
|
|
161
|
+
<template if:true={selectedFilterMenuData.contentType.length}>
|
|
160
162
|
<div class="chip-item-container">
|
|
161
163
|
<p class="chip-title">Type</p>
|
|
162
164
|
<template
|
|
163
|
-
for:each={selectedFilterMenuData.
|
|
165
|
+
for:each={selectedFilterMenuData.contentType}
|
|
164
166
|
for:item="postType"
|
|
165
167
|
>
|
|
166
168
|
<span class="chip-item" key={postType.name}>
|
|
167
169
|
{postType.name}
|
|
168
170
|
<dx-button
|
|
169
|
-
name="
|
|
171
|
+
name="contentType"
|
|
170
172
|
value={postType}
|
|
171
173
|
onclick={removeFilterItem}
|
|
172
174
|
variant="inline"
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { LightningElement } from "lwc";
|
|
2
2
|
import cx from "classnames";
|
|
3
|
-
import { getArchivePosts, getArchiveFilterList } from "./utils";
|
|
3
|
+
import { PER_PAGE_COUNT, getArchivePosts, getArchiveFilterList } from "./utils";
|
|
4
4
|
import { sortSplittedPostsByMonth } from "dxUtils/dates";
|
|
5
|
-
import { Filters } from "./contentArchive.types";
|
|
6
5
|
import { getUrlParamValue, setUrlParamValue } from "dxUtils/queryCoordinator";
|
|
6
|
+
import {
|
|
7
|
+
Filters,
|
|
8
|
+
FilterMenuData,
|
|
9
|
+
FilterMenuNames
|
|
10
|
+
} from "./contentArchive.types";
|
|
7
11
|
|
|
8
12
|
const MOBILE_MATCH = "767px";
|
|
9
13
|
|
|
10
|
-
|
|
14
|
+
enum FilterNames {
|
|
15
|
+
QUERY_CONTENT_FILTER = "contentType",
|
|
16
|
+
QUERY_AUTHOR_FILTER = "authors",
|
|
17
|
+
QUERY_DATES_FILTER = "dates",
|
|
18
|
+
QUERY_CATEGORIES_FILTER = "categories"
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
const PODCASTS = { id: 2, name: "Podcasts" };
|
|
12
22
|
const BLOGS = { id: 1, name: "Blogs" };
|
|
13
23
|
export default class ContentArchive extends LightningElement {
|
|
@@ -20,8 +30,9 @@ export default class ContentArchive extends LightningElement {
|
|
|
20
30
|
private totalPages: number = 1;
|
|
21
31
|
private loading: boolean = true;
|
|
22
32
|
private filtersLoading: boolean = true;
|
|
33
|
+
private filtersDatesLoading: boolean = false;
|
|
23
34
|
private modalOpen: boolean = false;
|
|
24
|
-
private cardType:
|
|
35
|
+
private cardType: "expanded" | "minimal" = "expanded";
|
|
25
36
|
|
|
26
37
|
private postsByDate: {} = {};
|
|
27
38
|
private dateList: any[] = [];
|
|
@@ -32,27 +43,26 @@ export default class ContentArchive extends LightningElement {
|
|
|
32
43
|
private mobileMatchMedia!: MediaQueryList;
|
|
33
44
|
|
|
34
45
|
private selectedFilterMenuData: Filters = {
|
|
35
|
-
|
|
46
|
+
contentType: [],
|
|
36
47
|
dates: [],
|
|
37
48
|
authors: [],
|
|
38
49
|
categories: []
|
|
39
50
|
};
|
|
51
|
+
|
|
40
52
|
private posts: any[] = [];
|
|
41
53
|
|
|
54
|
+
get isEmptyState() {
|
|
55
|
+
return this.totalResults === 0 && !this.loading;
|
|
56
|
+
}
|
|
57
|
+
|
|
42
58
|
get currentPageLength() {
|
|
43
59
|
if (this.loading) {
|
|
44
60
|
return "Loading Results...";
|
|
45
61
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (this.currentPage > 1) {
|
|
51
|
-
currentFirstResultNumber =
|
|
52
|
-
currentLastResultNumber - this.posts.length;
|
|
53
|
-
} else if (this.currentPage === 1 && !this.isEmptyState) {
|
|
54
|
-
currentFirstResultNumber = 1;
|
|
55
|
-
}
|
|
62
|
+
let currentFirstResultNumber = (this.currentPage - 1) * PER_PAGE_COUNT;
|
|
63
|
+
const currentLastResultNumber =
|
|
64
|
+
currentFirstResultNumber + this.posts.length;
|
|
65
|
+
currentFirstResultNumber += 1;
|
|
56
66
|
|
|
57
67
|
return `Showing ${currentFirstResultNumber} - ${currentLastResultNumber} of ${this.totalResults}`;
|
|
58
68
|
}
|
|
@@ -70,10 +80,6 @@ export default class ContentArchive extends LightningElement {
|
|
|
70
80
|
return this.totalResults ? `Archive Results ${pageInfo}` : "No results";
|
|
71
81
|
}
|
|
72
82
|
|
|
73
|
-
get isEmptyState() {
|
|
74
|
-
return this.totalResults === 0 && !this.loading;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
83
|
get spinnerSize() {
|
|
78
84
|
return this.isMobile ? "medium" : "large";
|
|
79
85
|
}
|
|
@@ -102,15 +108,15 @@ export default class ContentArchive extends LightningElement {
|
|
|
102
108
|
|
|
103
109
|
get hideBlogFilters() {
|
|
104
110
|
return (
|
|
105
|
-
this.selectedFilterMenuData.
|
|
106
|
-
this.selectedFilterMenuData.
|
|
111
|
+
this.selectedFilterMenuData.contentType.length === 1 &&
|
|
112
|
+
this.selectedFilterMenuData.contentType[0].id === 2
|
|
107
113
|
);
|
|
108
114
|
}
|
|
109
115
|
|
|
110
116
|
get contentTypeTitle() {
|
|
111
117
|
return `Content Type ${
|
|
112
|
-
this.selectedFilterMenuData.
|
|
113
|
-
? `(${this.selectedFilterMenuData.
|
|
118
|
+
this.selectedFilterMenuData.contentType.length > 0
|
|
119
|
+
? `(${this.selectedFilterMenuData.contentType.length})`
|
|
114
120
|
: ""
|
|
115
121
|
}`;
|
|
116
122
|
}
|
|
@@ -136,11 +142,17 @@ export default class ContentArchive extends LightningElement {
|
|
|
136
142
|
}`;
|
|
137
143
|
}
|
|
138
144
|
|
|
145
|
+
get selectedPostType() {
|
|
146
|
+
return this.selectedFilterMenuData.contentType.length === 1
|
|
147
|
+
? this.selectedFilterMenuData.contentType[0].name.toLowerCase()
|
|
148
|
+
: "all";
|
|
149
|
+
}
|
|
150
|
+
|
|
139
151
|
private filterSelectedDates(
|
|
140
|
-
currentDateList: Array<{ name: string }>,
|
|
141
152
|
selectedDate: string,
|
|
142
153
|
toRemove: boolean = false
|
|
143
154
|
) {
|
|
155
|
+
const currentDateList = this.selectedFilterMenuData.dates;
|
|
144
156
|
return currentDateList.filter((currentDateItem: { name: string }) => {
|
|
145
157
|
const year = currentDateItem.name.slice(-4);
|
|
146
158
|
|
|
@@ -169,9 +181,8 @@ export default class ContentArchive extends LightningElement {
|
|
|
169
181
|
selectedFilters = null;
|
|
170
182
|
}
|
|
171
183
|
|
|
172
|
-
setUrlParamValue(QUERY_SITE_FILTER, selectedFilters);
|
|
173
|
-
|
|
174
184
|
this.updateSelectedFilters(value, name, checked);
|
|
185
|
+
this.fetchArchiveFilterDateList();
|
|
175
186
|
}
|
|
176
187
|
|
|
177
188
|
private handleFiltersEvent(e: CustomEvent) {
|
|
@@ -181,8 +192,9 @@ export default class ContentArchive extends LightningElement {
|
|
|
181
192
|
|
|
182
193
|
private updateSelectedFilters(
|
|
183
194
|
value: any,
|
|
184
|
-
name:
|
|
185
|
-
checked: any
|
|
195
|
+
name: FilterMenuNames,
|
|
196
|
+
checked: any,
|
|
197
|
+
suppressFetch: boolean = false
|
|
186
198
|
) {
|
|
187
199
|
let copy = {
|
|
188
200
|
...this.selectedFilterMenuData
|
|
@@ -198,26 +210,25 @@ export default class ContentArchive extends LightningElement {
|
|
|
198
210
|
const regex = /^(\d{4})$/g;
|
|
199
211
|
|
|
200
212
|
if (regex.test(value.name) && copy[name].length > 0) {
|
|
201
|
-
copy[name] = this.filterSelectedDates(
|
|
213
|
+
copy[name] = this.filterSelectedDates(value.name);
|
|
202
214
|
} else if (regex.test(value.name.slice(-4))) {
|
|
203
|
-
copy[name] = this.filterSelectedDates(
|
|
204
|
-
copy[name],
|
|
205
|
-
value.name,
|
|
206
|
-
true
|
|
207
|
-
);
|
|
215
|
+
copy[name] = this.filterSelectedDates(value.name, true);
|
|
208
216
|
}
|
|
209
217
|
|
|
210
|
-
copy[name].
|
|
218
|
+
if (!copy[name].find((item) => item.name === value.name)) {
|
|
219
|
+
copy[name].push(value);
|
|
220
|
+
}
|
|
211
221
|
}
|
|
212
222
|
|
|
213
223
|
// Remove filters when only podcast is selected
|
|
214
224
|
if (
|
|
215
|
-
name ===
|
|
225
|
+
name === FilterNames.QUERY_CONTENT_FILTER &&
|
|
216
226
|
copy[name].length === 1 &&
|
|
217
227
|
!copy[name].some((item: { id: number }) => item.id === 1)
|
|
218
228
|
) {
|
|
229
|
+
setUrlParamValue({ QUERY_AUTHOR_FILTER: [] });
|
|
219
230
|
copy = {
|
|
220
|
-
|
|
231
|
+
contentType: [...copy.contentType],
|
|
221
232
|
categories: [...copy.categories],
|
|
222
233
|
dates: [...copy.dates],
|
|
223
234
|
authors: []
|
|
@@ -226,21 +237,26 @@ export default class ContentArchive extends LightningElement {
|
|
|
226
237
|
|
|
227
238
|
// Checkmark the blog type if value is a blog author
|
|
228
239
|
if (name === "authors" && checked) {
|
|
240
|
+
setUrlParamValue({ [FilterNames.QUERY_CONTENT_FILTER]: ["Blogs"] });
|
|
229
241
|
copy = {
|
|
230
|
-
|
|
242
|
+
contentType: [{ id: 1, name: "Blogs" }],
|
|
231
243
|
categories: [...copy.categories],
|
|
232
244
|
dates: [...copy.dates],
|
|
233
245
|
authors: [...copy.authors]
|
|
234
246
|
};
|
|
235
247
|
}
|
|
236
248
|
|
|
249
|
+
setUrlParamValue({ [name]: copy[name].map((a) => a.name) });
|
|
250
|
+
|
|
237
251
|
this.selectedFilterMenuData = copy;
|
|
238
252
|
this.currentPage = 1;
|
|
239
253
|
this.updateCheckedStatus();
|
|
240
|
-
|
|
254
|
+
if (!suppressFetch) {
|
|
255
|
+
this.fetchPostsByCardType();
|
|
256
|
+
}
|
|
241
257
|
}
|
|
242
258
|
|
|
243
|
-
private updateCheckedStatus() {
|
|
259
|
+
private async updateCheckedStatus() {
|
|
244
260
|
const filterMenuElements =
|
|
245
261
|
this.template.querySelectorAll("dx-filter-menu");
|
|
246
262
|
|
|
@@ -299,7 +315,7 @@ export default class ContentArchive extends LightningElement {
|
|
|
299
315
|
|
|
300
316
|
private handleFilterClear() {
|
|
301
317
|
this.selectedFilterMenuData = {
|
|
302
|
-
|
|
318
|
+
contentType: [],
|
|
303
319
|
dates: [],
|
|
304
320
|
authors: [],
|
|
305
321
|
categories: []
|
|
@@ -308,7 +324,12 @@ export default class ContentArchive extends LightningElement {
|
|
|
308
324
|
this.updateCheckedStatus();
|
|
309
325
|
this.fetchPostsByCardType();
|
|
310
326
|
|
|
311
|
-
setUrlParamValue(
|
|
327
|
+
setUrlParamValue({
|
|
328
|
+
[FilterNames.QUERY_CONTENT_FILTER]: [],
|
|
329
|
+
[FilterNames.QUERY_AUTHOR_FILTER]: [],
|
|
330
|
+
[FilterNames.QUERY_CATEGORIES_FILTER]: [],
|
|
331
|
+
[FilterNames.QUERY_DATES_FILTER]: []
|
|
332
|
+
});
|
|
312
333
|
}
|
|
313
334
|
|
|
314
335
|
private goToPage(e: CustomEvent) {
|
|
@@ -320,7 +341,7 @@ export default class ContentArchive extends LightningElement {
|
|
|
320
341
|
this.fetchPostsByCardType();
|
|
321
342
|
}
|
|
322
343
|
|
|
323
|
-
private fetchPostsByCardType() {
|
|
344
|
+
private async fetchPostsByCardType() {
|
|
324
345
|
if (this.cardType === "minimal") {
|
|
325
346
|
this.fetchPosts(20);
|
|
326
347
|
} else {
|
|
@@ -331,24 +352,39 @@ export default class ContentArchive extends LightningElement {
|
|
|
331
352
|
private async fetchArchiveFilterList() {
|
|
332
353
|
if (!this.dateList.length) {
|
|
333
354
|
this.filtersLoading = true;
|
|
334
|
-
|
|
355
|
+
|
|
356
|
+
const { dates, authors, categories } = await getArchiveFilterList(
|
|
357
|
+
this.selectedPostType
|
|
358
|
+
);
|
|
335
359
|
|
|
336
360
|
this.dateList = this.splitOptionsByDate(dates);
|
|
337
361
|
this.authorList = authors;
|
|
338
362
|
this.categoryList = categories;
|
|
339
363
|
this.filtersLoading = false;
|
|
364
|
+
|
|
365
|
+
requestAnimationFrame(() => this.updateAllFiltersFromUrl());
|
|
340
366
|
}
|
|
341
367
|
}
|
|
342
368
|
|
|
369
|
+
private async fetchArchiveFilterDateList() {
|
|
370
|
+
this.filtersDatesLoading = true;
|
|
371
|
+
|
|
372
|
+
const { dates } = await getArchiveFilterList(this.selectedPostType);
|
|
373
|
+
|
|
374
|
+
this.dateList = this.splitOptionsByDate(dates);
|
|
375
|
+
|
|
376
|
+
this.filtersDatesLoading = false;
|
|
377
|
+
}
|
|
378
|
+
|
|
343
379
|
private async fetchPosts(numberOfPosts: number) {
|
|
344
380
|
this.loading = true;
|
|
345
381
|
|
|
346
|
-
const { posts, totalResults, totalPages } = await getArchivePosts(
|
|
347
|
-
numberOfPosts,
|
|
348
|
-
this.currentPage,
|
|
349
|
-
this.cardType,
|
|
350
|
-
this.selectedFilterMenuData
|
|
351
|
-
);
|
|
382
|
+
const { posts, totalResults, totalPages } = await getArchivePosts({
|
|
383
|
+
count: numberOfPosts,
|
|
384
|
+
page: this.currentPage,
|
|
385
|
+
contentType: this.cardType,
|
|
386
|
+
filterMenuData: this.selectedFilterMenuData
|
|
387
|
+
});
|
|
352
388
|
|
|
353
389
|
this.posts = posts;
|
|
354
390
|
this.totalResults = totalResults;
|
|
@@ -420,53 +456,44 @@ export default class ContentArchive extends LightningElement {
|
|
|
420
456
|
requestAnimationFrame(() => this.updateCheckedStatus());
|
|
421
457
|
};
|
|
422
458
|
|
|
423
|
-
connectedCallback(): void {
|
|
459
|
+
async connectedCallback(): Promise<void> {
|
|
424
460
|
this.mobileMatchMedia = window.matchMedia(
|
|
425
461
|
`(max-width: ${MOBILE_MATCH})`
|
|
426
462
|
);
|
|
427
463
|
this.onMobileChange(this.mobileMatchMedia);
|
|
428
464
|
this.mobileMatchMedia.addEventListener("change", this.onMobileChange);
|
|
429
465
|
|
|
430
|
-
const presetFilters: Array<string> =
|
|
431
|
-
getUrlParamValue(QUERY_SITE_FILTER);
|
|
432
|
-
|
|
433
|
-
if (presetFilters.length === 1) {
|
|
434
|
-
if (presetFilters[0] === BLOGS.name) {
|
|
435
|
-
this.presetSiteFilter(BLOGS);
|
|
436
|
-
} else {
|
|
437
|
-
this.presetSiteFilter(PODCASTS);
|
|
438
|
-
}
|
|
439
|
-
} else if (presetFilters.length === 2) {
|
|
440
|
-
this.presetSiteFilter();
|
|
441
|
-
}
|
|
442
|
-
|
|
443
466
|
if (this.posts.length === 0) {
|
|
444
467
|
this.fetchArchiveFilterList();
|
|
445
468
|
this.fetchPostsByCardType();
|
|
446
469
|
}
|
|
447
470
|
}
|
|
448
471
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
this.
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
if (
|
|
466
|
-
|
|
472
|
+
private updateAllFiltersFromUrl() {
|
|
473
|
+
const filters: FilterMenuData = {
|
|
474
|
+
[FilterNames.QUERY_AUTHOR_FILTER]: this.authorList,
|
|
475
|
+
[FilterNames.QUERY_DATES_FILTER]: this.dateList,
|
|
476
|
+
[FilterNames.QUERY_CATEGORIES_FILTER]: this.categoryList,
|
|
477
|
+
[FilterNames.QUERY_CONTENT_FILTER]: this.contentTypeList
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
for (const [key, items] of Object.entries(filters)) {
|
|
481
|
+
const presetFilter: Array<string> = getUrlParamValue(key);
|
|
482
|
+
|
|
483
|
+
presetFilter.forEach((item) => {
|
|
484
|
+
const value = items.find(
|
|
485
|
+
(i) => i.name.toLowerCase() === item.toLowerCase()
|
|
486
|
+
);
|
|
487
|
+
|
|
488
|
+
if (value) {
|
|
489
|
+
this.updateSelectedFilters(
|
|
490
|
+
value,
|
|
491
|
+
key as FilterMenuNames,
|
|
492
|
+
true,
|
|
493
|
+
true
|
|
494
|
+
);
|
|
467
495
|
}
|
|
468
496
|
});
|
|
469
|
-
this.updateSelectedFilters(filter, "site", true);
|
|
470
497
|
}
|
|
471
498
|
}
|
|
472
499
|
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export interface Filters {
|
|
2
|
-
site: any[];
|
|
3
|
-
dates: any[];
|
|
4
|
-
authors: any[];
|
|
5
|
-
categories: any[];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
1
|
export type ArchivePostAuthor = {
|
|
9
2
|
id: number;
|
|
10
3
|
link: string;
|
|
@@ -73,14 +66,25 @@ export type ArchiveContent = {
|
|
|
73
66
|
totalPages: number;
|
|
74
67
|
};
|
|
75
68
|
|
|
69
|
+
export type FilterMenuNames =
|
|
70
|
+
| "contentType"
|
|
71
|
+
| "dates"
|
|
72
|
+
| "authors"
|
|
73
|
+
| "categories";
|
|
74
|
+
|
|
75
|
+
export type Filters = {
|
|
76
|
+
[key in FilterMenuNames]: any[];
|
|
77
|
+
};
|
|
78
|
+
|
|
76
79
|
export type FilterMenuItem = {
|
|
77
|
-
id: string;
|
|
80
|
+
id: string | number;
|
|
78
81
|
name: string;
|
|
79
82
|
shortName?: string;
|
|
83
|
+
checked?: boolean;
|
|
80
84
|
};
|
|
81
85
|
|
|
82
86
|
export type FilterMenuData = {
|
|
83
|
-
|
|
87
|
+
contentType: Array<FilterMenuItem>;
|
|
84
88
|
dates: Array<FilterMenuItem>;
|
|
85
89
|
categories: Array<FilterMenuItem>;
|
|
86
90
|
authors: Array<FilterMenuItem>;
|
|
@@ -2,23 +2,26 @@ import qs from "query-string";
|
|
|
2
2
|
import {
|
|
3
3
|
ArchivePost,
|
|
4
4
|
ArchivePostNormalized,
|
|
5
|
-
FilterMenuData
|
|
5
|
+
FilterMenuData,
|
|
6
|
+
FilterMenuItem
|
|
6
7
|
} from "./contentArchive.types";
|
|
7
8
|
import altData from "./altData.js";
|
|
8
9
|
|
|
9
|
-
let
|
|
10
|
+
let postsController: AbortController | null = null;
|
|
11
|
+
let filtersController: AbortController | null = null;
|
|
10
12
|
|
|
11
13
|
const ARCHIVE_BASE_URL = "https://developer.salesforce.com/blogs/wp-json/wp/v2";
|
|
12
14
|
const ARCHIVE_CONTENT_URL = `${ARCHIVE_BASE_URL}/latest-post-per-site`;
|
|
13
15
|
const ARCHIVE_FILTER_LIST_URL = `${ARCHIVE_BASE_URL}/archives-filters?order=DESC`;
|
|
16
|
+
export const PER_PAGE_COUNT = 10;
|
|
14
17
|
|
|
15
18
|
async function postsFetchHandler(url: string) {
|
|
16
|
-
if (
|
|
17
|
-
|
|
19
|
+
if (postsController) {
|
|
20
|
+
postsController.abort();
|
|
18
21
|
}
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
const { signal } =
|
|
23
|
+
postsController = new AbortController();
|
|
24
|
+
const { signal } = postsController;
|
|
22
25
|
|
|
23
26
|
const response = await fetch(url, { signal });
|
|
24
27
|
|
|
@@ -74,19 +77,35 @@ function normalizePosts(posts: Array<ArchivePost>, contentType: string) {
|
|
|
74
77
|
}));
|
|
75
78
|
}
|
|
76
79
|
|
|
77
|
-
export async function getArchivePosts(
|
|
78
|
-
count
|
|
79
|
-
page
|
|
80
|
-
contentType
|
|
81
|
-
filterMenuData
|
|
82
|
-
|
|
80
|
+
export async function getArchivePosts({
|
|
81
|
+
count = PER_PAGE_COUNT,
|
|
82
|
+
page = 1,
|
|
83
|
+
contentType = "minimal",
|
|
84
|
+
filterMenuData = {
|
|
85
|
+
contentType: [],
|
|
86
|
+
dates: [],
|
|
87
|
+
authors: [],
|
|
88
|
+
categories: []
|
|
89
|
+
}
|
|
90
|
+
}: {
|
|
91
|
+
count: number;
|
|
92
|
+
page: number;
|
|
93
|
+
contentType: "minimal" | "expanded";
|
|
94
|
+
filterMenuData: FilterMenuData;
|
|
95
|
+
}): Promise<ArchivePostNormalized> {
|
|
83
96
|
const filterQuery = {
|
|
84
|
-
site: filterMenuData.
|
|
85
|
-
|
|
97
|
+
site: filterMenuData.contentType.map(
|
|
98
|
+
(siteType: FilterMenuItem) => siteType.id
|
|
99
|
+
),
|
|
100
|
+
dates: filterMenuData.dates.map((date: FilterMenuItem) =>
|
|
86
101
|
date.shortName ? date.shortName : date.id
|
|
87
102
|
),
|
|
88
|
-
author: filterMenuData.authors.map(
|
|
89
|
-
|
|
103
|
+
author: filterMenuData.authors.map(
|
|
104
|
+
(author: FilterMenuItem) => author.id
|
|
105
|
+
),
|
|
106
|
+
category: filterMenuData.categories.map(
|
|
107
|
+
(category: FilterMenuItem) => category.id
|
|
108
|
+
)
|
|
90
109
|
};
|
|
91
110
|
|
|
92
111
|
const COMMON_FIELDS = [
|
|
@@ -150,8 +169,20 @@ export async function getArchivePosts(
|
|
|
150
169
|
};
|
|
151
170
|
}
|
|
152
171
|
|
|
153
|
-
export async function getArchiveFilterList() {
|
|
154
|
-
|
|
172
|
+
export async function getArchiveFilterList(postType: string = "all") {
|
|
173
|
+
if (filtersController) {
|
|
174
|
+
filtersController.abort();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
filtersController = new AbortController();
|
|
178
|
+
const { signal } = filtersController;
|
|
179
|
+
|
|
180
|
+
const response = await fetch(
|
|
181
|
+
`${ARCHIVE_FILTER_LIST_URL}${
|
|
182
|
+
postType !== "all" ? `&post-type=${postType}` : ""
|
|
183
|
+
}`,
|
|
184
|
+
{ signal }
|
|
185
|
+
);
|
|
155
186
|
|
|
156
187
|
if (response.ok) {
|
|
157
188
|
return response.json();
|
|
@@ -48,6 +48,10 @@ form > .full-name-field {
|
|
|
48
48
|
width: calc(50% - var(--dx-g-spacing-lg) / 2);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
.legal-terms {
|
|
52
|
+
margin-top: var(--dx-g-spacing-lg);
|
|
53
|
+
}
|
|
54
|
+
|
|
51
55
|
.submit-button {
|
|
52
56
|
width: 100%;
|
|
53
57
|
}
|
|
@@ -56,6 +60,7 @@ form > .full-name-field {
|
|
|
56
60
|
background-color: var(--dx-g-blue-vibrant-40);
|
|
57
61
|
border-color: var(--dx-g-blue-vibrant-40);
|
|
58
62
|
}
|
|
63
|
+
|
|
59
64
|
@media screen and (min-width: 641px) {
|
|
60
65
|
form > .full-name-field:first-of-type {
|
|
61
66
|
margin-right: var(--dx-g-spacing-lg);
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
missing-error-message="Create a user name"
|
|
68
68
|
error-message={usernameError}
|
|
69
69
|
format-error-message='Enter a unique username. Your username must be in the form of an email address, but does not have to be a real email address. We suggest "name@yourcompany." It must be unique and not associated with another Salesforce login credential.'
|
|
70
|
+
description-markup='Your username must be in the form of an email address (it does not have to be real). It must be unique and cannot be associated with another Salesforce login credential. <a href="/help" target="_blank">Read more about username recommendations.</a>'
|
|
70
71
|
label="Username"
|
|
71
72
|
name="username"
|
|
72
73
|
placeholder="Ex. name@yourcompany.com"
|
|
@@ -75,16 +76,33 @@
|
|
|
75
76
|
validity-on-blur={checkUsernameValidity}
|
|
76
77
|
onchange={handleUsernameChange}
|
|
77
78
|
></dx-input>
|
|
78
|
-
<dx-checkbox
|
|
79
|
+
<dx-checkbox
|
|
80
|
+
if:true={showMarketingField}
|
|
81
|
+
name="opt_in"
|
|
82
|
+
value="explicit"
|
|
83
|
+
>
|
|
79
84
|
<span lwc:dom="manual" class="marketing-terms"></span>
|
|
80
85
|
</dx-checkbox>
|
|
81
|
-
<dx-checkbox
|
|
86
|
+
<dx-checkbox
|
|
87
|
+
if:true={showLegalCheckbox}
|
|
88
|
+
required
|
|
89
|
+
name="eula"
|
|
90
|
+
value="accepted"
|
|
91
|
+
>
|
|
82
92
|
<span lwc:dom="manual" class="legal-terms"></span>
|
|
83
|
-
<span
|
|
93
|
+
<span
|
|
94
|
+
if:true={learnMore}
|
|
95
|
+
lwc:dom="manual"
|
|
96
|
+
class="learn-more"
|
|
97
|
+
></span>
|
|
84
98
|
</dx-checkbox>
|
|
85
99
|
<template if:false={showLegalCheckbox}>
|
|
86
100
|
<span lwc:dom="manual" class="legal-terms"></span>
|
|
87
|
-
<span
|
|
101
|
+
<span
|
|
102
|
+
if:true={learnMore}
|
|
103
|
+
lwc:dom="manual"
|
|
104
|
+
class="learn-more"
|
|
105
|
+
></span>
|
|
88
106
|
</template>
|
|
89
107
|
<dx-button
|
|
90
108
|
class="submit-button"
|