sr-npm 1.7.1286 → 1.7.1288

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.1286",
3
+ "version": "1.7.1288",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  const { COLLECTIONS,CUSTOM_VALUES_COLLECTION_FIELDS,JOBS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
2
2
  const { CAREERS_PAGE_SELECTORS, GLOBAL_SECTIONS_SELECTORS } = require('../public/selectors');
3
- const { wixWindow } = require('wix-window');
3
+
4
4
  const { window } = require('@wix/site-window');
5
5
  const { queryParams,onChange} = require('wix-location-frontend');
6
6
  const { location } = require("@wix/site-location");
@@ -39,10 +39,7 @@ let secondarySearchIsFilled=false // whether the secondary search is filled with
39
39
  let keywordAllJobs; // all jobs that are displayed in the jobs repeater when the keyword is filled
40
40
  let ActivateURLOnchange=true; // whether to activate the url onchange
41
41
  let considerAllJobs=false; // whether to consider all jobs or not
42
- let urlOnchangeIsActive=false
43
- let numbersofParamChanges=0;
44
- let selectedParamsList=[]
45
- let urlParamsIndex=0;
42
+
46
43
  const pagination = {
47
44
  pageSize: 10,
48
45
  currentPage: 1,
@@ -50,13 +47,8 @@ const pagination = {
50
47
 
51
48
  async function careersMultiBoxesPageOnReady(_$w,urlParams) {
52
49
  //to handle back and forth , url changes
53
-
54
50
  onChange(async ()=>{
55
- console.log("wixwindow.refere",wixWindow.referrer);
56
- urlOnchangeIsActive=true;
57
51
  await handleBackAndForth(_$w);
58
- urlOnchangeIsActive=false;
59
-
60
52
  });
61
53
  await loadData(_$w);
62
54
  await loadJobsRepeater(_$w); // if we remove the await here the job list will be flaky , it doesn't fill it properly
@@ -70,62 +62,26 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
70
62
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CLEAR_ALL_BUTTON_ID).onClick(async () => {
71
63
  await clearAll(_$w);
72
64
  });
73
- if (await window.formFactor() === "Mobile") {
65
+ const formFactor = await window.formFactor();
66
+ if (formFactor === "Mobile" || formFactor === "Tablet") {
74
67
  handleFilterInMobile(_$w);
75
68
  }
76
69
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_MULTI_STATE_BOX).changeState("results");
77
- selectedParamsList.push(urlParams);
78
70
  }
79
71
 
80
72
  async function handleBackAndForth(_$w){
81
- //check the case when i click on a category then i click on
82
-
83
-
84
- const newQueryParams=await location.query();
85
- selectedParamsList.push(newQueryParams);
86
-
87
-
88
-
89
73
  if(ActivateURLOnchange) {
90
- const newQueryParams=await location.query();
91
- await clearAll(_$w,true);
92
- await handleUrlParams(_$w,newQueryParams,true);
93
- ActivateURLOnchange=true;
94
- }
95
- else{
96
- numbersofParamChanges--;
97
- if(numbersofParamChanges===0) {
98
- ActivateURLOnchange=true;
99
- }
100
- }
101
-
74
+ const newQueryParams=await location.query();
75
+ console.log("newQueryParams: ", newQueryParams);
76
+ ActivateURLOnchange=false;
77
+ await clearAll(_$w,true);
78
+ await handleUrlParams(_$w,newQueryParams,true);
79
+ ActivateURLOnchange=true;
102
80
 
103
- // if(ActivateURLOnchange) {
104
- // const newQueryParams=await location.query();
105
- // console.log("newQueryParams: ", newQueryParams);
106
- // if(newQueryParams.page)
107
- // {
108
- // pageIsRemoved=false;
109
- // }
110
- // else
111
- // {
112
- // pageIsRemoved=true;
113
- // }
114
- // ActivateURLOnchange=false;
115
- // await clearAll(_$w,true);
116
- // await handleUrlParams(_$w,newQueryParams,true);
117
- // ActivateURLOnchange=true;
118
- // if(pageIsRemoved)
119
- // {
120
- // handlePaginationButtons(_$w);
121
- // pageIsRemoved=false;
122
- // }
123
-
124
-
125
- // }
126
- // else{
127
- // ActivateURLOnchange=true;
128
- // }
81
+ }
82
+ else{
83
+ ActivateURLOnchange=true;
84
+ }
129
85
  }
130
86
 
131
87
  async function clearAll(_$w,urlOnChange=false) {
@@ -142,7 +98,7 @@ async function clearAll(_$w,urlOnChange=false) {
142
98
  keywordAllJobs=undefined;
143
99
  if(!urlOnChange) {
144
100
  console.log("inside clearAll removing url params");
145
- // ActivateURLOnchange=false;
101
+ ActivateURLOnchange=false;
146
102
  queryParams.remove(possibleUrlParams.concat(["keyword", "page"]));
147
103
 
148
104
  await updateJobsAndNumbersAndFilters(_$w,true);
@@ -251,8 +207,6 @@ async function handleUrlParams(_$w,urlParams,handleBackAndForth=false) {
251
207
  const jobsFirstPage=currentJobs.slice(startSlicIndex,endSlicIndex);
252
208
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = jobsFirstPage;
253
209
  handlePaginationButtons(_$w);
254
- handlePageUrlParam();
255
-
256
210
  }
257
211
  } catch (error) {
258
212
  console.error('Failed to handle url params:', error);
@@ -302,7 +256,6 @@ async function handleParams(_$w,param,values) {
302
256
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationCurrentText).text = pagination.currentPage.toString();
303
257
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = nextPageJobs;
304
258
  handlePaginationButtons(_$w);
305
- handlePageUrlParam();
306
259
  await _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).scrollTo();
307
260
  });
308
261
 
@@ -312,7 +265,6 @@ async function handleParams(_$w,param,values) {
312
265
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationCurrentText).text = pagination.currentPage.toString();
313
266
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = previousPageJobs;
314
267
  handlePaginationButtons(_$w);
315
- handlePageUrlParam();
316
268
  await _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).scrollTo();
