sr-npm 1.7.1287 → 1.7.1289

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