sr-npm 1.7.575 → 1.7.577

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.575",
3
+ "version": "1.7.577",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -10,6 +10,38 @@ 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
+ });
44
+ updateSelectedValuesRepeater();
13
45
  }
14
46
 
15
47
  async function loadJobs(_$w) {
@@ -83,16 +115,16 @@ async function loadJobs(_$w) {
83
115
 
84
116
  // Input typing -> only filter this list’s visible options (no Jobs query)
85
117
  const runFilter = debounce(() => {
86
- const query = ($item(FILTER_LABEL_ID).value || '').toLowerCase().trim();
118
+ const query = ($item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).value || '').toLowerCase().trim();
87
119
  updateOptionsUI($item, fieldId, query);
88
120
  }, 150);
89
- $item(FILTER_LABEL_ID).onInput(runFilter);
121
+ $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).onInput(runFilter);
90
122
  });
91
123
 
92
124
  await refreshFacetCounts();
93
125
  // After counts are ready, re-render all items to show numbers
94
- $w(FILTER_REPEATER_ID).forEachItem(($item, itemData) => {
95
- const query = ($item(FILTER_LABEL_ID).value || '').toLowerCase().trim();
126
+ _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).forEachItem(($item, itemData) => {
127
+ const query = ($item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).value || '').toLowerCase().trim();
96
128
  updateOptionsUI($item, itemData._id, query);
97
129
 
98
130
 
@@ -226,6 +258,16 @@ async function refreshFacetCounts() {
226
258
  });
227
259
  }
228
260
 
261
+ function groupValuesByField(values, refKey) {
262
+ const map = new Map();
263
+ for (const v of values) {
264
+ const ref = v[refKey]; // should be the _id of the CustomFields item
265
+ if (!ref) continue;
266
+ if (!map.has(ref)) map.set(ref, []);
267
+ map.get(ref).push(v);
268
+ }
269
+ return map;
270
+ }
229
271
 
230
272
 
231
273
  module.exports = {