sr-npm 1.7.705 → 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 -46
- 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,8 +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);
|
|
41
|
-
|
|
44
|
+
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
|
|
@@ -80,13 +83,14 @@ async function loadSelectedValuesRepeater(_$w) {
|
|
|
80
83
|
selectedByField.delete(fieldId);
|
|
81
84
|
}
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
+
|
|
90
94
|
await updateJobsAndNumbersAndFilters(_$w);
|
|
91
95
|
});
|
|
92
96
|
});
|
|
@@ -146,47 +150,46 @@ async function loadJobsRepeater(_$w) {
|
|
|
146
150
|
counter[city.city]=city.count
|
|
147
151
|
}
|
|
148
152
|
for(const [key, value] of valuesByFieldId) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
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
|
+
}
|
|
161
164
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
optionsByFieldId.set(key, originalOptions);
|
|
166
|
+
for (const val of allvaluesobjects) {
|
|
167
|
+
counter[val.title]=val.totalJobs
|
|
168
|
+
}
|
|
166
169
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
+
});
|
|
181
184
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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);
|
|
186
189
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
+
_$w(`#${FiltersIds[field.title]}input`).onInput(runFilter);
|
|
191
|
+
|
|
192
|
+
|
|
190
193
|
}
|
|
191
194
|
await refreshFacetCounts(_$w);
|
|
192
195
|
|
|
@@ -195,6 +198,8 @@ async function loadJobsRepeater(_$w) {
|
|
|
195
198
|
}
|
|
196
199
|
}
|
|
197
200
|
|
|
201
|
+
|
|
202
|
+
|
|
198
203
|
async function updateJobsAndNumbersAndFilters(_$w) {
|
|
199
204
|
await applyJobFilters(_$w); // re-query jobs
|
|
200
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
|
}
|