sr-npm 1.7.737 → 1.7.739

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.737",
3
+ "version": "1.7.739",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -360,10 +360,40 @@ function handlePageUrlParam() {
360
360
  }
361
361
 
362
362
  }
363
- async function refreshFacetCounts(_$w,clearAll=false) {
363
+ async function refreshFacetCounts(_$w,clearAll=false,secondarySearch=false) {
364
364
  console.log("refreshing facet counts");
365
+
366
+
367
+ secondarySearch? countJobsPerField(secondarySearchJobs):countJobsPerField(currentJobs);
368
+ // const fieldIds = Array.from(optionsByFieldId.keys());
369
+ // const currentJobsIds=currentJobs.map(job=>job._id);
370
+ // for (const fieldId of fieldIds) {
371
+ // let currentoptions=optionsByFieldId.get(fieldId)
372
+ // let counter=new Map();
373
+ // for(const option of currentoptions) {
374
+ // for (const jobId of currentJobsIds) {
375
+ // if (valueToJobs[option.value].includes(jobId)) {
376
+ // counter.set(option.value, (counter.get(option.value) || 0) + 1);
377
+ // }
378
+ // }
379
+ // }
380
+ // countsByFieldId.set(fieldId, counter);
381
+ // }
382
+
383
+ console.log("countsByFieldId: ", countsByFieldId);
384
+
385
+ for(const field of allfields) {
386
+ const query = (_$w(`#${FiltersIds[field.title]}input`).value || '').toLowerCase().trim();
387
+ clearAll? updateOptionsUI(_$w,field.title, field._id, '',true):updateOptionsUI(_$w,field.title, field._id, query);
388
+ // no search query
389
+ }
390
+ }
391
+
392
+
393
+ function countJobsPerField(jobs) {
394
+ console.log("counting jobs per field for jobs: ", jobs);
365
395
  const fieldIds = Array.from(optionsByFieldId.keys());
366
- const currentJobsIds=currentJobs.map(job=>job._id);
396
+ const currentJobsIds=jobs.map(job=>job._id);
367
397
  for (const fieldId of fieldIds) {
368
398
  let currentoptions=optionsByFieldId.get(fieldId)
369
399
  let counter=new Map();
@@ -376,16 +406,8 @@ async function refreshFacetCounts(_$w,clearAll=false) {
376
406
  }
377
407
  countsByFieldId.set(fieldId, counter);
378
408
  }
379
-
380
- console.log("countsByFieldId: ", countsByFieldId);
381
-
382
- for(const field of allfields) {
383
- const query = (_$w(`#${FiltersIds[field.title]}input`).value || '').toLowerCase().trim();
384
- clearAll? updateOptionsUI(_$w,field.title, field._id, '',true):updateOptionsUI(_$w,field.title, field._id, query);
385
- // no search query
386
- }
409
+ console.log("countsByFieldId inside countJobsPerField: ", countsByFieldId);
387
410
  }
388
-
389
411
 
390
412
 
391
413
  function updateSelectedValuesRepeater(_$w) {
@@ -426,7 +448,7 @@ async function secondarySearch(_$w,query) {
426
448
  }
427
449
  handlePaginationButtons(_$w,true);
428
450
  updateTotalJobsCountText(_$w,true);
429
- await refreshFacetCounts(_$w);
451
+ await refreshFacetCounts(_$w,true);
430
452
  return secondarySearchJobs;
431
453
  }
432
454
  async function bindSearchInput(_$w) {