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