sr-npm 1.7.706 → 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.
@@ -18,6 +18,11 @@ const CAREERS_MULTI_BOXES_PAGE_CONSTS={
18
18
  paginationTotalCountText: '#paginationTotalCount',
19
19
  }
20
20
 
21
+ const fieldTitlesInCMS={
22
+ "brand": "Brands",
23
+ category: "Category",
24
+ }
25
+
21
26
  const FiltersIds={
22
27
  Category: 'Category',
23
28
  "Company Segment": 'CompanySegment',
@@ -32,4 +37,5 @@ const FiltersIds={
32
37
  module.exports = {
33
38
  CAREERS_MULTI_BOXES_PAGE_CONSTS,
34
39
  FiltersIds,
40
+ fieldTitlesInCMS
35
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.706",
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
- const {CAREERS_MULTI_BOXES_PAGE_CONSTS,FiltersIds} = require('../backend/careersMultiBoxesPageIds');
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,14 +33,28 @@ 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);
40
40
  console.log("allfields: ", allfields);
41
- const field=getFieldByTitle("brand",allfields);
41
+ const field=getFieldByTitle(fieldTitlesInCMS.brand,allfields);
42
42
  console.log("field: ", field);
43
- //await updateJobsAndNumbersAndFilters(_$w);
43
+ const options=optionsByFieldId.get(field._id);
44
+ console.log("all the options: are ", options);
45
+ const option=getCorrectOption(brandValue,options);
46
+ console.log("the correctoption: ", option);
47
+ if(option) {
48
+ console.log("setting the value of the checkbox to: ", option.value);
49
+
50
+ _$w(`#${FiltersIds[field.title]}CheckBox`).value = [option.value];
51
+ selectedByField.set(field._id, [option.value]);
52
+ await updateJobsAndNumbersAndFilters(_$w);
53
+ }
54
+ else {
55
+ console.warn("brand value not found in dropdown options");
56
+ }
57
+
44
58
 
45
59
  }
46
60
  }
@@ -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
  }