sr-npm 3.1.23 → 3.1.25

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/backend/data.js CHANGED
@@ -463,14 +463,18 @@ function fetchJobLocation(jobDetails) {
463
463
 
464
464
  async function createCollections() {
465
465
  console.log("Creating collections");
466
+ if(siteconfig===undefined) {
467
+ await getSiteConfig();
468
+ }
469
+
466
470
  await Promise.all(
467
471
  [createCollectionIfMissing(COLLECTIONS.JOBS, COLLECTIONS_FIELDS.JOBS,{ insert: 'ADMIN', update: 'ADMIN', remove: 'ADMIN', read: 'ANYONE' }),
468
472
  createCollectionIfMissing(COLLECTIONS.CITIES, COLLECTIONS_FIELDS.CITIES),
469
473
  createCollectionIfMissing(COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT, COLLECTIONS_FIELDS.AMOUNT_OF_JOBS_PER_DEPARTMENT),
470
474
  createCollectionIfMissing(COLLECTIONS.SECRET_MANAGER_MIRROR, COLLECTIONS_FIELDS.SECRET_MANAGER_MIRROR),
471
475
  createCollectionIfMissing(COLLECTIONS.BRANDS, COLLECTIONS_FIELDS.BRANDS),
472
- createCollectionIfMissing(COLLECTIONS.CUSTOM_VALUES, COLLECTIONS_FIELDS.CUSTOM_VALUES),
473
- createCollectionIfMissing(COLLECTIONS.CUSTOM_FIELDS, COLLECTIONS_FIELDS.CUSTOM_FIELDS)
476
+ siteconfig.customFields==="true" ? createCollectionIfMissing(COLLECTIONS.CUSTOM_VALUES, COLLECTIONS_FIELDS.CUSTOM_VALUES) : null,
477
+ siteconfig.customFields==="true" ? createCollectionIfMissing(COLLECTIONS.CUSTOM_FIELDS, COLLECTIONS_FIELDS.CUSTOM_FIELDS) : null
474
478
  ]);
475
479
  console.log("finished creating Collections");
476
480
  }
@@ -528,13 +532,16 @@ async function syncJobsFast() {
528
532
 
529
533
  async function clearCollections() {
530
534
  console.log("clearing collections");
535
+ if(siteconfig===undefined) {
536
+ await getSiteConfig();
537
+ }
531
538
  await Promise.all([
532
539
  wixData.truncate(COLLECTIONS.CITIES),
533
540
  wixData.truncate(COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT),
534
541
  wixData.truncate(COLLECTIONS.JOBS),
535
542
  wixData.truncate(COLLECTIONS.BRANDS),
536
- wixData.truncate(COLLECTIONS.CUSTOM_VALUES),
537
- wixData.truncate(COLLECTIONS.CUSTOM_FIELDS),
543
+ siteconfig.customFields==="true" ? wixData.truncate(COLLECTIONS.CUSTOM_VALUES) : null,
544
+ siteconfig.customFields==="true" ? wixData.truncate(COLLECTIONS.CUSTOM_FIELDS) : null,
538
545
  ]);
539
546
  console.log("cleared collections successfully");
540
547
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "3.1.23",
3
+ "version": "3.1.25",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -37,6 +37,8 @@ let currentSecondarySearchJobs=[] // current secondary search results that are d
37
37
  let secondarySearchIsFilled=false // whether the secondary search is filled with results
38
38
  let keywordAllJobs; // all jobs that are displayed in the jobs repeater when the keyword is filled
39
39
  let ActivateURLOnchange=true; // whether to activate the url onchange
40
+ let considerAllJobs=false; // whether to consider all jobs or not
41
+
40
42
  const pagination = {
41
43
  pageSize: 10,
42
44
  currentPage: 1,
@@ -285,11 +287,16 @@ async function handleParams(_$w,param,values) {
285
287
  let fieldTitle=field.title.toLowerCase().replace(' ', '');
286
288
  fieldTitle==="brands"? fieldTitle="brand":fieldTitle;
287
289
  ActivateURLOnchange=false;
290
+ const previousSelectedSize=selectedByField.size;
288
291
  if (updated.length) {
289
292
  selectedByField.set(fieldId, updated);
293
+
294
+
290
295
  queryParams.add({ [fieldTitle] : updated.map(val=>encodeURIComponent(val)).join(',') });
291
296
  } else {
292
297
  selectedByField.delete(fieldId);
298
+ handleConsiderAllJobs(previousSelectedSize,selectedByField.size);
299
+
293
300
  queryParams.remove([fieldTitle ]);
294
301
  }
295
302
 
@@ -398,8 +405,12 @@ async function loadJobsRepeater(_$w) {
398
405
  let fieldTitle=field.title.toLowerCase().replace(' ', '');
399
406
  fieldTitle==="brands"? fieldTitle="brand":fieldTitle;
400
407
  ActivateURLOnchange=false;
408
+ const previousSelectedSize=selectedByField.size;
409
+
401
410
  if (selected && selected.length) {
402
411
  selectedByField.set(field._id, selected);
412
+
413
+
403
414
  if(fieldTitle==="brand" || fieldTitle==="storename") {
404
415
  //in this case we need the label not valueid
405
416
  const valueLabels=getValueFromValueId(selected,value);
@@ -410,7 +421,8 @@ async function loadJobsRepeater(_$w) {
410
421
  }
411
422
 
412
423
  } else {
413
- selectedByField.delete(field._id);
424
+ selectedByField.delete(field._id);
425
+ handleConsiderAllJobs(previousSelectedSize,selectedByField.size);
414
426
  queryParams.remove([fieldTitle ]);
415
427
  }
416
428
 
@@ -451,14 +463,34 @@ function getValueFromValueId(valueIds, value) {
451
463
  updateTotalJobsCountText(_$w);
452
464
  }
453
465
 
466
+ function handleConsiderAllJobs(previousSelectedSize,currentSelectedSize) {
467
+ if(previousSelectedSize===2 && currentSelectedSize===1) {
468
+
469
+ considerAllJobs=true;
470
+ }
471
+ else{
472
+ considerAllJobs=false;
473
+ }
474
+ }
475
+
454
476
  function updateOptionsUI(_$w,fieldTitle, fieldId, searchQuery,clearAll=false) {
455
477
  let base = optionsByFieldId.get(fieldId) || [];
456
- const countsMap = countsByFieldId.get(fieldId) || new Map();
478
+ let countsMap=countsByFieldId.get(fieldId) || new Map();
479
+ if(considerAllJobs)
480
+ {
481
+ const selectedFieldId=Array.from( selectedByField.keys() )[0]
482
+ if(selectedFieldId===fieldId) {
483
+ const relevantFields=allvaluesobjects.filter(val=>val.customField===selectedFieldId)
484
+ countsMap = new Map(relevantFields.map(val=>[val.valueId, val.count]));
485
+ considerAllJobs=false;
486
+ }
487
+ }
457
488
  if(dontUpdateThisCheckBox===fieldId && !clearAll && selectedByField.has(fieldId) )
458
489
  {
459
490
  dontUpdateThisCheckBox=null;
460
491
  return;
461
492
  }
493
+
462
494
  let filteredbase=[]
463
495
  for (const element of base)
464
496
  {
@@ -613,8 +645,8 @@ async function refreshFacetCounts(_$w,clearAll=false) {
613
645
 
614
646
  function countJobsPerField(jobs) {
615
647
  const fieldIds = Array.from(optionsByFieldId.keys());
648
+
616
649
  const currentJobsIds=jobs.map(job=>job._id);
617
-
618
650
  for (const fieldId of fieldIds) {
619
651
  let currentoptions = optionsByFieldId.get(fieldId)
620
652
  let counter=new Map();
@@ -78,13 +78,7 @@ function getFieldByTitle(title,allFields) {
78
78
 
79
79
  function getCorrectOption(value,options,param) {
80
80
  const standardizedValue = normalizeString(value.toLowerCase())
81
- if(param==="employmenttype" || param==="Employment Type" || param==="Store Name") //employmenttype have a problematic value, added Employment Type for updateOptionsUI fuinction, added Store Name because Store name and location have for example Blenheim
82
- {
83
- //option.value is the id,
84
- return options.find(option=>normalizeString(option.value.toLowerCase())===standardizedValue);
85
- }
86
- //option.label is what we see live in the UI
87
- return options.find(option=>normalizeString(option.label.toLowerCase())===standardizedValue);
81
+ return options.find(option=>normalizeString(option.value.toLowerCase())===standardizedValue || normalizeString(option.label.toLowerCase())===standardizedValue);
88
82
  }
89
83
 
90
84
  function getOptionIndexFromCheckBox(options,value) {