sr-npm 1.7.617 → 1.7.619
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 +2 -106
package/package.json
CHANGED
|
@@ -66,14 +66,6 @@ async function loadJobs(_$w) {
|
|
|
66
66
|
});
|
|
67
67
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = alljobs;
|
|
68
68
|
|
|
69
|
-
// return wixData.query(COLLECTIONS.JOBS)
|
|
70
|
-
// .find()
|
|
71
|
-
// .then((res) => {
|
|
72
|
-
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = res.items;
|
|
73
|
-
// })
|
|
74
|
-
// .catch((err) => {
|
|
75
|
-
// console.error('Failed to load jobs:', err);
|
|
76
|
-
// });
|
|
77
69
|
}
|
|
78
70
|
|
|
79
71
|
async function loadFilters(_$w) {
|
|
@@ -187,14 +179,10 @@ async function loadJobs(_$w) {
|
|
|
187
179
|
value: o.value
|
|
188
180
|
};
|
|
189
181
|
});
|
|
190
|
-
console.log("base: ",base)
|
|
191
|
-
console.log("countsMap: ",countsMap)
|
|
192
|
-
console.log("withCounts: ",withCounts)
|
|
193
182
|
// Apply search
|
|
194
183
|
const filtered = searchQuery
|
|
195
184
|
? withCounts.filter(o => (o.label || '').toLowerCase().includes(searchQuery))
|
|
196
185
|
: withCounts;
|
|
197
|
-
console.log("filte@$@#@#$red: ",filtered)
|
|
198
186
|
|
|
199
187
|
// Preserve currently selected values that are still visible
|
|
200
188
|
const prevSelected = $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).value || [];
|
|
@@ -206,9 +194,6 @@ async function loadJobs(_$w) {
|
|
|
206
194
|
}
|
|
207
195
|
|
|
208
196
|
async function applyJobFilters(_$w,filterByField) {
|
|
209
|
-
console.log("applying job filters")
|
|
210
|
-
console.log("selectedByField: ",selectedByField)
|
|
211
|
-
|
|
212
197
|
let q = wixData.query(COLLECTIONS.JOBS)
|
|
213
198
|
|
|
214
199
|
// AND across categories, OR within each category
|
|
@@ -218,106 +203,29 @@ async function loadJobs(_$w) {
|
|
|
218
203
|
}
|
|
219
204
|
}
|
|
220
205
|
|
|
221
|
-
|
|
206
|
+
await q.find()
|
|
222
207
|
.then(async (res) => { _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = res.items;
|
|
223
208
|
await updateCurrentJobs(res);
|
|
224
|
-
// currentJobs=res.items.map(job=>job._id);
|
|
225
|
-
console.log("updated currentJobs adfger fucniton: ",currentJobs)
|
|
226
209
|
})
|
|
227
210
|
.catch((err) => { console.error('Failed to filter jobs:', err); });
|
|
228
211
|
}
|
|
229
212
|
|
|
230
213
|
|
|
231
|
-
async function refreshFacetCounts(_$w) {
|
|
232
|
-
// if (!valuesByFieldIdGlobal)
|
|
233
|
-
// {
|
|
234
|
-
// return;
|
|
235
|
-
// }
|
|
236
|
-
|
|
214
|
+
async function refreshFacetCounts(_$w) {
|
|
237
215
|
console.log("current countsByFieldId: ",countsByFieldId)
|
|
238
216
|
const fieldIds = Array.from(optionsByFieldId.keys());
|
|
239
217
|
for (const fieldId of fieldIds) {
|
|
240
218
|
let currentoptions=optionsByFieldId.get(fieldId)
|
|
241
|
-
//console.log("currentoptions@@@@@@@@@@@@@: ",currentoptions)
|
|
242
219
|
let counter=new Map();
|
|
243
220
|
for(const option of currentoptions) {
|
|
244
|
-
console.log("currentJobs length: ",currentJobs.length)
|
|
245
221
|
for (const jobId of currentJobs) {
|
|
246
222
|
if (valueToJobs[option.value].includes(jobId)) {
|
|
247
223
|
counter.set(option.value, (counter.get(option.value) || 0) + 1);
|
|
248
224
|
}
|
|
249
225
|
}
|
|
250
226
|
}
|
|
251
|
-
console.log("counter: ",counter)
|
|
252
|
-
console.log("fieldId: ",fieldId)
|
|
253
227
|
countsByFieldId.set(fieldId, counter);
|
|
254
228
|
}
|
|
255
|
-
console.log("new countsByFieldId: ",countsByFieldId)
|
|
256
|
-
// for (const valueId of Object.keys(valueToJobs)) {
|
|
257
|
-
// for (const jobId of currentJobs) {
|
|
258
|
-
// if (valueToJobs[valueId].includes(jobId)) {
|
|
259
|
-
// counter.set(valueId, (countsByFieldId.get(valueId) || 0) + 1);
|
|
260
|
-
// }
|
|
261
|
-
// }
|
|
262
|
-
// }
|
|
263
|
-
// }
|
|
264
|
-
// for (const valueId of Object.keys(valueToJobs)) {
|
|
265
|
-
// for (const jobId of currentJobs) {
|
|
266
|
-
// if (valueToJobs[valueId].includes(jobId)) {
|
|
267
|
-
// counter.set(valueId, (countsByFieldId.get(valueId) || 0) + 1);
|
|
268
|
-
// }
|
|
269
|
-
// }
|
|
270
|
-
// }
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
// // Run per-field queries in parallel
|
|
277
|
-
// const tasks = fieldIds.map(async (fieldId) => {
|
|
278
|
-
// // Build query with selections from all other fields
|
|
279
|
-
// let q = wixData.query(COLLECTIONS.JOBS);
|
|
280
|
-
// for (const [fid, values] of selectedByField.entries()) {
|
|
281
|
-
// if (fid !== fieldId && values && values.length) {
|
|
282
|
-
// q = q.hasSome(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES, values);
|
|
283
|
-
// }
|
|
284
|
-
// }
|
|
285
|
-
|
|
286
|
-
// // Fetch all matching jobs (paged)
|
|
287
|
-
// const jobs = await findAll(q);
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
// // Prepare a set of valid option IDs for this field
|
|
291
|
-
// const options = optionsByFieldId.get(fieldId) || [];
|
|
292
|
-
// const optionSet = new Set(options.map(o => o.value));
|
|
293
|
-
|
|
294
|
-
// // Tally counts
|
|
295
|
-
// const counts = new Map(); // valueId -> count
|
|
296
|
-
// for (const job of jobs) {
|
|
297
|
-
// const referencedfield= await wixData.queryReferenced(COLLECTIONS.JOBS, job, JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES)
|
|
298
|
-
// //console.log("referencedfield: ",referencedfield)
|
|
299
|
-
// const vals = referencedfield.items
|
|
300
|
-
// //const vals = job[JOB_VALUES_FIELD] || [];
|
|
301
|
-
// for (const val of vals) {
|
|
302
|
-
// if (optionSet.has(val._id)) {
|
|
303
|
-
// counts.set(val._id, (counts.get(val._id) || 0) + 1);
|
|
304
|
-
// }
|
|
305
|
-
// }
|
|
306
|
-
|
|
307
|
-
// }
|
|
308
|
-
|
|
309
|
-
// // Ensure every option has a count (zero if absent)
|
|
310
|
-
// for (const o of options) {
|
|
311
|
-
// if (!counts.has(o.value))
|
|
312
|
-
// {
|
|
313
|
-
// counts.set(o.value, 0);}
|
|
314
|
-
// }
|
|
315
|
-
|
|
316
|
-
// countsByFieldId.set(fieldId, counts);
|
|
317
|
-
// });
|
|
318
|
-
|
|
319
|
-
// await Promise.all(tasks);
|
|
320
|
-
|
|
321
229
|
// // After counts are ready, update all items currently rendered
|
|
322
230
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).forEachItem(($item, itemData) => {
|
|
323
231
|
const query = ($item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).value || '').toLowerCase().trim();
|
|
@@ -364,18 +272,6 @@ async function refreshFacetCounts(_$w) {
|
|
|
364
272
|
console.log("updated currentJobs inisde new function: ",currentJobs)
|
|
365
273
|
}
|
|
366
274
|
|
|
367
|
-
async function findAll(q) {
|
|
368
|
-
const out = [];
|
|
369
|
-
let res = await q.limit(1000).find();
|
|
370
|
-
out.push(...res.items);
|
|
371
|
-
while (res.hasNext()) {
|
|
372
|
-
res = await res.next();
|
|
373
|
-
out.push(...res.items);
|
|
374
|
-
}
|
|
375
|
-
return out;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
|
|
379
275
|
module.exports = {
|
|
380
276
|
careersMultiBoxesPageOnReady
|
|
381
277
|
};
|