sr-npm 1.7.704 → 1.7.706
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 +1 -1
- package/pages/careersMultiBoxesPage.js +51 -45
- package/pages/pagesUtils.js +10 -0
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} = require('../backend/careersMultiBoxesPageIds');
|
|
3
3
|
const { query,queryParams,onChange} = require("wix-location-frontend");
|
|
4
|
-
const { groupValuesByField, debounce, getAllRecords } = require('./pagesUtils');
|
|
4
|
+
const { groupValuesByField, debounce, getAllRecords, getFieldById, getFieldByTitle } = require('./pagesUtils');
|
|
5
5
|
|
|
6
6
|
let dontUpdateThisCheckBox;
|
|
7
7
|
const selectedByField = new Map(); // fieldId -> array of selected value IDs
|
|
@@ -37,7 +37,11 @@ async function handleUrlParams(_$w,urlParams) {
|
|
|
37
37
|
console.log("brandValue: ", brandValue);
|
|
38
38
|
console.log("selectedByField: ", selectedByField);
|
|
39
39
|
console.log("optionsByFieldId: ", optionsByFieldId);
|
|
40
|
+
console.log("allfields: ", allfields);
|
|
41
|
+
const field=getFieldByTitle("brand",allfields);
|
|
42
|
+
console.log("field: ", field);
|
|
40
43
|
//await updateJobsAndNumbersAndFilters(_$w);
|
|
44
|
+
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
|
|
@@ -79,13 +83,14 @@ async function loadSelectedValuesRepeater(_$w) {
|
|
|
79
83
|
selectedByField.delete(fieldId);
|
|
80
84
|
}
|
|
81
85
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
const field=getFieldById(fieldId,allfields);
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
const currentVals = _$w(`#${FiltersIds[field.title]}CheckBox`).value || [];
|
|
90
|
+
const nextVals = currentVals.filter(v => v !== valueId);
|
|
91
|
+
_$w(`#${FiltersIds[field.title]}CheckBox`).value = nextVals;
|
|
92
|
+
|
|
93
|
+
|
|
89
94
|
await updateJobsAndNumbersAndFilters(_$w);
|
|
90
95
|
});
|
|
91
96
|
});
|
|
@@ -145,47 +150,46 @@ async function loadJobsRepeater(_$w) {
|
|
|
145
150
|
counter[city.city]=city.count
|
|
146
151
|
}
|
|
147
152
|
for(const [key, value] of valuesByFieldId) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
153
|
+
const field=getFieldById(key,allfields);
|
|
154
|
+
let originalOptions=[];
|
|
155
|
+
if(key==="Location") {
|
|
156
|
+
originalOptions=value.map(city=>({
|
|
157
|
+
label: city.city,
|
|
158
|
+
value: city._id
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
else{
|
|
162
|
+
originalOptions=value
|
|
163
|
+
}
|
|
160
164
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
+
optionsByFieldId.set(key, originalOptions);
|
|
166
|
+
for (const val of allvaluesobjects) {
|
|
167
|
+
counter[val.title]=val.totalJobs
|
|
168
|
+
}
|
|
165
169
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
170
|
+
countsByFieldId.set(key, new Map(originalOptions.map(o => [o.value, counter[o.label]])));
|
|
171
|
+
updateOptionsUI(_$w,field.title, field._id, ''); // no search query
|
|
172
|
+
_$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = []; // start empty
|
|
173
|
+
_$w(`#${FiltersIds[field.title]}CheckBox`).onChange(async (ev) => {
|
|
174
|
+
dontUpdateThisCheckBox=field._id;
|
|
175
|
+
const selected = ev.target.value; // array of selected value IDs
|
|
176
|
+
if (selected && selected.length) {
|
|
177
|
+
selectedByField.set(field._id, selected);
|
|
178
|
+
} else {
|
|
179
|
+
selectedByField.delete(field._id);
|
|
180
|
+
}
|
|
181
|
+
await updateJobsAndNumbersAndFilters(_$w);
|
|
182
|
+
|
|
183
|
+
});
|
|
180
184
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
+
const runFilter = debounce(() => {
|
|
186
|
+
const query = (_$w(`#${FiltersIds[field.title]}input`).value || '').toLowerCase().trim();
|
|
187
|
+
updateOptionsUI(_$w, field.title, field._id, query);
|
|
188
|
+
}, 150);
|
|
185
189
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
190
|
+
_$w(`#${FiltersIds[field.title]}input`).onInput(runFilter);
|
|
191
|
+
|
|
192
|
+
|
|
189
193
|
}
|
|
190
194
|
await refreshFacetCounts(_$w);
|
|
191
195
|
|
|
@@ -194,6 +198,8 @@ async function loadJobsRepeater(_$w) {
|
|
|
194
198
|
}
|
|
195
199
|
}
|
|
196
200
|
|
|
201
|
+
|
|
202
|
+
|
|
197
203
|
async function updateJobsAndNumbersAndFilters(_$w) {
|
|
198
204
|
await applyJobFilters(_$w); // re-query jobs
|
|
199
205
|
await refreshFacetCounts(_$w); // recompute and update counts in all lists
|
package/pages/pagesUtils.js
CHANGED
|
@@ -37,8 +37,18 @@ function groupValuesByField(values, refKey) {
|
|
|
37
37
|
return items;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
function getFieldById(fieldId,allFields) {
|
|
41
|
+
return allFields.find(field=>field._id===fieldId);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function getFieldByTitle(title,allFields) {
|
|
45
|
+
return allFields.find(field=>field.title===title);
|
|
46
|
+
}
|
|
47
|
+
|
|
40
48
|
module.exports = {
|
|
41
49
|
groupValuesByField,
|
|
42
50
|
debounce,
|
|
43
51
|
getAllRecords,
|
|
52
|
+
getFieldById,
|
|
53
|
+
getFieldByTitle,
|
|
44
54
|
}
|