@salesforcedevs/dw-components 1.3.323 → 1.3.324-alpha

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dw-components",
3
- "version": "1.3.323",
3
+ "version": "1.3.324-alpha",
4
4
  "description": "Lightning web components for https://developer.salesforce.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -1,3 +1,7 @@
1
+ @import "dxHelpers/reset";
2
+ @import "dxHelpers/text";
3
+ @import "dxHelpers/card";
4
+
1
5
  dx-section:first-of-type {
2
6
  --dx-c-section-padding-bottom: 0;
3
7
  }
@@ -6,16 +10,83 @@ dx-section {
6
10
  --dx-c-section-position: revert;
7
11
  }
8
12
 
13
+ .featured-app-container {
14
+ padding-right: 20px;
15
+ display: flex;
16
+ flex-flow: row wrap-reverse;
17
+ justify-content: space-between;
18
+ align-items: center;
19
+ }
20
+
21
+ .featured-app-container h4 {
22
+ color: var(--dx-g-text-heading-color);
23
+ font-weight: 800;
24
+ }
25
+
26
+ .dx-text-display-5 {
27
+ color: var(--dx-g-text-heading-color);
28
+ transition: var(--dx-g-transition-hue-1x);
29
+ line-height: var(--dx-c-card-title-line-height);
30
+ letter-spacing: var(--dx-c-card-title-letter-spacing);
31
+ word-break: var(--dx-c-card-title-word-break, break-word);
32
+ hyphens: auto;
33
+ }
34
+
35
+ .featured-app-text {
36
+ display: flex;
37
+ flex-direction: column;
38
+ width: 50%;
39
+ align-self: flex-end;
40
+ padding-right: 20px;
41
+ }
42
+
43
+ .featured-app-container img {
44
+ width: 50%;
45
+ height: 80%;
46
+ border-radius: 20px;
47
+ box-shadow: var(--dx-g-box-shadow-lg);
48
+ }
49
+
50
+ @media screen and (max-width: 639px) {
51
+ .featured-app-container {
52
+ flex-direction: column-reverse;
53
+ }
54
+
55
+ .featured-app-container h4 {
56
+ margin-top: 1em;
57
+ }
58
+
59
+ .featured-app-container img {
60
+ width: 100%;
61
+ height: auto;
62
+ }
63
+
64
+ .featured-app-text {
65
+ display: flex;
66
+ flex-direction: column;
67
+ width: 100%;
68
+ }
69
+ }
70
+
9
71
  .badge-link-container {
10
72
  padding-top: var(--dx-g-spacing-md);
73
+ width: 100%;
11
74
  }
12
75
 
13
76
  .badge-container {
77
+ display: flex;
78
+ flex-flow: row wrap;
79
+ width: 100%;
80
+ gap: 1em;
14
81
  padding-top: 0;
15
82
  }
16
83
 
17
84
  .external-link-container {
18
85
  padding-top: var(--dx-g-spacing-md);
86
+ display: flex;
87
+ flex-flow: row wrap;
88
+ margin-top: 4em;
89
+ gap: 1em;
19
90
  }
20
91
 
