sr-npm 1.7.641 → 1.7.642
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
|
@@ -9,12 +9,14 @@ const optionsByFieldId = new Map(); // fieldId -> [{label, value}] array of obje
|
|
|
9
9
|
const countsByFieldId = new Map(); // fieldId -> {valueId: count} map of counts for each valueId
|
|
10
10
|
let alljobs=[] // all jobs in the database
|
|
11
11
|
let allvaluesobjects=[] // all values in the database
|
|
12
|
-
let valueToJobs={} // valueId -> array of
|
|
12
|
+
let valueToJobs={} // valueId -> array of jobIds
|
|
13
|
+
let currentJobsIds=[] // current jobs that are displayed in the jobs repeater
|
|
13
14
|
let currentJobs=[] // current jobs that are displayed in the jobs repeater
|
|
14
15
|
async function careersMultiBoxesPageOnReady(_$w) {
|
|
15
16
|
if(alljobs.length===0) {
|
|
16
17
|
alljobs=await getAllRecords(COLLECTIONS.JOBS);
|
|
17
|
-
|
|
18
|
+
currentJobsIds=alljobs.map(job=>job._id);
|
|
19
|
+
currentJobs=alljobs;
|
|
18
20
|
console.log("alljobs: ",alljobs)
|
|
19
21
|
}
|
|
20
22
|
if(Object.keys(valueToJobs).length === 0){
|
|
@@ -76,7 +78,7 @@ async function loadJobs(_$w) {
|
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
function updateTotalJobsCountText(_$w) {
|
|
79
|
-
_$w('#totalJobsCountText').text = `${
|
|
81
|
+
_$w('#totalJobsCountText').text = `${currentJobsIds.length} Jobs`;
|
|
80
82
|
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -224,13 +226,31 @@ async function loadJobs(_$w) {
|
|
|
224
226
|
|
|
225
227
|
async function applyJobFilters(_$w,filterByField) {
|
|
226
228
|
let q = wixData.query(COLLECTIONS.JOBS)
|
|
229
|
+
console.log(currentJobs)
|
|
230
|
+
let newFilteredJobs=[]
|
|
231
|
+
let alreadyAddedJobs=[]
|
|
232
|
+
console.log(selectedByField)
|
|
227
233
|
|
|
228
234
|
// AND across categories, OR within each category
|
|
229
235
|
for (const [, values] of selectedByField.entries()) {
|
|
236
|
+
console.log(values)
|
|
237
|
+
for(job of currentJobs) {
|
|
238
|
+
if(job[filterByField].some(value=>values.includes(value))) {
|
|
239
|
+
|
|
240
|
+
if(!alreadyAddedJobs.includes(job._id)) {
|
|
241
|
+
newFilteredJobs.push(job);
|
|
242
|
+
alreadyAddedJobs.push(job._id);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
230
247
|
if (values && values.length) {
|
|
248
|
+
|
|
231
249
|
q = q.hasSome(filterByField, values);
|
|
250
|
+
|
|
232
251
|
}
|
|
233
252
|
}
|
|
253
|
+
console.log(newFilteredJobs)
|
|
234
254
|
|
|
235
255
|
await q.find()
|
|
236
256
|
.then(async (res) => { _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = res.items;
|
|
@@ -246,7 +266,7 @@ async function refreshFacetCounts(_$w) {
|
|
|
246
266
|
let currentoptions=optionsByFieldId.get(fieldId)
|
|
247
267
|
let counter=new Map();
|
|
248
268
|
for(const option of currentoptions) {
|
|
249
|
-
for (const jobId of
|
|
269
|
+
for (const jobId of currentJobsIds) {
|
|
250
270
|
if (valueToJobs[option.value].includes(jobId)) {
|
|
251
271
|
counter.set(option.value, (counter.get(option.value) || 0) + 1);
|
|
252
272
|
}
|
|
@@ -292,7 +312,7 @@ async function refreshFacetCounts(_$w) {
|
|
|
292
312
|
res = await res.next();
|
|
293
313
|
newcurrentJobs.push(...res.items.map(job=>job._id));
|
|
294
314
|
}
|
|
295
|
-
|
|
315
|
+
currentJobsIds = newcurrentJobs;
|
|
296
316
|
}
|
|
297
317
|
|
|
298
318
|
module.exports = {
|