sr-npm 1.7.737 → 1.7.738

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.738",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -360,10 +360,39 @@ 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) {
365
394
  const fieldIds = Array.from(optionsByFieldId.keys());
366
- const currentJobsIds=currentJobs.map(job=>job._id);
395
+ const currentJobsIds=jobs.map(job=>job._id);
367
396
  for (const fieldId of fieldIds) {
368
397
  let currentoptions=optionsByFieldId.get(fieldId)
369
398
  let counter=new Map();
@@ -376,16 +405,7 @@ async function refreshFacetCounts(_$w,clearAll=false) {
376
405
  }
377
406
  countsByFieldId.set(fieldId, counter);
378
407
  }
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
- }
387
408
  }
388
-
389
409
 
390
410
 
391
411
  function updateSelectedValuesRepeater(_$w) {
@@ -426,7 +446,7 @@ async function secondarySearch(_$w,query) {
426
446
  }
427
447
  handlePaginationButtons(_$w,true);
428
448
  updateTotalJobsCountText(_$w,true);
429
- await refreshFacetCounts(_$w);
449
+ await refreshFacetCounts(_$w,true);
430
450
  return secondarySearchJobs;
431
451
  }
432
452
  async function bindSearchInput(_$w) {