sr-npm 1.7.707 → 1.7.708

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.707",
3
+ "version": "1.7.708",
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 } = require('./pagesUtils');
4
+ const { groupValuesByField, debounce, getAllRecords, getFieldById, getFieldByTitle,getCorrectOption } = require('./pagesUtils');
5
5
 
6
6
  let dontUpdateThisCheckBox;
7
7
  const selectedByField = new Map(); // fieldId -> array of selected value IDs
@@ -33,7 +33,7 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
33
33
 
34
34
  async function handleUrlParams(_$w,urlParams) {
35
35
  if(urlParams.brand) {
36
- const brandValue = decodeURIComponent(urlParams.Brand);
36
+ const brandValue = decodeURIComponent(urlParams.brand);
37
37
  console.log("brandValue: ", brandValue);
38
38
  console.log("selectedByField: ", selectedByField);
39
39
  console.log("optionsByFieldId: ", optionsByFieldId);
@@ -42,7 +42,7 @@ async function handleUrlParams(_$w,urlParams) {
42
42
  console.log("field: ", field);
43
43
  const options=optionsByFieldId.get(field._id);
44
44
  console.log("all the options: are ", options);
45
- const option=options.find(option=>option.label===brandValue);
45
+ const option=getCorrectOption(brandValue,options);
46
46
  console.log("the correctoption: ", option);
47
47
  if(option) {
48
48
  console.log("setting the value of the checkbox to: ", option.value);
@@ -45,10 +45,18 @@ function groupValuesByField(values, refKey) {
45
45
  return allFields.find(field=>field.title===title);
46
46
  }
47
47
 
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);
53
+ }
54
+
48
55
  module.exports = {
49
56
  groupValuesByField,
50
57
  debounce,
51
58
  getAllRecords,
52
59
  getFieldById,
53
60
  getFieldByTitle,
61
+ getCorrectOption,
54
62
  }