sr-npm 1.7.609 → 1.7.611
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 +69 -50
package/package.json
CHANGED
|
@@ -17,14 +17,10 @@ async function careersMultiBoxesPageOnReady(_$w) {
|
|
|
17
17
|
}
|
|
18
18
|
if(Object.keys(valueToJobs).length === 0){
|
|
19
19
|
allvaluesobjects=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
20
|
-
console.log("allvaluesobjects: ",allvaluesobjects)
|
|
21
20
|
for (const value of allvaluesobjects) {
|
|
22
|
-
console.log("value: ",value)
|
|
23
21
|
valueToJobs[value._id]= value.jobIds;
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
|
-
console.log("valueToJobs: ",valueToJobs)
|
|
27
|
-
console.log("alljobs: ",alljobs)
|
|
28
24
|
|
|
29
25
|
await loadJobs(_$w);
|
|
30
26
|
await loadFilters(_$w);
|
|
@@ -212,6 +208,7 @@ async function loadJobs(_$w) {
|
|
|
212
208
|
function applyJobFilters(_$w,filterByField) {
|
|
213
209
|
console.log("applying job filters")
|
|
214
210
|
console.log("selectedByField: ",selectedByField)
|
|
211
|
+
|
|
215
212
|
let q = wixData.query(COLLECTIONS.JOBS)
|
|
216
213
|
|
|
217
214
|
// AND across categories, OR within each category
|
|
@@ -222,21 +219,21 @@ async function loadJobs(_$w) {
|
|
|
222
219
|
}
|
|
223
220
|
|
|
224
221
|
q.find()
|
|
225
|
-
.then((res) => { _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = res.items;
|
|
226
|
-
|
|
227
|
-
|
|
222
|
+
.then((res) => { _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = res.items;
|
|
223
|
+
updateCurrentJobs(res);
|
|
224
|
+
// currentJobs=res.items.map(job=>job._id);
|
|
225
|
+
console.log("updated currentJobs adfger fucniton: ",currentJobs)
|
|
228
226
|
})
|
|
229
227
|
.catch((err) => { console.error('Failed to filter jobs:', err); });
|
|
230
228
|
}
|
|
231
229
|
|
|
232
230
|
|
|
233
231
|
async function refreshFacetCounts(_$w) {
|
|
234
|
-
if (!valuesByFieldIdGlobal)
|
|
235
|
-
{
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const fieldIds = Array.from(optionsByFieldId.keys());
|
|
232
|
+
// if (!valuesByFieldIdGlobal)
|
|
233
|
+
// {
|
|
234
|
+
// return;
|
|
235
|
+
// }
|
|
236
|
+
const counts = new Map();
|
|
240
237
|
for (const valueId of Object.keys(valueToJobs)) {
|
|
241
238
|
for (const jobId of currentJobs) {
|
|
242
239
|
if (valueToJobs[valueId].includes(jobId)) {
|
|
@@ -244,54 +241,66 @@ async function refreshFacetCounts(_$w) {
|
|
|
244
241
|
}
|
|
245
242
|
}
|
|
246
243
|
}
|
|
244
|
+
|
|
245
|
+
// const fieldIds = Array.from(optionsByFieldId.keys());
|
|
246
|
+
// for (const valueId of Object.keys(valueToJobs)) {
|
|
247
|
+
// for (const jobId of currentJobs) {
|
|
248
|
+
// if (valueToJobs[valueId].includes(jobId)) {
|
|
249
|
+
// countsByFieldId.set(valueId, (countsByFieldId.get(valueId) || 0) + 1);
|
|
250
|
+
// }
|
|
251
|
+
// }
|
|
252
|
+
// }
|
|
247
253
|
|
|
248
254
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
// // Run per-field queries in parallel
|
|
259
|
+
// const tasks = fieldIds.map(async (fieldId) => {
|
|
260
|
+
// // Build query with selections from all other fields
|
|
261
|
+
// let q = wixData.query(COLLECTIONS.JOBS);
|
|
262
|
+
// for (const [fid, values] of selectedByField.entries()) {
|
|
263
|
+
// if (fid !== fieldId && values && values.length) {
|
|
264
|
+
// q = q.hasSome(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES, values);
|
|
265
|
+
// }
|
|
266
|
+
// }
|
|
258
267
|
|
|
259
|
-
|
|
260
|
-
|
|
268
|
+
// // Fetch all matching jobs (paged)
|
|
269
|
+
// const jobs = await findAll(q);
|
|
261
270
|
|
|
262
271
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
272
|
+
// // Prepare a set of valid option IDs for this field
|
|
273
|
+
// const options = optionsByFieldId.get(fieldId) || [];
|
|
274
|
+
// const optionSet = new Set(options.map(o => o.value));
|
|
266
275
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
276
|
+
// // Tally counts
|
|
277
|
+
// const counts = new Map(); // valueId -> count
|
|
278
|
+
// for (const job of jobs) {
|
|
279
|
+
// const referencedfield= await wixData.queryReferenced(COLLECTIONS.JOBS, job, JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES)
|
|
280
|
+
// //console.log("referencedfield: ",referencedfield)
|
|
281
|
+
// const vals = referencedfield.items
|
|
282
|
+
// //const vals = job[JOB_VALUES_FIELD] || [];
|
|
283
|
+
// for (const val of vals) {
|
|
284
|
+
// if (optionSet.has(val._id)) {
|
|
285
|
+
// counts.set(val._id, (counts.get(val._id) || 0) + 1);
|
|
286
|
+
// }
|
|
287
|
+
// }
|
|
279
288
|
|
|
280
|
-
|
|
289
|
+
// }
|
|
281
290
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
291
|
+
// // Ensure every option has a count (zero if absent)
|
|
292
|
+
// for (const o of options) {
|
|
293
|
+
// if (!counts.has(o.value))
|
|
294
|
+
// {
|
|
295
|
+
// counts.set(o.value, 0);}
|
|
296
|
+
// }
|
|
288
297
|
|
|
289
|
-
|
|
290
|
-
});
|
|
298
|
+
// countsByFieldId.set(fieldId, counts);
|
|
299
|
+
// });
|
|
291
300
|
|
|
292
|
-
await Promise.all(tasks);
|
|
301
|
+
// await Promise.all(tasks);
|
|
293
302
|
|
|
294
|
-
// After counts are ready, update all items currently rendered
|
|
303
|
+
// // After counts are ready, update all items currently rendered
|
|
295
304
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).forEachItem(($item, itemData) => {
|
|
296
305
|
const query = ($item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).value || '').toLowerCase().trim();
|
|
297
306
|
updateOptionsUI($item, itemData._id, query);
|
|
@@ -325,6 +334,16 @@ async function refreshFacetCounts(_$w) {
|
|
|
325
334
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).data = selectedItems;
|
|
326
335
|
}
|
|
327
336
|
|
|
337
|
+
async function updateCurrentJobs(res) {
|
|
338
|
+
currentJobs = [];
|
|
339
|
+
currentJobs.push(...res.items.map(job=>job._id));
|
|
340
|
+
while (res.hasNext()) {
|
|
341
|
+
res = await res.next();
|
|
342
|
+
currentJobs.push(...res.items.map(job=>job._id));
|
|
343
|
+
}
|
|
344
|
+
console.log("updated currentJobs inisde new function: ",currentJobs)
|
|
345
|
+
}
|
|
346
|
+
|
|
328
347
|
async function findAll(q) {
|
|
329
348
|
const out = [];
|
|
330
349
|
let res = await q.limit(1000).find();
|