sr-npm 1.7.709 → 1.7.711

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.709",
3
+ "version": "1.7.711",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,7 +1,7 @@
1
1
  const { COLLECTIONS,CUSTOM_VALUES_COLLECTION_FIELDS,JOBS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
2
2
  const {CAREERS_MULTI_BOXES_PAGE_CONSTS,FiltersIds,fieldTitlesInCMS} = require('../backend/careersMultiBoxesPageIds');
3
3
  const { query,queryParams,onChange} = require("wix-location-frontend");
4
- const { groupValuesByField, debounce, getAllRecords, getFieldById, getFieldByTitle,getCorrectOption } = require('./pagesUtils');
4
+ const { groupValuesByField, debounce, getAllRecords, getFieldById, getFieldByTitle,getCorrectOption,getOptionIndexFromCheckBox } = require('./pagesUtils');
5
5
 
6
6
  let dontUpdateThisCheckBox;
7
7
  const selectedByField = new Map(); // fieldId -> array of selected value IDs
@@ -48,7 +48,11 @@ async function handleUrlParams(_$w,urlParams) {
48
48
  if(option) {
49
49
  console.log("setting the value of the checkbox to: ", option.value);
50
50
 
51
- _$w(`#${FiltersIds[field.title]}CheckBox`).value = [option.value];
51
+ // _$w(`#${FiltersIds[field.title]}CheckBox`).value = [option.value];
52
+ const optionIndex=getOptionIndexFromCheckBox(_$w(`#${FiltersIds[field.title]}CheckBox`).options,option.value);
53
+ console.log("optionIndex: ", optionIndex);
54
+
55
+ _$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = [optionIndex];
52
56
  selectedByField.set(field._id, [option.value]);
53
57
  applyFiltering=true;
54
58
  }
@@ -70,10 +74,10 @@ async function handleUrlParams(_$w,urlParams) {
70
74
  console.log("the correctoption: ", option);
71
75
  if(option) {
72
76
  console.log("setting the value of the checkbox to: ", option.value);
73
- _$w(`#${FiltersIds[field.title]}CheckBox`).value = [option.value];
77
+ //_$w(`#${FiltersIds[field.title]}CheckBox`).value = [option.value];
74
78
  selectedByField.set(field._id, [option.value]);
75
79
  applyFiltering=true
76
-
80
+
77
81
  }
78
82
  else {
79
83
  console.warn("category value not found in dropdown options");
@@ -52,6 +52,21 @@ function groupValuesByField(values, refKey) {
52
52
  return options.find(option=>option.label.toLowerCase().trim().replace(/[-\s]/g, '')===standardizedValue);
53
53
  }
54
54
 
55
+ function getOptionIndexFromCheckBox(options,value) {
56
+ console.log("options: ", options);
57
+ console.log("value: ", value);
58
+ for(let index=0;index<options.length;index++) {
59
+
60
+ console.log(`options at index ${index} is ${options[index]}`);
61
+
62
+ if(options[index].value===value) {
63
+ console.log(`found it !! at index ${index}`);
64
+ return index;
65
+ }
66
+ }
67
+ return options.findIndex(option=>option.value===value);
68
+ }
69
+
55
70
  module.exports = {
56
71
  groupValuesByField,
57
72
  debounce,
@@ -59,4 +74,5 @@ function groupValuesByField(values, refKey) {
59
74
  getFieldById,
60
75
  getFieldByTitle,
61
76
  getCorrectOption,
77
+ getOptionIndexFromCheckBox,
62
78
  }