sr-npm 3.1.8 → 3.1.10
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 +7 -0
- package/backend/secretsData.js +8 -3
- package/package.json +1 -1
- package/pages/careersMultiBoxesPage.js +56 -35
- package/pages/positionPage.js +0 -1
package/backend/data.js
CHANGED
|
@@ -500,6 +500,7 @@ async function referenceJobs() {
|
|
|
500
500
|
}
|
|
501
501
|
|
|
502
502
|
async function syncJobsFast() {
|
|
503
|
+
try{
|
|
503
504
|
console.log("Syncing jobs fast");
|
|
504
505
|
await createCollections();
|
|
505
506
|
await clearCollections();
|
|
@@ -516,6 +517,12 @@ async function syncJobsFast() {
|
|
|
516
517
|
await aggregateJobs();
|
|
517
518
|
await referenceJobs();
|
|
518
519
|
console.log("syncing jobs fast finished successfully");
|
|
520
|
+
}
|
|
521
|
+
catch (error) {
|
|
522
|
+
error.message="Error syncing jobs: "+error.message;
|
|
523
|
+
throw error;
|
|
524
|
+
}
|
|
525
|
+
|
|
519
526
|
}
|
|
520
527
|
|
|
521
528
|
|
package/backend/secretsData.js
CHANGED
|
@@ -37,9 +37,14 @@ const elevatedQuery = auth.elevate(wixData.query);
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
async function getApiKeys() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
try{
|
|
41
|
+
const companyId = await getTokenFromCMS(TOKEN_NAME.COMPANY_ID);
|
|
42
|
+
const templateType = await getTemplateTypeFromCMS();
|
|
43
|
+
return {companyId,templateType};
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error("Error getting api keys: ", error);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
module.exports = {
|
package/package.json
CHANGED
|
@@ -21,6 +21,7 @@ let allsecondarySearchJobs=[] // secondary search results that are displayed in
|
|
|
21
21
|
let currentSecondarySearchJobs=[] // current secondary search results that are displayed in the jobs repeater
|
|
22
22
|
let secondarySearchIsFilled=false // whether the secondary search is filled with results
|
|
23
23
|
let keywordAllJobs; // all jobs that are displayed in the jobs repeater when the keyword is filled
|
|
24
|
+
let ActivateURLOnchange=true; // whether to activate the url onchange
|
|
24
25
|
const pagination = {
|
|
25
26
|
pageSize: 10,
|
|
26
27
|
currentPage: 1,
|
|
@@ -33,7 +34,7 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
|
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
await loadData(_$w);
|
|
36
|
-
loadJobsRepeater(_$w);
|
|
37
|
+
await loadJobsRepeater(_$w); // if we remove the await here the job list will be flaky , it doesn't fill it properly
|
|
37
38
|
loadPrimarySearchRepeater(_$w);
|
|
38
39
|
await loadFilters(_$w);
|
|
39
40
|
loadSelectedValuesRepeater(_$w);
|
|
@@ -52,15 +53,23 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
async function handleBackAndForth(_$w){
|
|
56
|
+
if(ActivateURLOnchange) {
|
|
55
57
|
const newQueryParams=await location.query();
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
console.log("newQueryParams: ", newQueryParams);
|
|
59
|
+
ActivateURLOnchange=false;
|
|
60
|
+
await clearAll(_$w,true);
|
|
61
|
+
await handleUrlParams(_$w,newQueryParams,true);
|
|
62
|
+
ActivateURLOnchange=true;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
else{
|
|
66
|
+
ActivateURLOnchange=true;
|
|
67
|
+
}
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
async function clearAll(_$w,urlOnChange=false) {
|
|
63
71
|
if(selectedByField.size>0 || _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).value || _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value) {
|
|
72
|
+
|
|
64
73
|
for(const field of allfields) {
|
|
65
74
|
_$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = [];
|
|
66
75
|
}
|
|
@@ -71,9 +80,13 @@ async function clearAll(_$w,urlOnChange=false) {
|
|
|
71
80
|
currentJobs=alljobs;
|
|
72
81
|
keywordAllJobs=undefined;
|
|
73
82
|
if(!urlOnChange) {
|
|
83
|
+
console.log("inside clearAll removing url params");
|
|
84
|
+
ActivateURLOnchange=false;
|
|
74
85
|
queryParams.remove(possibleUrlParams.concat(["keyword", "page"]));
|
|
86
|
+
|
|
87
|
+
await updateJobsAndNumbersAndFilters(_$w,true);
|
|
75
88
|
}
|
|
76
|
-
|
|
89
|
+
|
|
77
90
|
}
|
|
78
91
|
}
|
|
79
92
|
|
|
@@ -113,7 +126,7 @@ function handleFilterInMobile(_$w) {
|
|
|
113
126
|
}
|
|
114
127
|
|
|
115
128
|
|
|
116
|
-
async function handleUrlParams(_$w,urlParams) {
|
|
129
|
+
async function handleUrlParams(_$w,urlParams,handleBackAndForth=false) {
|
|
117
130
|
try {
|
|
118
131
|
let applyFiltering=false;
|
|
119
132
|
let currentApplyFilterFlag=false;
|
|
@@ -136,8 +149,9 @@ async function handleUrlParams(_$w,urlParams) {
|
|
|
136
149
|
}
|
|
137
150
|
currentApplyFilterFlag=false;
|
|
138
151
|
}
|
|
139
|
-
if(applyFiltering || keywordAllJobs) {
|
|
152
|
+
if(applyFiltering || keywordAllJobs || handleBackAndForth) {
|
|
140
153
|
await updateJobsAndNumbersAndFilters(_$w);
|
|
154
|
+
|
|
141
155
|
}
|
|
142
156
|
|
|
143
157
|
if(urlParams.page) {
|
|
@@ -236,6 +250,7 @@ async function handleParams(_$w,param,values) {
|
|
|
236
250
|
const field=getFieldById(fieldId,allfields);
|
|
237
251
|
let fieldTitle=field.title.toLowerCase().replace(' ', '');
|
|
238
252
|
fieldTitle==="brands"? fieldTitle="brand":fieldTitle;
|
|
253
|
+
ActivateURLOnchange=false;
|
|
239
254
|
if (updated.length) {
|
|
240
255
|
selectedByField.set(fieldId, updated);
|
|
241
256
|
queryParams.add({ [fieldTitle] : updated.map(val=>encodeURIComponent(val)).join(',') });
|
|
@@ -243,10 +258,12 @@ async function handleParams(_$w,param,values) {
|
|
|
243
258
|
selectedByField.delete(fieldId);
|
|
244
259
|
queryParams.remove([fieldTitle ]);
|
|
245
260
|
}
|
|
261
|
+
|
|
246
262
|
const currentVals = _$w(`#${FiltersIds[field.title]}CheckBox`).value || [];
|
|
247
263
|
const nextVals = currentVals.filter(v => v !== valueId);
|
|
248
264
|
_$w(`#${FiltersIds[field.title]}CheckBox`).value = nextVals;
|
|
249
265
|
await updateJobsAndNumbersAndFilters(_$w);
|
|
266
|
+
|
|
250
267
|
});
|
|
251
268
|
});
|
|
252
269
|
updateSelectedValuesRepeater(_$w);
|
|
@@ -313,8 +330,7 @@ async function loadJobsRepeater(_$w) {
|
|
|
313
330
|
// 2) Load all values once and group them by referenced field
|
|
314
331
|
let valuesByFieldId = groupValuesByField(allvaluesobjects, CUSTOM_VALUES_COLLECTION_FIELDS.CUSTOM_FIELD);
|
|
315
332
|
valuesByFieldId.set("Location",cities)
|
|
316
|
-
|
|
317
|
-
// Build CheckboxGroup options for this field
|
|
333
|
+
// Build CheckboxGroup options for this field
|
|
318
334
|
const counter={}
|
|
319
335
|
for(const city of cities) {
|
|
320
336
|
counter[city.city]=city.count
|
|
@@ -343,27 +359,28 @@ async function loadJobsRepeater(_$w) {
|
|
|
343
359
|
|
|
344
360
|
_$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = []; // start empty
|
|
345
361
|
_$w(`#${FiltersIds[field.title]}CheckBox`).onChange(async (ev) => {
|
|
346
|
-
dontUpdateThisCheckBox
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
else{
|
|
359
|
-
queryParams.add({ [fieldTitle] : selected.map(val=>encodeURIComponent(val)).join(',') });
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
} else {
|
|
363
|
-
selectedByField.delete(field._id);
|
|
364
|
-
queryParams.remove([fieldTitle ]);
|
|
362
|
+
dontUpdateThisCheckBox=field._id;
|
|
363
|
+
const selected = ev.target.value; // array of selected value IDs
|
|
364
|
+
let fieldTitle=field.title.toLowerCase().replace(' ', '');
|
|
365
|
+
fieldTitle==="brands"? fieldTitle="brand":fieldTitle;
|
|
366
|
+
ActivateURLOnchange=false;
|
|
367
|
+
if (selected && selected.length) {
|
|
368
|
+
selectedByField.set(field._id, selected);
|
|
369
|
+
if(fieldTitle==="brand" || fieldTitle==="storename") {
|
|
370
|
+
//in this case we need the label not valueid
|
|
371
|
+
const valueLabels=getValueFromValueId(selected,value);
|
|
372
|
+
queryParams.add({ [fieldTitle] : valueLabels.map(val=>encodeURIComponent(val)).join(',') });
|
|
365
373
|
}
|
|
366
|
-
|
|
374
|
+
else{
|
|
375
|
+
queryParams.add({ [fieldTitle] : selected.map(val=>encodeURIComponent(val)).join(',') });
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
} else {
|
|
379
|
+
selectedByField.delete(field._id);
|
|
380
|
+
queryParams.remove([fieldTitle ]);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
console.log("selectedByField: ",selectedByField)
|
|
367
384
|
await updateJobsAndNumbersAndFilters(_$w);
|
|
368
385
|
});
|
|
369
386
|
|
|
@@ -394,10 +411,10 @@ function getValueFromValueId(valueIds, value) {
|
|
|
394
411
|
}
|
|
395
412
|
|
|
396
413
|
async function updateJobsAndNumbersAndFilters(_$w,clearAll=false) {
|
|
397
|
-
await applyJobFilters(_$w); // re-query jobs
|
|
414
|
+
await applyJobFilters(_$w,clearAll); // re-query jobs
|
|
398
415
|
await refreshFacetCounts(_$w,clearAll); // recompute and update counts in all lists
|
|
399
416
|
await updateSelectedValuesRepeater(_$w);
|
|
400
|
-
updateTotalJobsCountText(_$w);
|
|
417
|
+
updateTotalJobsCountText(_$w);
|
|
401
418
|
}
|
|
402
419
|
|
|
403
420
|
function updateOptionsUI(_$w,fieldTitle, fieldId, searchQuery,clearAll=false) {
|
|
@@ -444,7 +461,8 @@ function getValueFromValueId(valueIds, value) {
|
|
|
444
461
|
}
|
|
445
462
|
}
|
|
446
463
|
|
|
447
|
-
async function applyJobFilters(_$w) {
|
|
464
|
+
async function applyJobFilters(_$w,clearAll=false) {
|
|
465
|
+
// if(!clearAll) {
|
|
448
466
|
let tempFilteredJobs=[];
|
|
449
467
|
let finalFilteredJobs=[];
|
|
450
468
|
secondarySearchIsFilled? finalFilteredJobs=allsecondarySearchJobs:finalFilteredJobs=alljobs;
|
|
@@ -478,12 +496,13 @@ function getValueFromValueId(valueIds, value) {
|
|
|
478
496
|
finalFilteredJobs=tempFilteredJobs;
|
|
479
497
|
tempFilteredJobs=[];
|
|
480
498
|
}
|
|
481
|
-
|
|
482
499
|
secondarySearchIsFilled? currentSecondarySearchJobs=finalFilteredJobs:currentJobs=finalFilteredJobs;
|
|
483
500
|
|
|
484
501
|
|
|
485
502
|
let jobsFirstPage=[];
|
|
503
|
+
console.log("currentSecondarySearchJobs: ",currentSecondarySearchJobs)
|
|
486
504
|
secondarySearchIsFilled? jobsFirstPage=currentSecondarySearchJobs.slice(0,pagination.pageSize):jobsFirstPage=currentJobs.slice(0,pagination.pageSize);
|
|
505
|
+
console.log("jobsFirstPage: ",jobsFirstPage)
|
|
487
506
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = jobsFirstPage;
|
|
488
507
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationCurrentText).text = "1";
|
|
489
508
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationTotalCountText).text = secondarySearchIsFilled? Math.ceil(currentSecondarySearchJobs.length/pagination.pageSize).toString():Math.ceil(currentJobs.length/pagination.pageSize).toString();
|
|
@@ -496,6 +515,7 @@ function getValueFromValueId(valueIds, value) {
|
|
|
496
515
|
pagination.currentPage=1;
|
|
497
516
|
handlePaginationButtons(_$w);
|
|
498
517
|
}
|
|
518
|
+
// }
|
|
499
519
|
|
|
500
520
|
function handlePaginationButtons(_$w)
|
|
501
521
|
{
|
|
@@ -519,14 +539,15 @@ function handlePaginationButtons(_$w)
|
|
|
519
539
|
}
|
|
520
540
|
|
|
521
541
|
function handlePageUrlParam() {
|
|
542
|
+
ActivateURLOnchange=false;
|
|
522
543
|
if(pagination.currentPage==1)
|
|
523
544
|
{
|
|
545
|
+
|
|
524
546
|
queryParams.remove(["page"]);
|
|
525
547
|
}
|
|
526
548
|
else{
|
|
527
549
|
queryParams.add({ page: pagination.currentPage });
|
|
528
550
|
}
|
|
529
|
-
|
|
530
551
|
}
|
|
531
552
|
async function refreshFacetCounts(_$w,clearAll=false) {
|
|
532
553
|
|