sr-npm 1.7.707 → 1.7.709
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,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
|
|
@@ -32,8 +32,9 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
async function handleUrlParams(_$w,urlParams) {
|
|
35
|
+
let applyFiltering=false;
|
|
35
36
|
if(urlParams.brand) {
|
|
36
|
-
const brandValue = decodeURIComponent(urlParams.
|
|
37
|
+
const brandValue = decodeURIComponent(urlParams.brand);
|
|
37
38
|
console.log("brandValue: ", brandValue);
|
|
38
39
|
console.log("selectedByField: ", selectedByField);
|
|
39
40
|
console.log("optionsByFieldId: ", optionsByFieldId);
|
|
@@ -42,20 +43,44 @@ async function handleUrlParams(_$w,urlParams) {
|
|
|
42
43
|
console.log("field: ", field);
|
|
43
44
|
const options=optionsByFieldId.get(field._id);
|
|
44
45
|
console.log("all the options: are ", options);
|
|
45
|
-
const option=
|
|
46
|
+
const option=getCorrectOption(brandValue,options);
|
|
46
47
|
console.log("the correctoption: ", option);
|
|
47
48
|
if(option) {
|
|
48
49
|
console.log("setting the value of the checkbox to: ", option.value);
|
|
49
50
|
|
|
50
51
|
_$w(`#${FiltersIds[field.title]}CheckBox`).value = [option.value];
|
|
51
52
|
selectedByField.set(field._id, [option.value]);
|
|
52
|
-
|
|
53
|
+
applyFiltering=true;
|
|
53
54
|
}
|
|
54
55
|
else {
|
|
55
56
|
console.warn("brand value not found in dropdown options");
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
}
|
|
59
|
+
if(urlParams.category) {
|
|
60
|
+
const categoryValue = decodeURIComponent(urlParams.category);
|
|
61
|
+
console.log("categoryValue: ", categoryValue);
|
|
62
|
+
console.log("selectedByField: ", selectedByField);
|
|
63
|
+
console.log("optionsByFieldId: ", optionsByFieldId);
|
|
64
|
+
console.log("allfields: ", allfields);
|
|
65
|
+
const field=getFieldByTitle(fieldTitlesInCMS.category,allfields);
|
|
66
|
+
console.log("field: ", field);
|
|
67
|
+
const options=optionsByFieldId.get(field._id);
|
|
68
|
+
console.log("all the options: are ", options);
|
|
69
|
+
const option=getCorrectOption(categoryValue,options);
|
|
70
|
+
console.log("the correctoption: ", option);
|
|
71
|
+
if(option) {
|
|
72
|
+
console.log("setting the value of the checkbox to: ", option.value);
|
|
73
|
+
_$w(`#${FiltersIds[field.title]}CheckBox`).value = [option.value];
|
|
74
|
+
selectedByField.set(field._id, [option.value]);
|
|
75
|
+
applyFiltering=true
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
console.warn("category value not found in dropdown options");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if(applyFiltering) {
|
|
83
|
+
await updateJobsAndNumbersAndFilters(_$w);
|
|
59
84
|
}
|
|
60
85
|
}
|
|
61
86
|
|
|
@@ -185,6 +210,7 @@ async function loadJobsRepeater(_$w) {
|
|
|
185
210
|
updateOptionsUI(_$w,field.title, field._id, ''); // no search query
|
|
186
211
|
_$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = []; // start empty
|
|
187
212
|
_$w(`#${FiltersIds[field.title]}CheckBox`).onChange(async (ev) => {
|
|
213
|
+
console.log(`#${FiltersIds[field.title]}CheckBox.selectedIndices: `, _$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices);
|
|
188
214
|
dontUpdateThisCheckBox=field._id;
|
|
189
215
|
const selected = ev.target.value; // array of selected value IDs
|
|
190
216
|
if (selected && selected.length) {
|
package/pages/pagesUtils.js
CHANGED
|
@@ -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
|
}
|