sr-npm 1.7.574 → 1.7.576
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.
|
@@ -6,7 +6,9 @@ const CAREERS_MULTI_BOXES_PAGE_CONSTS={
|
|
|
6
6
|
FILTER_LABEL: '#FilterTextInput',
|
|
7
7
|
FILTER_CHECKBOX_CONTAINER: '#FilterCheckBoxContainer',
|
|
8
8
|
FILTER_REPEATER_ITEM_CHECKBOX: '#filterCheckBox',
|
|
9
|
-
|
|
9
|
+
SELECTED_VALUES_REPEATER: '#selectedValuesReapter',
|
|
10
|
+
SELECTED_VALUES_REPEATER_ITEM_LABEL: '#selectedValueLabel',
|
|
11
|
+
DESELECT_BUTTON_ID: '#deselectFilterValueButton',
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
module.exports = {
|
package/package.json
CHANGED
|
@@ -10,6 +10,37 @@ const countsByFieldId = new Map();
|
|
|
10
10
|
async function careersMultiBoxesPageOnReady(_$w) {
|
|
11
11
|
await loadJobs(_$w);
|
|
12
12
|
await loadFilters(_$w);
|
|
13
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).onItemReady(($item, itemData) => {
|
|
14
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER_ITEM_LABEL).text = itemData.label || '';
|
|
15
|
+
|
|
16
|
+
// Deselect this value from both the selected map and the multibox
|
|
17
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.DESELECT_BUTTON_ID).onClick(() => {
|
|
18
|
+
const fieldId = itemData.fieldId;
|
|
19
|
+
const valueId = itemData.valueId;
|
|
20
|
+
if (!fieldId || !valueId) return;
|
|
21
|
+
|
|
22
|
+
const existing = selectedByField.get(fieldId) || [];
|
|
23
|
+
const updated = existing.filter(v => v !== valueId);
|
|
24
|
+
if (updated.length) {
|
|
25
|
+
selectedByField.set(fieldId, updated);
|
|
26
|
+
} else {
|
|
27
|
+
selectedByField.delete(fieldId);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Update the checkbox group UI inside the corresponding filter item
|
|
31
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).forEachItem(($filterItem, filterItemData) => {
|
|
32
|
+
if (filterItemData._id === fieldId) {
|
|
33
|
+
const currentVals = $filterItem(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).value || [];
|
|
34
|
+
const nextVals = currentVals.filter(v => v !== valueId);
|
|
35
|
+
$filterItem(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).value = nextVals;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
applyJobFilters(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES);
|
|
40
|
+
refreshFacetCounts();
|
|
41
|
+
updateSelectedValuesRepeater();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
13
44
|
}
|
|
14
45
|
|
|
15
46
|
async function loadJobs(_$w) {
|
|
@@ -28,7 +59,7 @@ async function loadJobs(_$w) {
|
|
|
28
59
|
});
|
|
29
60
|
}
|
|
30
61
|
|
|
31
|
-
async function loadFilters() {
|
|
62
|
+
async function loadFilters(_$w) {
|
|
32
63
|
try {
|
|
33
64
|
// 1) Load all categories (fields)
|
|
34
65
|
const fields = await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
|
|
@@ -83,16 +114,16 @@ async function loadJobs(_$w) {
|
|
|
83
114
|
|
|
84
115
|
// Input typing -> only filter this list’s visible options (no Jobs query)
|
|
85
116
|
const runFilter = debounce(() => {
|
|
86
|
-
const query = ($item(
|
|
117
|
+
const query = ($item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).value || '').toLowerCase().trim();
|
|
87
118
|
updateOptionsUI($item, fieldId, query);
|
|
88
119
|
}, 150);
|
|
89
|
-
$item(
|
|
120
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).onInput(runFilter);
|
|
90
121
|
});
|
|
91
122
|
|
|
92
123
|
await refreshFacetCounts();
|
|
93
124
|
// After counts are ready, re-render all items to show numbers
|
|
94
|
-
$w(
|
|
95
|
-
const query = ($item(
|
|
125
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).forEachItem(($item, itemData) => {
|
|
126
|
+
const query = ($item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).value || '').toLowerCase().trim();
|
|
96
127
|
updateOptionsUI($item, itemData._id, query);
|
|
97
128
|
|
|
98
129
|
|
|
@@ -226,6 +257,16 @@ async function refreshFacetCounts() {
|
|
|
226
257
|
});
|
|
227
258
|
}
|
|
228
259
|
|
|
260
|
+
function groupValuesByField(values, refKey) {
|
|
261
|
+
const map = new Map();
|
|
262
|
+
for (const v of values) {
|
|
263
|
+
const ref = v[refKey]; // should be the _id of the CustomFields item
|
|
264
|
+
if (!ref) continue;
|
|
265
|
+
if (!map.has(ref)) map.set(ref, []);
|
|
266
|
+
map.get(ref).push(v);
|
|
267
|
+
}
|
|
268
|
+
return map;
|
|
269
|
+
}
|
|
229
270
|
|
|
230
271
|
|
|
231
272
|
module.exports = {
|