sr-npm 1.7.641 → 1.7.643
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
|
|
|
@@ -104,6 +106,13 @@ async function loadJobs(_$w) {
|
|
|
104
106
|
|
|
105
107
|
// Set the filter label (category name)
|
|
106
108
|
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).placeholder = itemData.title
|
|
109
|
+
|
|
110
|
+
// if(fieldId==="Location") {
|
|
111
|
+
// $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).options = cities.map(city=>({
|
|
112
|
+
// label: city.title,
|
|
113
|
+
// value: city._id
|
|
114
|
+
// }));
|
|
115
|
+
// }
|
|
107
116
|
|
|
108
117
|
// Build CheckboxGroup options for this field
|
|
109
118
|
const fieldValues = valuesByFieldId.get(fieldId) || [];
|
|
@@ -224,13 +233,35 @@ async function loadJobs(_$w) {
|
|
|
224
233
|
|
|
225
234
|
async function applyJobFilters(_$w,filterByField) {
|
|
226
235
|
let q = wixData.query(COLLECTIONS.JOBS)
|
|
236
|
+
console.log(currentJobs)
|
|
237
|
+
let newFilteredJobs=[]
|
|
238
|
+
let alreadyAddedJobs=[]
|
|
239
|
+
console.log("selectedByField: ",selectedByField)
|
|
227
240
|
|
|
228
241
|
// AND across categories, OR within each category
|
|
229
242
|
for (const [, values] of selectedByField.entries()) {
|
|
243
|
+
console.log("values: ",values)
|
|
244
|
+
for(job of currentJobs) {
|
|
245
|
+
console.log("job: ",job)
|
|
246
|
+
console.log("job[filterByField]: ",job[filterByField])
|
|
247
|
+
console.log("job[filterByField].some(value=>values.includes(value))) ",job[filterByField].some(value=>values.includes(value))))
|
|
248
|
+
if(job[filterByField].some(value=>values.includes(value))) {
|
|
249
|
+
console.log("!alreadyAddedJobs.includes(job._id) ",!alreadyAddedJobs.includes(job._id))
|
|
250
|
+
if(!alreadyAddedJobs.includes(job._id)) {
|
|
251
|
+
newFilteredJobs.push(job);
|
|
252
|
+
alreadyAddedJobs.push(job._id);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
230
257
|
if (values && values.length) {
|
|
258
|
+
|
|
231
259
|
q = q.hasSome(filterByField, values);
|
|
260
|
+
|
|
232
261
|
}
|
|
233
262
|
}
|
|
263
|
+
console.log("alreadyAddedJobs: ",alreadyAddedJobs)
|
|
264
|
+
console.log("newFilteredJobs: ",newFilteredJobs)
|
|
234
265
|
|
|
235
266
|
await q.find()
|
|
236
267
|
.then(async (res) => { _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = res.items;
|
|
@@ -246,7 +277,7 @@ async function refreshFacetCounts(_$w) {
|
|
|
246
277
|
let currentoptions=optionsByFieldId.get(fieldId)
|
|
247
278
|
let counter=new Map();
|
|
248
279
|
for(const option of currentoptions) {
|
|
249
|
-
for (const jobId of
|
|
280
|
+
for (const jobId of currentJobsIds) {
|
|
250
281
|
if (valueToJobs[option.value].includes(jobId)) {
|
|
251
282
|
counter.set(option.value, (counter.get(option.value) || 0) + 1);
|
|
252
283
|
}
|
|
@@ -292,7 +323,7 @@ async function refreshFacetCounts(_$w) {
|
|
|
292
323
|
res = await res.next();
|
|
293
324
|
newcurrentJobs.push(...res.items.map(job=>job._id));
|
|
294
325
|
}
|
|
295
|
-
|
|
326
|
+
currentJobsIds = newcurrentJobs;
|
|
296
327
|
}
|
|
297
328
|
|
|
298
329
|
module.exports = {
|