@salesforcedevs/dw-components 1.1.2-alpha.3 → 1.1.2-alpha.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/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div class="panel-list-container">
|
|
3
3
|
<h2 class="title">{title}</h2>
|
|
4
4
|
<dx-tab-panel-list tabs={tabLabels} onchange={handleTabChange}>
|
|
5
|
-
<template for:each={
|
|
5
|
+
<template for:each={trials} for:item="trial">
|
|
6
6
|
<dx-tab-panel key={trial.label}>
|
|
7
7
|
<div
|
|
8
8
|
key={trial.label}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
></dx-button-toggle>
|
|
21
21
|
</template>
|
|
22
22
|
</div>
|
|
23
|
-
<template for:each={
|
|
23
|
+
<template for:each={filteredCategories} for:item="category">
|
|
24
24
|
<div key={category.title} class="category-container">
|
|
25
25
|
<h2 class="dx-text-heading-4 category-title">
|
|
26
26
|
{category.title}
|
|
@@ -8,13 +8,19 @@ export default class BrowseTrials extends LightningElement {
|
|
|
8
8
|
get trials() {
|
|
9
9
|
return this._trials;
|
|
10
10
|
}
|
|
11
|
-
set trials(
|
|
11
|
+
set trials(
|
|
12
|
+
value: [{ label: string; hideFilters: boolean; buttonLabels: string[] }]
|
|
13
|
+
) {
|
|
12
14
|
this._trials = toJson(value);
|
|
13
|
-
this._trialsCopy = toJson(value);
|
|
14
15
|
this.tabLabels = this._trials.map((trial) => ({ label: trial.label }));
|
|
15
16
|
this.buttonLabels = this._trials.map((trial) =>
|
|
16
|
-
trial.
|
|
17
|
+
trial.hideFilters ? [] : trial.buttonLabels
|
|
17
18
|
);
|
|
19
|
+
this._filteredCategories = this._trials.map(
|
|
20
|
+
(trial) => trial.categories
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
console.log(this._filteredCategories);
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
get buttonLabelsForActiveTab() {
|
|
@@ -25,58 +31,65 @@ export default class BrowseTrials extends LightningElement {
|
|
|
25
31
|
return this._trials[this.activeTabIndex].categories;
|
|
26
32
|
}
|
|
27
33
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return this._trialsCopy[this.activeTabIndex].categories;
|
|
34
|
+
get filteredCategories() {
|
|
35
|
+
return this._filteredCategories[this.activeTabIndex];
|
|
31
36
|
}
|
|
32
|
-
set
|
|
33
|
-
this.
|
|
37
|
+
set filteredCategories(value: any) {
|
|
38
|
+
this._filteredCategories[this.activeTabIndex] = value;
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
@track
|
|
37
|
-
private
|
|
38
|
-
{ label: string; categories: Array<{ title: string }> }
|
|
39
|
-
];
|
|
42
|
+
private _filteredCategories!: Array<any>;
|
|
40
43
|
|
|
44
|
+
private activeTabIndex = 0;
|
|
41
45
|
private buttonLabels!: string[][];
|
|
46
|
+
private filteredTitles: string[] = [];
|
|
42
47
|
private tabLabels!: Array<{ label: string }>;
|
|
43
|
-
private _trials!: [
|
|
44
|
-
|
|
48
|
+
private _trials!: [
|
|
49
|
+
{
|
|
50
|
+
label: string;
|
|
51
|
+
hideFilters: boolean;
|
|
52
|
+
buttonLabels: string[];
|
|
53
|
+
categories: Array<{ title: string }>;
|
|
54
|
+
}
|
|
55
|
+
];
|
|
45
56
|
|
|
46
57
|
handleTabChange(e: CustomEvent) {
|
|
47
58
|
this.activeTabIndex = e.detail;
|
|
48
59
|
}
|
|
49
60
|
|
|
50
|
-
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
filterCategories() {
|
|
62
|
+
this.filteredCategories = this.activeCategories.filter((category) =>
|
|
63
|
+
this.filteredTitles.includes(category.title)
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
addLabelToFilter(label: string) {
|
|
68
|
+
this.filteredTitles.push(label);
|
|
69
|
+
this.filterCategories();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
removeLabelFromFilter(label: string) {
|
|
73
|
+
this.filteredTitles = this.filteredTitles.filter(
|
|
74
|
+
(filterTitle) => filterTitle !== label
|
|
75
|
+
);
|
|
76
|
+
this.filterCategories();
|
|
60
77
|
}
|
|
61
78
|
|
|
62
|
-
|
|
63
|
-
this.
|
|
64
|
-
|
|
65
|
-
? [...this.activeCategories]
|
|
66
|
-
: [
|
|
67
|
-
...this.activeCategories.filter(
|
|
68
|
-
(category) => category.title !== label
|
|
69
|
-
)
|
|
70
|
-
];
|
|
79
|
+
resetFilters() {
|
|
80
|
+
this.filteredTitles = [];
|
|
81
|
+
this.filteredCategories = this.activeCategories;
|
|
71
82
|
}
|
|
72
83
|
|
|
73
84
|
handleFilters(e: CustomEvent) {
|
|
74
85
|
const { label, value } = e.detail;
|
|
75
86
|
|
|
76
87
|
if (value) {
|
|
77
|
-
this.
|
|
88
|
+
this.addLabelToFilter(label);
|
|
89
|
+
} else if (this.filteredTitles.length !== 1) {
|
|
90
|
+
this.removeLabelFromFilter(label);
|
|
78
91
|
} else {
|
|
79
|
-
this.
|
|
92
|
+
this.resetFilters();
|
|
80
93
|
}
|
|
81
94
|
}
|
|
82
95
|
}
|