sr-npm 1.7.672 → 1.7.674
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 +1 -1
- package/pages/careersMultiBoxesPage.js +57 -14
package/package.json
CHANGED
|
@@ -138,34 +138,57 @@ async function loadJobs(_$w) {
|
|
|
138
138
|
valuesByFieldId.set("Location",cities)
|
|
139
139
|
valuesByFieldIdGlobal = valuesByFieldId; // store globally
|
|
140
140
|
console.log("valuesByFieldId: @$##@$@##$ ",valuesByFieldId)
|
|
141
|
+
|
|
142
|
+
// Build CheckboxGroup options for this field
|
|
143
|
+
|
|
141
144
|
|
|
142
145
|
for(const [key, value] of valuesByFieldId) {
|
|
143
146
|
console.log("elemenet: ",key)
|
|
144
147
|
for(const field of fields) {
|
|
145
148
|
if(field._id===key && field.title==="Category") {
|
|
149
|
+
let originalOptions=[];
|
|
150
|
+
if(key==="Location") {
|
|
151
|
+
originalOptions=value.map(city=>({
|
|
152
|
+
label: city.city,
|
|
153
|
+
value: city._id
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
else{
|
|
157
|
+
originalOptions=value
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
optionsByFieldId.set(key, originalOptions);
|
|
161
|
+
const counter={}
|
|
162
|
+
|
|
163
|
+
for (const val of allvaluesobjects) {
|
|
164
|
+
counter[val.title]=val.totalJobs
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
countsByFieldId.set(key, new Map(originalOptions.map(o => [o.value, counter[o.label]])));
|
|
146
168
|
updateOptionsUI(_$w,field.title, field._id, ''); // no search query
|
|
147
169
|
console.log("field: ",field)
|
|
148
170
|
console.log("elemenet: ",key)
|
|
149
171
|
console.log("valuesByFieldId.get(elemenet): ",valuesByFieldId.get(key))
|
|
150
172
|
//_$w("#CategoryCheckBox").options = valuesByFieldId.get(elemenet);
|
|
151
|
-
_$w(
|
|
173
|
+
_$w(`#${field.title}CheckBox`).onChange(async (ev) => {
|
|
152
174
|
dontUpdateThisCheckBox=field._id;
|
|
153
175
|
const selected = ev.target.value; // array of selected value IDs
|
|
154
176
|
if (selected && selected.length) {
|
|
155
177
|
selectedByField.set(field._id, selected);
|
|
156
178
|
} else {
|
|
157
|
-
selectedByField.delete(field._id);
|
|
179
|
+
selectedByField.delete(field._id);
|
|
158
180
|
}
|
|
159
181
|
await applyJobFilters(_$w,field._id); // re-query jobs
|
|
160
|
-
|
|
182
|
+
await refreshFacetCounts(_$w,field.title); // recompute and update counts in all lists
|
|
161
183
|
// await updateSelectedValuesRepeater(_$w);
|
|
162
184
|
updateTotalJobsCountText(_$w);
|
|
163
185
|
});
|
|
164
|
-
|
|
165
|
-
const
|
|
186
|
+
|
|
187
|
+
const runFilter = debounce(() => {
|
|
188
|
+
const query = (_$w(`#${field.title}input`).value || '').toLowerCase().trim();
|
|
166
189
|
updateOptionsUI(_$w, field.title, field._id, query);
|
|
167
190
|
}, 150);
|
|
168
|
-
|
|
191
|
+
_$w(`#${field.title}input`).onInput(runFilter);
|
|
169
192
|
found=true;
|
|
170
193
|
break;
|
|
171
194
|
}
|
|
@@ -175,6 +198,15 @@ async function loadJobs(_$w) {
|
|
|
175
198
|
}
|
|
176
199
|
}
|
|
177
200
|
|
|
201
|
+
await refreshFacetCounts(_$w);
|
|
202
|
+
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).forEachItem(($item, itemData) => {
|
|
203
|
+
// const query = ($item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).value || '').toLowerCase().trim();
|
|
204
|
+
// updateOptionsUI($item, itemData._id, query);
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
178
210
|
//
|
|
179
211
|
|
|
180
212
|
|
|
@@ -249,6 +281,9 @@ async function loadJobs(_$w) {
|
|
|
249
281
|
|
|
250
282
|
|
|
251
283
|
// });
|
|
284
|
+
for(const city of cities) {
|
|
285
|
+
counter[city.city]=city.count
|
|
286
|
+
}
|
|
252
287
|
} catch (err) {
|
|
253
288
|
console.error('Failed to load filters:', err);
|
|
254
289
|
}
|
|
@@ -280,6 +315,7 @@ async function loadJobs(_$w) {
|
|
|
280
315
|
|
|
281
316
|
function updateOptionsUI(_$w,fieldTitle, fieldId, searchQuery) {
|
|
282
317
|
let base = optionsByFieldId.get(fieldId) || [];
|
|
318
|
+
console.log("base: ",base)
|
|
283
319
|
const countsMap = countsByFieldId.get(fieldId) || new Map();
|
|
284
320
|
if(dontUpdateThisCheckBox===fieldId)
|
|
285
321
|
{
|
|
@@ -309,12 +345,15 @@ async function loadJobs(_$w) {
|
|
|
309
345
|
|
|
310
346
|
// Preserve currently selected values that are still visible
|
|
311
347
|
// const prevSelected = $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).value || [];
|
|
312
|
-
const prevSelected = _$w(
|
|
348
|
+
const prevSelected = _$w(`#${fieldTitle}CheckBox`).value || [];
|
|
313
349
|
const visibleSet = new Set(filtered.map(o => o.value));
|
|
314
350
|
const preserved = prevSelected.filter(v => visibleSet.has(v));
|
|
351
|
+
console.log("preserved: ",preserved)
|
|
352
|
+
console.log("filtered: ",filtered)
|
|
353
|
+
console.log("fieldTitle: ",fieldTitle)
|
|
315
354
|
|
|
316
|
-
_$w(
|
|
317
|
-
_$w(
|
|
355
|
+
_$w(`#${fieldTitle}CheckBox`).options = filtered;
|
|
356
|
+
_$w(`#${fieldTitle}CheckBox`).value = preserved;
|
|
318
357
|
|
|
319
358
|
}
|
|
320
359
|
|
|
@@ -355,7 +394,7 @@ async function loadJobs(_$w) {
|
|
|
355
394
|
}
|
|
356
395
|
|
|
357
396
|
|
|
358
|
-
async function refreshFacetCounts(_$w) {
|
|
397
|
+
async function refreshFacetCounts(_$w,fieldTitle) {
|
|
359
398
|
const fieldIds = Array.from(optionsByFieldId.keys());
|
|
360
399
|
const currentJobsIds=currentJobs.map(job=>job._id);
|
|
361
400
|
for (const fieldId of fieldIds) {
|
|
@@ -371,10 +410,14 @@ async function refreshFacetCounts(_$w) {
|
|
|
371
410
|
countsByFieldId.set(fieldId, counter);
|
|
372
411
|
}
|
|
373
412
|
// // After counts are ready, update all items currently rendered
|
|
374
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).forEachItem(($item, itemData) => {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
});
|
|
413
|
+
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).forEachItem(($item, itemData) => {
|
|
414
|
+
// const query = ($item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).value || '').toLowerCase().trim();
|
|
415
|
+
// updateOptionsUI($item, itemData._id, query);
|
|
416
|
+
// });
|
|
417
|
+
for(const fieldId of fieldIds) {
|
|
418
|
+
const query = (_$w(`#${fieldTitle}input`).value || '').toLowerCase().trim();
|
|
419
|
+
updateOptionsUI(_$w,fieldTitle, fieldId, query); // no search query
|
|
420
|
+
}
|
|
378
421
|
}
|
|
379
422
|
|
|
380
423
|
function groupValuesByField(values, refKey) {
|