21
92
  .item-container {
@@ -99,6 +170,8 @@ dx-section {
99
170
  @media screen and (max-width: 767px) {
100
171
  .badge-link-container {
101
172
  display: flex;
173
+ flex-direction: column;
174
+ gap: 1.5em;
102
175
  }
103
176
 
104
177
  .docs-action-bar {
@@ -123,7 +196,6 @@ dx-section {
123
196
  }
124
197
 
125
198
  .external-link-container {
126
- padding: 0 0 0 8px;
127
199
  margin-top: -4px;
128
200
  }
129
201
  }
@@ -1,142 +1,100 @@
1
1
  <template>
2
- <dx-section>
3
- <dx-feature
4
- header={featuredCodeSample.title}
5
- button-href={featuredCodeSample.href}
6
- button-label="Explore on GitHub"
7
- image-src={featuredCodeSample.imgSrc}
8
- variant="display"
9
- label="Featured Demo"
10
- is-external-link
11
- class="code-samples-feature"
12
- >
13
- {featuredCodeSample.body}
14
- </dx-feature>
15
- </dx-section>
16
-
17
- <dx-section header="Browse Demos">
18
- <div class="docs-action-bar">
19
- <div class="records-container">
20
- <span if:true={endingRecord}>
21
- Showing { startingRecord } to { endingRecord } of {
22
- filteredSamples.length }
2
+ <dx-section
3
+ class="feature-gradient"
4
+ background-color="linear-gradient(var(--dx-g-indigo-vibrant-90), white)"
5
+ >
6
+ <div class="featured-app-container">
7
+ <div class="featured-app-text">
8
+ <h4>Featured App</h4>
9
+ <h2 class="dx-text-display-5">{featuredCodeSample.title}</h2>
10
+ <span class="feature-card-content dx-text-body-2">
11
+ {featuredCodeSample.body}
23
12
  </span>
13
+ <div class="badge-link-container">
14
+ <div class="badge-container">
15
+ <dx-metadata-badge
16
+ for:each={featuredCodeSample.tags}
17
+ for:item="tag"
18
+ key={tag}
19
+ value={tag}
20
+ ></dx-metadata-badge>
21
+ </div>
22
+
23
+ <div class="external-link-container">
24
+ <dx-button
25
+ target={target}
26
+ icon-symbol="new_window"
27
+ variant="primary"
28
+ size="large"
29
+ href={featuredCodeSample.githubLink}
30
+ onclick={handleReadItClick}
31
+ >
32
+ Explore on GitHub
33
+ </dx-button>
34
+ <dx-button
35
+ target={target}
36
+ variant="secondary"
37
+ size="large"
38
+ href={featuredCodeSample.trailheadLink}
39
+ onclick={handleReadItClick}
40
+ >
41
+ Learn on Trailhead
42
+ </dx-button>
43
+ </div>
44
+ </div>
24
45
  </div>
25
- <div class="filters-container">
26
- <dx-popover if:true={showSourcesFilter} width="max-content">
27
- <dx-button
28
- class="filter-button"
29
- variant="tertiary"
30
- icon-symbol="chevrondown"
31
- slot="control"
32
- >
33
- Source
34
- </dx-button>
35
- <dx-checkbox-group
36
- legend="Source"
37
- options={sources}
38
- slot="content"
39
- onchange={handleSourceFilterChange}
40
- value={selectedSourceFilter}
41
- class="filter-checkbox-group"
42
- ></dx-checkbox-group>
43
- </dx-popover>
44
- <dx-popover width="max-content">
45
- <dx-button
46
- class="filter-button"
47
- variant="tertiary"
48
- icon-symbol="chevrondown"
49
- slot="control"
50
- >
51
- Type
52
- </dx-button>
53
- <dx-checkbox-group
54
- legend="Type"
55
- options={types}
56
- slot="content"
57
- onchange={handleTypeFilterChange}
58
- value={selectedTypeFilter}
59
- class="filter-checkbox-group"
60
- ></dx-checkbox-group>
61
- </dx-popover>
62
- <dx-popover width="max-content">
63
- <dx-button
64
- class="filter-button"
65
- variant="tertiary"
66
- icon-symbol="chevrondown"
67
- slot="control"
68
- >
69
- Products
70
- </dx-button>
71
- <dx-checkbox-group
72
- legend="Products"
73
- options={products}
74
- slot="content"
75
- onchange={handleProductFilterChange}
76
- value={selectedProductFilter}
77
- class="filter-checkbox-group"
78
- ></dx-checkbox-group>
79
- </dx-popover>
80
- </div>
81
- <dx-input
82
- size="small"
83
- placeholder="Search..."
84
- icon-symbol="search"
85
- shortcut-key="j"
86
- class="docs-search-input"
87
- onchange={handleSearchChange}
88
- value={searchTerm}
89
- ></dx-input>
46
+ <img
47
+ class="image dx-card-base_image featured-app-image"
48
+ src={featuredCodeSample.img}
49
+ alt={featuredCodeSample.title}
50
+ />
90
51
  </div>
52
+ </dx-section>
53
+ <dx-section title="Explore the Apps">
91
54
  <dx-grid columns={tileColumns} if:false={showEmptyState}>
92
55
  <dx-card-docs
93
- class="content-card"
94
- for:each={currentPageSamples}
56
+ for:each={samples}
95
57
  for:item="item"
96
58
  for:index="i"
97
59
  key={item.id}
98
60
  body={item.body}
99
- label={item.type}
100
61
  header={item.title}
101
- href={item.href}
62
+ href={item.githubLink}
63
+ img-src={item.img}
64
+ show-mobile-img
102
65
  >
103
66
  <div class="badge-link-container">
104
67
  <div class="badge-container">
105
68
  <dx-metadata-badge
106
- value={item.product}
107
- size="small"
69
+ for:each={item.tags}
70
+ for:item="tag"
71
+ key={tag}
72
+ value={tag}
108
73
  ></dx-metadata-badge>
109
74
  </div>
110
75
  <div class="external-link-container">
111
76
  <dx-button
112
77
  target={target}
113
78
  icon-symbol="new_window"
114
- variant="inline"
115
- href={item.href}
79
+ variant="primary"
80
+ size="large"
81
+ href={item.githubLink}
116
82
  onclick={handleReadItClick}
117
83
  >
118
- {item.buttonText}
84
+ Explore on GitHub
85
+ </dx-button>
86
+ <dx-button
87
+ target={target}
88
+ variant="secondary"
89
+ size="large"
90
+ href={item.trailheadLink}
91
+ onclick={handleReadItClick}
92
+ >
93
+ Learn on Trailhead
119
94
  </dx-button>
120
95
  </div>
121
96
  </div>
122
97
  </dx-card-docs>
123
98
  </dx-grid>
124
- <div if:false={hidePagination} class="pagination-container">
125
- <dx-pagination
126
- if:false={showEmptyState}
127
- current-page={page}
128
- total-pages={totalPages}
129
- pages-to-show={pagesToShow}
130
- onpagechange={goToPage}
131
- ></dx-pagination>
132
- </div>
133
- <dx-empty-state
134
- variant="alt"
135
- header="Beep boop. That did not compute."
136
- subtitle={emptyStateSubtitle}
137
- body={emptyStateBody}
138
- suggestions={emptyStateSuggestions}
139
- if:true={showEmptyState}
140
- ></dx-empty-state>
141
99
  </dx-section>
142
100
  </template>
@@ -1,128 +1,20 @@
1
1
  import { api, LightningElement } from "lwc";
2
- import qs from "query-string";
3
- import uniqBy from "lodash.uniqby";
4
- import orderBy from "lodash.orderby";
5
- import cloneDeep from "lodash.clonedeep";
6
- import { DropdownItem, CodeSample } from "typings/custom";
2
+
3
+ import { CodeSample } from "typings/custom";
7
4
  import { toJson } from "dxUtils/normalizers";
8
- import { track } from "dxUtils/analytics";
9
5
 
10
- const PRODUCT_FILTER_ALL_PRODUCTS = "all products";
11
- const WAIT_TIME = 500;
12
6
  const DEFAULT_BUTTON_TEXT = "Explore on GitHub";
13
7
  export default class CodeSamplesGrid extends LightningElement {
14
- private searchTerm = "";
15
- private selectedProductFilter: string[] | null = null;
16
- private selectedTypeFilter: string[] | null = null;
17
- private selectedSourceFilter: string[] | null = null;
18
- private page = 1;
19
- private pageSize = 9;
20
- private startingRecord = 1;
21
- private endingRecord = 24;
22
- private totalRecountCount = 0;
23
- private totalPages = 1;
24
8
  private _featuredCodeSample?: CodeSample = undefined;
25
9
  private _samplesList: CodeSample[] = [];
26
- private _typesFiltersList: DropdownItem[] = [];
27
- private _sourceFiltersList: DropdownItem[] = [];
28
- private _productFiltersList: DropdownItem[] = [];
29
- private matchDesktop!: MediaQueryList;
30
- private matchMobile!: MediaQueryList;
31
- private matchMobileSmall!: MediaQueryList;
32
10
  private deviceType: "desktop" | "mobile" | "mobile-small" = "desktop";
33
- private _searchTimeout?: number;
34
11
  private target = "_blank";
35
12
  private isDesktop = "(min-width: 1024px)";
36
13
  private isMobile = "(min-width: 401px) and (max-width: 1023px)";
37
14
  private isMobileSmall = "(max-width: 400px)";
38
- private showSourcesFilter = false;
39
- private filteredItemsSelected: boolean = false;
40
- private filtersDefaultValue = {
41
- selectedSourceFilter: [] as string[],
42
- selectedTypeFilter: [] as string[],
43
- selectedProductFilter: [] as string[],
44
- searchTerm: "",
45
- page: "1"
46
- };
47
15
 
48
16
  connectedCallback(): void {
49
- this.matchDesktop = window.matchMedia(this.isDesktop);
50
- this.matchDesktop.addEventListener("change", this.handleView);
51
-
52
- this.matchMobile = window.matchMedia(this.isMobile);
53
- this.matchMobile.addEventListener("change", this.handleView);
54
-
55
- this.matchMobileSmall = window.matchMedia(this.isMobileSmall);
56
- this.matchMobileSmall.addEventListener("change", this.handleView);
57
- window.addEventListener("popstate", this.handleURLStateChange);
58
- if (this.matchDesktop.matches) {
59
- this.deviceType = "desktop";
60
- }
61
- if (this.matchMobile.matches) {
62
- this.deviceType = "mobile";
63
- }
64
- if (this.matchMobileSmall.matches) {
65
- this.deviceType = "mobile-small";
66
- }
67
- this.evaluateQueryParams(false);
68
- }
69
-
70
- handleURLStateChange(): void {
71
- this.evaluateQueryParams(true);
72
- this.scrollToTop();
73
- }
74
-
75
- evaluateQueryParams(resetFilters: boolean): void {
76
- let page = "1";
77
- if (resetFilters) {
78
- this.selectedSourceFilter =
79
- this.filtersDefaultValue.selectedSourceFilter;
80
- this.selectedTypeFilter =
81
- this.filtersDefaultValue.selectedTypeFilter;
82
- this.selectedProductFilter =
83
- this.filtersDefaultValue.selectedProductFilter;
84
- }
85
- const urlParams = new URLSearchParams(window.location.search);
86
- if (urlParams.toString()) {
87
- if (urlParams.has("source")) {
88
- this.selectedSourceFilter = urlParams.getAll("source");
89
- }
90
- if (urlParams.has("type")) {
91
- this.selectedTypeFilter = urlParams.getAll("type");
92
- }
93
- if (urlParams.get("service")) {
94
- this.selectedProductFilter = urlParams
95
- .get("service")!
96
- .split(",");
97
- }
98
- if (urlParams.get("filter_text")) {
99
- this.searchTerm = (
100
- urlParams.get("filter_text") || ""
101
- ).toLowerCase();
102
- }
103
- if (urlParams.has("page")) {
104
- page = urlParams.get("page")!;
105
- }
106
- }
107
- this.calculatePagination(page, true);
108
- }
109
-
110
- disconnectedCallback(): void {
111
- this.matchDesktop.removeEventListener("change", this.handleView);
112
- this.matchMobile.removeEventListener("change", this.handleView);
113
- this.matchMobileSmall.removeEventListener("change", this.handleView);
114
- window.removeEventListener("popstate", this.handleURLStateChange);
115
-
116
- if (!this.filteredItemsSelected) {
117
- this.selectedProductFilter?.forEach((filter) => {
118
- track(document, "custEv_filterAbandoned", {
119
- click_text: filter,
120
- element_title: "CodeSamplesGrid",
121
- element_type: "filter abandoned",
122
- content_category: "filter"
123
- });
124
- });
125
- }
17
+ console.log(this._samplesList);
126
18
  }
127
19
 
128
20
  @api
@@ -141,12 +33,10 @@ export default class CodeSamplesGrid extends LightningElement {
141
33
  title: sample.title,
142
34
  body: sample.body,
143
35
  buttonText: DEFAULT_BUTTON_TEXT,
144
- href: sample.href,
145
- imgSrc: sample.imgSrc,
146
- product: sample.product,
147
- type: sample.type,
148
- // source: sample.source,
149
- source: "none",
36
+ githubLink: sample.githubLink,
37
+ trailheadLink: sample.trailheadLink,
38
+ img: sample.img,
39
+ tags: sample.tags,
150
40
  target: this.target
151
41
  }));
152
42
  }
@@ -155,128 +45,8 @@ export default class CodeSamplesGrid extends LightningElement {
155
45
  return this._samplesList;
156
46
  }
157
47
 
158
- @api
159
- set products(value: string) {
160
- const productsFilters = toJson(value).map((sample: string) => ({
161
- label: sample,
162
- value: sample.toLowerCase()
163
- }));
164
-
165
- this._productFiltersList = orderBy(
166
- uniqBy([...productsFilters] as any, "value"),
167
- ["value"],
168
- ["asc"]
169
- ) as any[];
170
- this.selectedProductFilter = this._productFiltersList.map(
171
- (filter) => filter.value
172
- );
173
- this.filtersDefaultValue.selectedProductFilter = cloneDeep(
174
- this.selectedProductFilter
175
- );
176
- }
177
- get products(): DropdownItem[] {
178
- return this._productFiltersList;
179
- }
180
-
181
- @api
182
- set types(value: string) {
183
- const typesFilter = toJson(value).map((sample: string) => ({
184
- label: sample,
185
- value: sample.toLowerCase()
186
- }));
187
-
188
- this._typesFiltersList = orderBy(
189
- uniqBy([...typesFilter] as any, "value"),
190
- ["value"],
191
- ["asc"]
192
- ) as any[];
193
- this.selectedTypeFilter = this._typesFiltersList.map(
194
- (filter) => filter.value
195
- );
196
- this.filtersDefaultValue.selectedTypeFilter = cloneDeep(
197
- this.selectedTypeFilter
198
- );
199
- }
200
- get types(): DropdownItem[] {
201
- return this._typesFiltersList;
202
- }
203
-
204
- @api
205
- set sources(value: string) {
206
- const parsedValues = toJson(value);
207
- this.showSourcesFilter = parsedValues.length > 0;
208
- const sourcesFilter = parsedValues.map((sample: string) => ({
209
- label: sample,
210
- value: sample.toLowerCase()
211
- }));
212
-
213
- this._sourceFiltersList = orderBy(
214
- uniqBy([...sourcesFilter] as any, "value"),
215
- ["value"],
216
- ["asc"]
217
- ) as any;
218
- this.selectedSourceFilter = this._sourceFiltersList.map(
219
- (filter) => filter.value
220
- );
221
- this.filtersDefaultValue.selectedSourceFilter = cloneDeep(
222
- this.selectedSourceFilter
223
- );
224
- }
225
- get sources(): DropdownItem[] {
226
- return this._sourceFiltersList;
227
- }
228
-
229
- get filteredSamples(): CodeSample[] {
230
- return this.filterSamples([...this.samples]);
231
- }
232
-
233
- get currentPageSamples(): CodeSample[] {
234
- return this.filteredSamples.slice(
235
- this.startingRecord - 1,
236
- this.endingRecord
237
- );
238
- }
239
-
240
- get typesList(): DropdownItem[] {
241
- return this._typesFiltersList || [];
242
- }
243
-
244
- get productFiltersList(): DropdownItem[] {
245
- return this._productFiltersList || [];
246
- }
247
-
248
- get showEmptyState(): boolean {
249
- return !this.filteredSamples.length;
250
- }
251
-
252
48
  get tileColumns(): string {
253
- return this.deviceType === "desktop" ? "three" : "two";
254
- }
255
-
256
- get pagesToShow(): number {
257
- return this.deviceType === "mobile-small" ? 3 : 5;
258
- }
259
-
260
- get hidePagination(): boolean {
261
- return this.totalPages < 2;
262
- }
263
-
264
- get emptyStateSubtitle() {
265
- return (
266
- "Sorry, no results were found for your search" +
267
- (this.searchTerm !== "" ? ` "${this.searchTerm}"` : "")
268
- );
269
- }
270
-
271
- get emptyStateBody() {
272
- return "Search Tips:";
273
- }
274
-
275
- get emptyStateSuggestions() {
276
- return JSON.stringify([
277
- "Please consider misspellings",
278
- "Try different search keywords"
279
- ]);
49
+ return this.deviceType === "desktop" ? "two" : "one";
280
50
  }
281
51
 
282
52
  handleView = (e: MediaQueryListEvent | MediaQueryList): void => {
@@ -294,169 +64,4 @@ export default class CodeSamplesGrid extends LightningElement {
294
64
  this.deviceType = "mobile-small";
295
65
  }
296
66
  };
297
-
298
- goToPage(e: CustomEvent): void {
299
- const page = e.detail;
300
- this.displayRecordsPerPage(page);
301
- this.setSearchParams("page", page ? page.toString() : "1");
302
- this.scrollToTop();
303
- }
304
-
305
- displayRecordsPerPage(page: number): void {
306
- this.page = page;
307
- this.startingRecord =
308
- page === 1 ? page : (page - 1) * this.pageSize + 1;
309
- this.endingRecord = this.pageSize * page;
310
- this.endingRecord =
311
- this.endingRecord > this.totalRecountCount
312
- ? this.totalRecountCount
313
- : this.endingRecord;
314
- }
315
-
316
- handleSearchChange(event: CustomEvent): void {
317
- const value = event.detail;
318
- this.searchTerm = value.toLowerCase();
319
- window.clearTimeout(this._searchTimeout);
320
- this._searchTimeout = window.setTimeout(() => {
321
- this.calculatePagination();
322
- }, WAIT_TIME);
323
- }
324
-
325
- handleSourceFilterChange(event: CustomEvent): void {
326
- this.selectedSourceFilter = event.detail.value;
327
- this.calculatePagination();
328
- }
329
-
330
- handleTypeFilterChange(event: CustomEvent): void {
331
- this.selectedTypeFilter = event.detail.value;
332
- this.calculatePagination();
333
- }
334
-
335
- handleProductFilterChange(event: CustomEvent): void {
336
- if (event.detail.checkedValue === PRODUCT_FILTER_ALL_PRODUCTS) {
337
- if (event.detail.checked) {
338
- this.selectedProductFilter = this.productFiltersList.map(
339
- (filter) => filter.value
340
- );
341
- } else {
342
- this.selectedProductFilter = [];
343
- }
344
- } else {
345
- let newList = event.detail.value;
346
- if (!event.detail.checked) {
347
- newList = newList.filter(
348
- (val: typeof PRODUCT_FILTER_ALL_PRODUCTS) =>
349
- val !== PRODUCT_FILTER_ALL_PRODUCTS
350
- );
351
- }
352
- this.selectedProductFilter = newList;
353
- }
354
- this.calculatePagination();
355
- this.filteredItemsSelected = false;
356
- }
357
-
358
- handleLanguageFilterChange(event: CustomEvent): void {
359
- this.selectedTypeFilter = event.detail.value;
360
- this.setSearchParams("type", this.selectedTypeFilter);
361
- }
362
-
363
- filterSamples(samples: CodeSample[]): CodeSample[] {
364
- const filtered = samples
365
- .filter((contentItem) => {
366
- const matchesSearchTerm =
367
- contentItem.body.toLowerCase().includes(this.searchTerm) ||
368
- contentItem.title.toLowerCase().includes(this.searchTerm);
369
- const matchesProductFilters =
370
- !this.selectedProductFilter ||
371
- !this.selectedProductFilter.length ||
372
- this.selectedProductFilter.includes(
373
- PRODUCT_FILTER_ALL_PRODUCTS
374
- ) ||
375
- (typeof contentItem.product === "string" &&
376
- this.selectedProductFilter.includes(
377
- contentItem.product.toLowerCase()
378
- ));
379
- const matchesTypeFilters =
380
- !this.selectedTypeFilter ||
381
- !this.selectedTypeFilter.length ||
382
- (typeof contentItem.type === "string" &&
383
- this.selectedTypeFilter.includes(
384
- contentItem.type.toLowerCase()
385
- ));
386
- const matchesSourceFilters =
387
- !this.selectedSourceFilter ||
388
- !this.selectedSourceFilter.length ||
389
- (typeof contentItem.source === "string" &&
390
- this.selectedSourceFilter.includes(
391
- contentItem.source.toLowerCase()
392
- ));
393
-
394
- return (
395
- matchesSearchTerm &&
396
- matchesProductFilters &&
397
- matchesTypeFilters &&
398
- matchesSourceFilters
399
- );
400
- })
401
- .sort((a: CodeSample, b: CodeSample) => {
402
- return a.title.localeCompare(b.title);
403
- });
404
- return filtered;
405
- }
406
-
407
- calculatePagination(page?: string, skipSetSearchParams = false): void {
408
- if (page) {
409
- this.page = parseInt(page, 10) || 1;
410
- }
411
- this.totalRecountCount = this.filteredSamples.length;
412
- this.totalPages = Math.ceil(this.totalRecountCount / this.pageSize);
413
- this.displayRecordsPerPage(this.page);
414
- if (!skipSetSearchParams) {
415
- this.setSearchParams();
416
- }
417
- }
418
-
419
- scrollToTop(): void {
420
- this.template
421
- .querySelector(".docs-grid-container")!
422
- .scrollIntoView({ behavior: "smooth" });
423
- }
424
-
425
- setSearchParams(key?: string | null, val?: string[] | null): void {
426
- const service =
427
- this.selectedProductFilter!.length ===
428
- this.productFiltersList.length
429
- ? ""
430
- : this.selectedProductFilter!.join(",");
431
- const params: { [key: string]: any } = {
432
- filter_text: this.searchTerm,
433
- service,
434
- type: this.selectedTypeFilter,
435
- page: this.page.toString(),
436
- source: this.selectedSourceFilter
437
- };
438
- if (key) {
439
- params[key] = key === "service" ? val!.join(",") : val;
440
- }
441
- for (const _key in params) {
442
- if (!params[_key]) {
443
- delete params[_key];
444
- }
445
- }
446
- const searchParams = qs.stringify(params);
447
- const newurl = `${window.location.pathname}?${searchParams}`;
448
- window.history.pushState({ path: newurl }, "", newurl);
449
- }
450
-
451
- handleReadItClick() {
452
- this.filteredItemsSelected = true;
453
- this.selectedProductFilter?.forEach((filter) => {
454
- track(document, "custEv_filterApplied", {
455
- click_text: filter,
456
- click_url: `${window.location.origin}${filter}`,
457
- element_type: "filter applied",
458
- content_category: "filter"
459
- });
460
- });
461
- }
462
67
  }