317
269
  });
318
270
  } catch (error) {
@@ -326,12 +278,6 @@ async function handleParams(_$w,param,values) {
326
278
  $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER_ITEM_LABEL).text = itemData.label || '';
327
279
  // Deselect this value from both the selected map and the multibox
328
280
  $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.DESELECT_BUTTON_ID).onClick(async () => {
329
- // const currentQueryParams=await location.query();
330
- // if(currentQueryParams.page)
331
- // {
332
- // //queryParams.remove(["page"]);
333
- // queryParams.add({ ["page"]: 1 });
334
- // }
335
281
  const fieldId = itemData.fieldId;
336
282
  const valueId = itemData.valueId;
337
283
  dontUpdateThisCheckBox=fieldId;
@@ -341,24 +287,18 @@ async function handleParams(_$w,param,values) {
341
287
  const field=getFieldById(fieldId,allfields);
342
288
  let fieldTitle=field.title.toLowerCase().replace(' ', '');
343
289
  fieldTitle==="brands"? fieldTitle="brand":fieldTitle;
344
- // ActivateURLOnchange=false;
290
+ ActivateURLOnchange=false;
345
291
  const previousSelectedSize=selectedByField.size;
346
292
  if (updated.length) {
347
293
  selectedByField.set(fieldId, updated);
348
294
 
349
295
 
350
296
  queryParams.add({ [fieldTitle] : updated.map(val=>encodeURIComponent(val)).join(',') });
351
- if(urlOnchangeIsActive){
352
- numbersofParamChanges++;
353
- }
354
297
  } else {
355
298
  selectedByField.delete(fieldId);
356
299
  handleConsiderAllJobs(previousSelectedSize,selectedByField.size);
357
300
 
358
301
  queryParams.remove([fieldTitle ]);
359
- if(urlOnchangeIsActive){
360
- numbersofParamChanges++;
361
- }
362
302
  }
363
303
 
364
304
  const currentVals = _$w(`#${FiltersIds[field.title]}CheckBox`).value || [];
@@ -412,7 +352,6 @@ async function loadJobsRepeater(_$w) {
412
352
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationTotalCountText).text = Math.ceil(currentJobs.length/pagination.pageSize).toString();
413
353
  updateTotalJobsCountText(_$w);
414
354
  handlePaginationButtons(_$w);
415
- handlePageUrlParam();
416
355
  } catch (error) {
417
356
  console.error('Failed to load jobs repeater:', error);
418
357
  }
@@ -462,16 +401,6 @@ async function loadJobsRepeater(_$w) {
462
401
 
463
402
  _$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = []; // start empty
464
403
  _$w(`#${FiltersIds[field.title]}CheckBox`).onChange(async (ev) => {
465
- const currentQueryParams=await location.query();
466
- if(currentQueryParams.page)
467
- {
468
- // //try instead of removing to add page = 1
469
- // //queryParams.remove(["page"]);
470
- // queryParams.add({ ["page"]: 1 });
471
- pageIsRemoved=true
472
- //save the selected param
473
-
474
- }
475
404
  dontUpdateThisCheckBox=field._id;
476
405
  const selected = ev.target.value; // array of selected value IDs
477
406
  let fieldTitle=field.title.toLowerCase().replace(' ', '');
@@ -487,26 +416,15 @@ async function loadJobsRepeater(_$w) {
487
416
  //in this case we need the label not valueid
488
417
  const valueLabels=getValueFromValueId(selected,value);
489
418
  queryParams.add({ [fieldTitle] : valueLabels.map(val=>encodeURIComponent(val)).join(',') });
490
-
491
- if(urlOnchangeIsActive){
492
- numbersofParamChanges++;
493
- }
494
419
  }
495
420
  else{
496
421
  queryParams.add({ [fieldTitle] : selected.map(val=>encodeURIComponent(val)).join(',') });
497
- if(urlOnchangeIsActive){
498
- numbersofParamChanges++;
499
- }
500
422
  }
501
423
 
502
424
  } else {
503
425
  selectedByField.delete(field._id);
504
426
  handleConsiderAllJobs(previousSelectedSize,selectedByField.size);
505
427
  queryParams.remove([fieldTitle ]);
506
-
507
- if(urlOnchangeIsActive){
508
- numbersofParamChanges++;
509
- }
510
428
  }
511
429
 
512
430
  console.log("selectedByField: ",selectedByField)
@@ -682,19 +600,13 @@ function getValueFromValueId(valueIds, value) {
682
600
  await _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_MULTI_STATE_BOX).changeState("searchResult");
683
601
  pagination.currentPage=1;
684
602
  }
685
- handlePaginationButtons(_$w);
686
- if(!urlOnchangeIsActive)
687
- {
688
-
689
- handlePageUrlParam();
690
- }
691
603
 
604
+ handlePaginationButtons(_$w);
692
605
  }
693
606
 
694
607
  function handlePaginationButtons(_$w)
695
608
  {
696
- console.log("iamhere")
697
- // handlePageUrlParam();
609
+ handlePageUrlParam();
698
610
 
699
611
  pagination.currentPage===1 || pagination.currentPage===0? _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_PREVIOUS).disable():_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_PREVIOUS).enable();
700
612
  if(secondarySearchIsFilled) {
@@ -718,11 +630,9 @@ function handlePageUrlParam() {
718
630
  if(pagination.currentPage==1 || pagination.currentPage==0)
719
631
  {
720
632
  queryParams.remove(["page"]);
721
- numbersofParamChanges++;
722
633
  }
723
634
  else{
724
- queryParams.add({ ["page"]: pagination.currentPage });
725
- numbersofParamChanges++;
635
+ queryParams.add({ page: pagination.currentPage });
726
636
  }
727
637
  }
728
638
  async function refreshFacetCounts(_$w,clearAll=false) {
@@ -807,7 +717,6 @@ async function secondarySearch(_$w,query) {
807
717
  secondarySearchIsFilled=true
808
718
  }
809
719
  handlePaginationButtons(_$w);
810
- handlePageUrlParam();
811
720
  updateTotalJobsCountText(_$w);
812
721
  await refreshFacetCounts(_$w);
813
722
  return allsecondarySearchJobs;