sr-npm 1.7.649 → 1.7.651
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 +20 -49
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);
|
|
@@ -107,12 +105,12 @@ async function loadJobs(_$w) {
|
|
|
107
105
|
// Set the filter label (category name)
|
|
108
106
|
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).placeholder = itemData.title
|
|
109
107
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
if(fieldId==="Location") {
|
|
109
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).options = cities.map(city=>({
|
|
110
|
+
label: city.city,
|
|
111
|
+
value: city._id
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
116
114
|
|
|
117
115
|
// Build CheckboxGroup options for this field
|
|
118
116
|
const fieldValues = valuesByFieldId.get(fieldId) || [];
|
|
@@ -141,7 +139,7 @@ async function loadJobs(_$w) {
|
|
|
141
139
|
} else {
|
|
142
140
|
selectedByField.delete(fieldId);
|
|
143
141
|
}
|
|
144
|
-
await applyJobFilters(_$w,
|
|
142
|
+
await applyJobFilters(_$w,fieldId); // re-query jobs
|
|
145
143
|
await refreshFacetCounts(_$w); // recompute and update counts in all lists
|
|
146
144
|
await updateSelectedValuesRepeater(_$w);
|
|
147
145
|
updateTotalJobsCountText(_$w);
|
|
@@ -232,48 +230,31 @@ async function loadJobs(_$w) {
|
|
|
232
230
|
}
|
|
233
231
|
|
|
234
232
|
async function applyJobFilters(_$w,filterByField) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
let newFilteredJobs=[];
|
|
238
|
-
let currentAllJobs=alljobs;
|
|
233
|
+
let tempFilteredJobs=[];
|
|
234
|
+
let finalFilteredJobs=alljobs;
|
|
239
235
|
let addedJobsIds=[]
|
|
240
|
-
|
|
236
|
+
if(filterByField!="Location") {
|
|
237
|
+
filterByField=JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES;
|
|
238
|
+
}
|
|
241
239
|
|
|
242
240
|
// AND across categories, OR within each category
|
|
243
241
|
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)))
|
|
242
|
+
for(job of finalFilteredJobs) {
|
|
249
243
|
if(job[filterByField].some(value=>values.includes(value._id))) {
|
|
250
|
-
// console.log("!alreadyAddedJobs.includes(job._id) ",!alreadyAddedJobs.includes(job._id))
|
|
251
244
|
if(!addedJobsIds.includes(job._id)) {
|
|
252
|
-
|
|
245
|
+
tempFilteredJobs.push(job);
|
|
253
246
|
addedJobsIds.push(job._id);
|
|
254
247
|
}
|
|
255
248
|
}
|
|
256
249
|
}
|
|
257
250
|
addedJobsIds=[]
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
// if (values && values.length) {
|
|
261
|
-
|
|
262
|
-
// q = q.hasSome(filterByField, values);
|
|
263
|
-
|
|
264
|
-
// }
|
|
251
|
+
finalFilteredJobs=tempFilteredJobs;
|
|
252
|
+
tempFilteredJobs=[];
|
|
265
253
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
currentJobs
|
|
269
|
-
// currentJobsIds=addedJobsIds;
|
|
270
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = newFilteredJobs;
|
|
254
|
+
|
|
255
|
+
currentJobs=finalFilteredJobs;
|
|
256
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = currentJobs;
|
|
271
257
|
|
|
272
|
-
// await q.find()
|
|
273
|
-
// .then(async (res) => { _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = res.items;
|
|
274
|
-
// await updateCurrentJobs(res);
|
|
275
|
-
// })
|
|
276
|
-
// .catch((err) => { console.error('Failed to filter jobs:', err); });
|
|
277
258
|
}
|
|
278
259
|
|
|
279
260
|
|
|
@@ -323,16 +304,6 @@ async function refreshFacetCounts(_$w) {
|
|
|
323
304
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).data = selectedItems;
|
|
324
305
|
}
|
|
325
306
|
|
|
326
|
-
async function updateCurrentJobs(res) {
|
|
327
|
-
let newcurrentJobs = [];
|
|
328
|
-
newcurrentJobs.push(...res.items.map(job=>job._id));
|
|
329
|
-
while (res.hasNext()) {
|
|
330
|
-
res = await res.next();
|
|
331
|
-
newcurrentJobs.push(...res.items.map(job=>job._id));
|
|
332
|
-
}
|
|
333
|
-
currentJobs = newcurrentJobs;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
307
|
module.exports = {
|
|
337
308
|
careersMultiBoxesPageOnReady
|
|
338
309
|
};
|