sr-npm 1.7.714 → 1.7.716

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.714",
3
+ "version": "1.7.716",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -34,10 +34,25 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
34
34
  async function handleUrlParams(_$w,urlParams) {
35
35
  let applyFiltering=false;
36
36
  if(urlParams.brand) {
37
- const brandValue = decodeURIComponent(urlParams.brand);
38
- const field=getFieldByTitle(fieldTitlesInCMS.brand,allfields);
37
+ applyFiltering=await handleParams(_$w,"brand",urlParams.brand)
38
+ }
39
+ if(urlParams.category) {
40
+ applyFiltering=await handleParams(_$w,"category",urlParams.category)
41
+ }
42
+ if(urlParams.keyword) {
43
+ console.log("keyword urlparam handling coming soon...")
44
+ }
45
+ if(applyFiltering) {
46
+ await updateJobsAndNumbersAndFilters(_$w);
47
+ }
48
+ }
49
+
50
+ async function handleParams(_$w,param,value) {
51
+ let applyFiltering=false;
52
+ const decodedValue = decodeURIComponent(value);
53
+ const field=getFieldByTitle(fieldTitlesInCMS[param],allfields);
39
54
  const options=optionsByFieldId.get(field._id);
40
- const option=getCorrectOption(brandValue,options);
55
+ const option=getCorrectOption(decodedValue,options);
41
56
  if(option) {
42
57
  const optionIndex=getOptionIndexFromCheckBox(_$w(`#${FiltersIds[field.title]}CheckBox`).options,option.value);
43
58
  _$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = [optionIndex];
@@ -46,38 +61,9 @@ async function handleUrlParams(_$w,urlParams) {
46
61
  dontUpdateThisCheckBox=field._id;
47
62
  }
48
63
  else {
49
- console.warn("brand value not found in dropdown options");
50
- }
51
- }
52
- if(urlParams.category) {
53
- const categoryValue = decodeURIComponent(urlParams.category);
54
- const field=getFieldByTitle(fieldTitlesInCMS.category,allfields);
55
- const options=optionsByFieldId.get(field._id);
56
- const option=getCorrectOption(categoryValue,options);
57
- if(option) {
58
- const optionIndex=getOptionIndexFromCheckBox(_$w(`#${FiltersIds[field.title]}CheckBox`).options,option.value);
59
- _$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = [optionIndex];
60
- selectedByField.set(field._id, [option.value]);
61
- applyFiltering=true
62
- if(dontUpdateThisCheckBox)
63
- {
64
- //to update the checkboxes after applying the filters
65
- dontUpdateThisCheckBox=null;
66
- }
67
- else{
68
- dontUpdateThisCheckBox=field._id;
69
- }
70
- }
71
- else {
72
- console.warn("category value not found in dropdown options");
64
+ console.warn(`${param} value not found in dropdown options`);
73
65
  }
74
- }
75
- if(urlParams.keyword) {
76
- console.log("keyword urlparam handling coming soon...")
77
- }
78
- if(applyFiltering) {
79
- await updateJobsAndNumbersAndFilters(_$w);
80
- }
66
+ return applyFiltering;
81
67
  }
82
68
 
83
69
  async function loadPaginationButtons(_$w) {
@@ -46,25 +46,16 @@ function groupValuesByField(values, refKey) {
46
46
  }
47
47
 
48
48
  function getCorrectOption(value,options) {
49
- console.log("value: ", value);
50
- const standardizedValue = value.toLowerCase().trim().replace(/[-\s]/g, '');
51
- console.log("standardizedValue: ", standardizedValue);
52
- return options.find(option=>option.label.toLowerCase().trim().replace(/[-\s]/g, '')===standardizedValue);
49
+ const standardizedValue = value.toLowerCase().trim().replace(/[^a-z0-9]/gi, '');
50
+ return options.find(option=>option.label.toLowerCase().trim().replace(/[^a-z0-9]/gi, '')===standardizedValue);
53
51
  }
54
52
 
55
53
  function getOptionIndexFromCheckBox(options,value) {
56
- console.log("options: ", options);
57
- console.log("value: ", value);
58
54
  for(let index=0;index<options.length;index++) {
59
-
60
- console.log(`options at index ${index} is ${options[index]}`);
61
-
62
55
  if(options[index].value===value) {
63
- console.log(`found it !! at index ${index}`);
64
56
  return index;
65
57
  }
66
58
  }
67
- return options.findIndex(option=>option.value===value);
68
59
  }
69
60
 
70
61
  module.exports = {