sr-npm 1.7.650 → 1.7.652
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 +33 -47
package/package.json
CHANGED
|
@@ -10,12 +10,10 @@ const countsByFieldId = new Map(); // fieldId -> {valueId: count} map of counts
|
|
|
10
10
|
let alljobs=[] // all jobs in the database
|
|
11
11
|
let allvaluesobjects=[] // all values in the database
|
|
12
12
|
let valueToJobs={} // valueId -> array of jobIds
|
|
13
|
-
//let currentJobsIds=[] // current jobs that are displayed in the jobs repeater
|
|
14
13
|
let currentJobs=[] // current jobs that are displayed in the jobs repeater
|
|
15
14
|
async function careersMultiBoxesPageOnReady(_$w) {
|
|
16
15
|
if(alljobs.length===0) {
|
|
17
16
|
alljobs=await getAllRecords(COLLECTIONS.JOBS);
|
|
18
|
-
// currentJobsIds=alljobs.map(job=>job._id);
|
|
19
17
|
currentJobs=alljobs;
|
|
20
18
|
console.log("alljobs: ",alljobs)
|
|
21
19
|
}
|
|
@@ -58,7 +56,7 @@ async function careersMultiBoxesPageOnReady(_$w) {
|
|
|
58
56
|
}
|
|
59
57
|
});
|
|
60
58
|
|
|
61
|
-
await applyJobFilters(_$w,
|
|
59
|
+
await applyJobFilters(_$w,fieldId);
|
|
62
60
|
await refreshFacetCounts(_$w);
|
|
63
61
|
await updateSelectedValuesRepeater(_$w);
|
|
64
62
|
updateTotalJobsCountText(_$w);
|
|
@@ -93,7 +91,10 @@ async function loadJobs(_$w) {
|
|
|
93
91
|
console.log("cities: ",cities)
|
|
94
92
|
// 2) Load all values once and group them by referenced field
|
|
95
93
|
|
|
96
|
-
|
|
94
|
+
let valuesByFieldId = groupValuesByField(allvaluesobjects, CUSTOM_VALUES_COLLECTION_FIELDS.CUSTOM_FIELD);
|
|
95
|
+
console.log("valuesByFieldId: ",valuesByFieldId)
|
|
96
|
+
valuesByFieldId["Location"]=cities
|
|
97
|
+
console.log("valuesByFieldId after addubg cities: ",valuesByFieldId)
|
|
97
98
|
valuesByFieldIdGlobal = valuesByFieldId; // store globally
|
|
98
99
|
|
|
99
100
|
|
|
@@ -109,23 +110,36 @@ async function loadJobs(_$w) {
|
|
|
109
110
|
|
|
110
111
|
// if(fieldId==="Location") {
|
|
111
112
|
// $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).options = cities.map(city=>({
|
|
112
|
-
// label: city.
|
|
113
|
+
// label: city.city,
|
|
113
114
|
// value: city._id
|
|
114
115
|
// }));
|
|
115
116
|
// }
|
|
116
117
|
|
|
117
118
|
// Build CheckboxGroup options for this field
|
|
118
119
|
const fieldValues = valuesByFieldId.get(fieldId) || [];
|
|
119
|
-
|
|
120
|
+
console.log("fieldValues: ",fieldValues)
|
|
121
|
+
let originalOptions=[];
|
|
122
|
+
if(fieldId==="Location") {
|
|
123
|
+
originalOptions=fieldValues.map(city=>({
|
|
124
|
+
label: city.city,
|
|
125
|
+
value: city._id
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
else{
|
|
129
|
+
originalOptions = fieldValues.map(v => ({
|
|
120
130
|
label: v.title ,
|
|
121
131
|
value: v._id
|
|
122
132
|
}));
|
|
133
|
+
}
|
|
123
134
|
optionsByFieldId.set(fieldId, originalOptions);
|
|
124
135
|
const counter={}
|
|
125
136
|
|
|
126
137
|
for (const val of allvaluesobjects) {
|
|
127
138
|
counter[val.title]=val.totalJobs
|
|
128
139
|
}
|
|
140
|
+
for(const city of cities) {
|
|
141
|
+
counter[city.city]=city.count
|
|
142
|
+
}
|
|
129
143
|
|
|
130
144
|
countsByFieldId.set(fieldId, new Map(originalOptions.map(o => [o.value, counter[o.label]])));
|
|
131
145
|
|
|
@@ -141,7 +155,7 @@ async function loadJobs(_$w) {
|
|
|
141
155
|
} else {
|
|
142
156
|
selectedByField.delete(fieldId);
|
|
143
157
|
}
|
|
144
|
-
await applyJobFilters(_$w,
|
|
158
|
+
await applyJobFilters(_$w,fieldId); // re-query jobs
|
|
145
159
|
await refreshFacetCounts(_$w); // recompute and update counts in all lists
|
|
146
160
|
await updateSelectedValuesRepeater(_$w);
|
|
147
161
|
updateTotalJobsCountText(_$w);
|
|
@@ -232,49 +246,31 @@ async function loadJobs(_$w) {
|
|
|
232
246
|
}
|
|
233
247
|
|
|
234
248
|
async function applyJobFilters(_$w,filterByField) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
let newFilteredJobs=[];
|
|
238
|
-
let currentAllJobs=alljobs;
|
|
249
|
+
let tempFilteredJobs=[];
|
|
250
|
+
let finalFilteredJobs=alljobs;
|
|
239
251
|
let addedJobsIds=[]
|
|
240
|
-
|
|
252
|
+
if(filterByField!="Location") {
|
|
253
|
+
filterByField=JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES;
|
|
254
|
+
}
|
|
241
255
|
|
|
242
256
|
// AND across categories, OR within each category
|
|
243
257
|
for (const [, values] of selectedByField.entries()) {
|
|
244
|
-
|
|
245
|
-
for(job of currentAllJobs) {
|
|
246
|
-
//console.log("job: ",job)
|
|
247
|
-
console.log("job[filterByField]: ",job[filterByField])
|
|
248
|
-
// console.log("job[filterByField].some(value=>values.includes(value))) ",job[filterByField].some(value=>values.includes(value._id)))
|
|
258
|
+
for(job of finalFilteredJobs) {
|
|
249
259
|
if(job[filterByField].some(value=>values.includes(value._id))) {
|
|
250
|
-
// console.log("!alreadyAddedJobs.includes(job._id) ",!alreadyAddedJobs.includes(job._id))
|
|
251
260
|
if(!addedJobsIds.includes(job._id)) {
|
|
252
|
-
|
|
261
|
+
tempFilteredJobs.push(job);
|
|
253
262
|
addedJobsIds.push(job._id);
|
|
254
263
|
}
|
|
255
264
|
}
|
|
256
265
|
}
|
|
257
266
|
addedJobsIds=[]
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
// if (values && values.length) {
|
|
261
|
-
|
|
262
|
-
// q = q.hasSome(filterByField, values);
|
|
263
|
-
|
|
264
|
-
// }
|
|
267
|
+
finalFilteredJobs=tempFilteredJobs;
|
|
268
|
+
tempFilteredJobs=[];
|
|
265
269
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
currentJobs=currentAllJobs;
|
|
270
|
-
// currentJobsIds=addedJobsIds;
|
|
271
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = currentAllJobs;
|
|
270
|
+
|
|
271
|
+
currentJobs=finalFilteredJobs;
|
|
272
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = currentJobs;
|
|
272
273
|
|
|
273
|
-
// await q.find()
|
|
274
|
-
// .then(async (res) => { _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = res.items;
|
|
275
|
-
// await updateCurrentJobs(res);
|
|
276
|
-
// })
|
|
277
|
-
// .catch((err) => { console.error('Failed to filter jobs:', err); });
|
|
278
274
|
}
|
|
279
275
|
|
|
280
276
|
|
|
@@ -324,16 +320,6 @@ async function refreshFacetCounts(_$w) {
|
|
|
324
320
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).data = selectedItems;
|
|
325
321
|
}
|
|
326
322
|
|
|
327
|
-
async function updateCurrentJobs(res) {
|
|
328
|
-
let newcurrentJobs = [];
|
|
329
|
-
newcurrentJobs.push(...res.items.map(job=>job._id));
|
|
330
|
-
while (res.hasNext()) {
|
|
331
|
-
res = await res.next();
|
|
332
|
-
newcurrentJobs.push(...res.items.map(job=>job._id));
|
|
333
|
-
}
|
|
334
|
-
currentJobs = newcurrentJobs;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
323
|
module.exports = {
|
|
338
324
|
careersMultiBoxesPageOnReady
|
|
339
325
|
};
|