sr-npm 1.7.688 → 1.7.689

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": "sr-npm",
3
- "version": "1.7.688",
3
+ "version": "1.7.689",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -39,46 +39,10 @@ async function careersMultiBoxesPageOnReady(_$w) {
39
39
  selectedByField.clear();
40
40
  console.log("selectedByField after clear : ",selectedByField)
41
41
  await applyJobFilters(_$w);
42
- await refreshFacetCounts(_$w);
42
+ await refreshFacetCounts(_$w,true);
43
43
  await updateSelectedValuesRepeater(_$w);
44
44
  updateTotalJobsCountText(_$w);
45
45
  });
46
- // _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).onItemReady(($item, itemData) => {
47
- // $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER_ITEM_LABEL).text = itemData.label || '';
48
-
49
- // // Deselect this value from both the selected map and the multibox
50
- // $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.DESELECT_BUTTON_ID).onClick(async () => {
51
-
52
- // const fieldId = itemData.fieldId;
53
- // const valueId = itemData.valueId;
54
- // dontUpdateThisCheckBox=fieldId;
55
- // if (!fieldId || !valueId) return;
56
-
57
- // const existing = selectedByField.get(fieldId) || [];
58
- // const updated = existing.filter(v => v !== valueId);
59
- // if (updated.length) {
60
- // selectedByField.set(fieldId, updated);
61
- // } else {
62
- // selectedByField.delete(fieldId);
63
- // }
64
-
65
- // // Update the checkbox group UI inside the corresponding filter item
66
- // _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).forEachItem(($filterItem, filterItemData) => {
67
- // if (filterItemData._id === fieldId) {
68
- // const currentVals = $filterItem(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).value || [];
69
- // const nextVals = currentVals.filter(v => v !== valueId);
70
- // $filterItem(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).value = nextVals;
71
- // }
72
- // });
73
-
74
- // await applyJobFilters(_$w,fieldId);
75
- // await refreshFacetCounts(_$w);
76
- // await updateSelectedValuesRepeater(_$w);
77
- // updateTotalJobsCountText(_$w);
78
- // });
79
- // });
80
- // await updateSelectedValuesRepeater(_$w);
81
-
82
46
  }
83
47
 
84
48
  async function loadSelectedValuesRepeater(_$w) {
@@ -329,10 +293,10 @@ async function loadJobs(_$w) {
329
293
  };
330
294
  };
331
295
 
332
- function updateOptionsUI(_$w,fieldTitle, fieldId, searchQuery) {
296
+ function updateOptionsUI(_$w,fieldTitle, fieldId, searchQuery,clearAll=false) {
333
297
  let base = optionsByFieldId.get(fieldId) || [];
334
298
  const countsMap = countsByFieldId.get(fieldId) || new Map();
335
- if(dontUpdateThisCheckBox===fieldId)
299
+ if(dontUpdateThisCheckBox===fieldId && !clearAll)
336
300
  {
337
301
  dontUpdateThisCheckBox=null;
338
302
  return;
@@ -359,8 +323,8 @@ async function loadJobs(_$w) {
359
323
  : withCounts;
360
324
 
361
325
  // Preserve currently selected values that are still visible
362
- // const prevSelected = $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).value || [];
363
- const prevSelected = _$w(`#${FiltersIds[fieldTitle]}CheckBox`).value || [];
326
+ let prevSelected=[]
327
+ clearAll? prevSelected=[]:prevSelected= _$w(`#${FiltersIds[fieldTitle]}CheckBox`).value;
364
328
  const visibleSet = new Set(filtered.map(o => o.value));
365
329
  const preserved = prevSelected.filter(v => visibleSet.has(v));
366
330
 
@@ -407,7 +371,7 @@ async function loadJobs(_$w) {
407
371
  }
408
372
 
409
373
 
410
- async function refreshFacetCounts(_$w) {
374
+ async function refreshFacetCounts(_$w,clearAll=false) {
411
375
  const fieldIds = Array.from(optionsByFieldId.keys());
412
376
  const currentJobsIds=currentJobs.map(job=>job._id);
413
377
  for (const fieldId of fieldIds) {
@@ -422,14 +386,12 @@ async function refreshFacetCounts(_$w) {
422
386
  }
423
387
  countsByFieldId.set(fieldId, counter);
424
388
  }
425
- // // After counts are ready, update all items currently rendered
426
- // _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).forEachItem(($item, itemData) => {
427
- // const query = ($item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).value || '').toLowerCase().trim();
428
- // updateOptionsUI($item, itemData._id, query);
429
- // });
389
+ console.log("countsByFieldId after refreshFacetCounts: ",countsByFieldId)
390
+
430
391
  for(const field of allfields) {
431
392
  const query = (_$w(`#${FiltersIds[field.title]}input`).value || '').toLowerCase().trim();
432
- updateOptionsUI(_$w,field.title, field._id, query); // no search query
393
+ clearAll? updateOptionsUI(_$w,field.title, field._id, '',true):updateOptionsUI(_$w,field.title, field._id, query);
394
+ // no search query
433
395
  }
434
396
  }
435
397