sr-npm 3.1.14 → 3.1.16

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": "3.1.14",
3
+ "version": "3.1.16",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -441,16 +441,20 @@ function getValueFromValueId(valueIds, value) {
441
441
  function updateOptionsUI(_$w,fieldTitle, fieldId, searchQuery,clearAll=false) {
442
442
  let base = optionsByFieldId.get(fieldId) || [];
443
443
  const countsMap = countsByFieldId.get(fieldId) || new Map();
444
- if(dontUpdateThisCheckBox===fieldId && !clearAll)
444
+ if(dontUpdateThisCheckBox===fieldId && !clearAll && selectedByField.has(fieldId) )
445
445
  {
446
- dontUpdateThisCheckBox=null;
447
- return;
446
+ dontUpdateThisCheckBox=null;
447
+ return;
448
448
  }
449
449
  let filteredbase=[]
450
450
  for (const element of base)
451
451
  {
452
452
  if(countsMap.get(element.value))
453
453
  {
454
+ if(countsMap.get(element.value)==-1)
455
+ {
456
+ countsMap.set(element.value,0);
457
+ }
454
458
  filteredbase.push(element)
455
459
  }
456
460
  }
@@ -468,19 +472,31 @@ function getValueFromValueId(valueIds, value) {
468
472
  : withCounts;
469
473
 
470
474
  // Preserve currently selected values that are still visible
471
- let prevSelected=[]
472
- clearAll? prevSelected=[]:prevSelected= _$w(`#${FiltersIds[fieldTitle]}CheckBox`).value;
475
+ // let prevSelected=[]
476
+ // clearAll? prevSelected=[]:prevSelected= _$w(`#${FiltersIds[fieldTitle]}CheckBox`).value;
473
477
  const visibleSet = new Set(filtered.map(o => o.value));
474
- const preserved = prevSelected.filter(v => visibleSet.has(v));
478
+ //const preserved = prevSelected.filter(v => visibleSet.has(v));
475
479
  if(filtered.length===0) {
476
480
  _$w(`#${FiltersIds[fieldTitle]}MultiBox`).changeState(`${FiltersIds[fieldTitle]}NoResults`);
477
481
  }
478
482
  else{
479
483
  _$w(`#${FiltersIds[fieldTitle]}MultiBox`).changeState(`${FiltersIds[fieldTitle]}Results`);
480
484
  _$w(`#${FiltersIds[fieldTitle]}CheckBox`).options = filtered;
481
- _$w(`#${FiltersIds[fieldTitle]}CheckBox`).value = preserved;
485
+ clearAll?_$w(`#${FiltersIds[fieldTitle]}CheckBox`).value=[]:_$w(`#${FiltersIds[fieldTitle]}CheckBox`).value = visibleSet
486
+ if(visibleSet.size>0 && selectedByField.has(fieldId)) {
487
+ let selectedindices=[];
488
+ for(const value of selectedByField.get(fieldId)) {
489
+ const options = optionsByFieldId.get(fieldId) || [];
490
+ const option = getCorrectOption(value,options,fieldTitle);
491
+ if(option) {
492
+ const optionIndex = getOptionIndexFromCheckBox(_$w(`#${FiltersIds[fieldTitle]}CheckBox`).options,option.value);
493
+ selectedindices.push(optionIndex);
494
+ }
495
+ }
496
+ _$w(`#${FiltersIds[fieldTitle]}CheckBox`).selectedIndices = selectedindices;
482
497
  }
483
498
  }
499
+ }
484
500
 
485
501
  async function applyJobFilters(_$w) {
486
502
  let tempFilteredJobs=[];
@@ -593,7 +609,18 @@ async function refreshFacetCounts(_$w,clearAll=false) {
593
609
  counter.set(option.value, (counter.get(option.value) || 0) + 1);
594
610
  }
595
611
  }
612
+
613
+ }
614
+ if(selectedByField.has(fieldId)) {
615
+ for (const value of selectedByField.get(fieldId)) {
616
+ console.log("value: ",value)
617
+ if(counter.get(value)===undefined)
618
+ {
619
+ //it is -1 as a flag, so in case it was selected and after selecting more filters from different field and suddenly no more jobs have it, we will show 0
620
+ counter.set(value, -1);
621
+ }
596
622
  }
623
+ }
597
624
  countsByFieldId.set(fieldId, counter);
598
625
  }
599
626
  }
@@ -81,10 +81,12 @@ function getFieldByTitle(title,allFields) {
81
81
 
82
82
  function getCorrectOption(value,options,param) {
83
83
  const standardizedValue = normalizeString(value.toLowerCase())
84
- if(param==="employmenttype") //employmenttype have a problematic value
84
+ if(param==="employmenttype" || param==="Employment Type" || param==="Store Name") //employmenttype have a problematic value, added Employment Type for updateOptionsUI fuinction, added Store Name because Store name and location have for example Blenheim
85
85
  {
86
+ //option.value is the id,
86
87
  return options.find(option=>normalizeString(option.value.toLowerCase())===standardizedValue);
87
88
  }
89
+ //option.label is what we see live in the UI
88
90
  return options.find(option=>normalizeString(option.label.toLowerCase())===standardizedValue);
89
91
  }
90
92