sr-npm 1.7.750 → 1.7.752
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.
|
@@ -16,12 +16,16 @@ const CAREERS_MULTI_BOXES_PAGE_CONSTS={
|
|
|
16
16
|
PAGE_BUTTON_PREVIOUS: '#previousPageButton',
|
|
17
17
|
paginationCurrentText: '#paginationCurrent',
|
|
18
18
|
paginationTotalCountText: '#paginationTotalCount',
|
|
19
|
-
SEARCH_INPUT: '#searchInput',
|
|
20
19
|
PRIMARY_SEARCH_RESULTS: '#resultsRepeater',
|
|
21
20
|
SEARCH_BUTTON: '#searchButton',
|
|
22
21
|
SECONDARY_SEARCH_INPUT: '#secondarySearchInput',
|
|
23
22
|
JOBS_MULTI_STATE_BOX:"#jobsMultiStateBox",
|
|
24
|
-
|
|
23
|
+
PRIMARY_SEARCH_INPUT: '#primarySearchInput',
|
|
24
|
+
JOB_RESULTS_REPEATER: '#jobResultsRepeater',
|
|
25
|
+
CATEGORY_RESULTS_REPEATER: '#categoryResultsRepeater',
|
|
26
|
+
PRIMARY_SEARCH_MULTI_BOX: '#primarySearchMultiBox',
|
|
27
|
+
PRIMARY_SEARCH_POSITION_BUTTON: '#primarySearechPositionButton',
|
|
28
|
+
PRIMARY_SEARCH_CATEGORY_BUTTON: '#primarySearchCategoryButton',
|
|
25
29
|
|
|
26
30
|
}
|
|
27
31
|
|
package/package.json
CHANGED
|
@@ -22,6 +22,7 @@ const pagination = {
|
|
|
22
22
|
async function careersMultiBoxesPageOnReady(_$w,urlParams) {
|
|
23
23
|
await loadData(_$w);
|
|
24
24
|
await loadJobsRepeater(_$w);
|
|
25
|
+
await loadPrimarySearchButtons(_$w);
|
|
25
26
|
await loadFilters(_$w);
|
|
26
27
|
await loadSelectedValuesRepeater(_$w);
|
|
27
28
|
await bindSearchInput(_$w);
|
|
@@ -41,6 +42,17 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
|
|
|
41
42
|
await handleUrlParams(_$w,urlParams);
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
async function loadPrimarySearchButtons(_$w) {
|
|
46
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
|
|
47
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_POSITION_BUTTON).text = itemData.title || '';
|
|
48
|
+
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
|
|
52
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_CATEGORY_BUTTON).text = itemData.title || '';
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
44
56
|
async function handleUrlParams(_$w,urlParams) {
|
|
45
57
|
let applyFiltering=false;
|
|
46
58
|
if(urlParams.brand) {
|
|
@@ -150,6 +162,7 @@ async function loadData(_$w) {
|
|
|
150
162
|
}
|
|
151
163
|
if(Object.keys(valueToJobs).length === 0){
|
|
152
164
|
allvaluesobjects=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
165
|
+
console.log("allvaluesobjects: ", allvaluesobjects);
|
|
153
166
|
for (const value of allvaluesobjects) {
|
|
154
167
|
valueToJobs[value._id]= value.jobIds;
|
|
155
168
|
}
|
|
@@ -222,7 +235,7 @@ async function loadJobsRepeater(_$w) {
|
|
|
222
235
|
dontUpdateThisCheckBox=field._id;
|
|
223
236
|
const selected = ev.target.value; // array of selected value IDs
|
|
224
237
|
if (selected && selected.length) {
|
|
225
|
-
selectedByField.set(field._id, selected);
|
|
238
|
+
selectedByField.set(field._id, selected);
|
|
226
239
|
} else {
|
|
227
240
|
selectedByField.delete(field._id);
|
|
228
241
|
}
|
|
@@ -327,8 +340,6 @@ async function loadJobsRepeater(_$w) {
|
|
|
327
340
|
tempFilteredJobs=[];
|
|
328
341
|
}
|
|
329
342
|
secondarySearchIsFilled? currentSecondarySearchJobs=finalFilteredJobs:currentJobs=finalFilteredJobs;
|
|
330
|
-
|
|
331
|
-
//currentJobs=finalFilteredJobs;
|
|
332
343
|
let jobsFirstPage=[];
|
|
333
344
|
secondarySearchIsFilled? jobsFirstPage=currentSecondarySearchJobs.slice(0,pagination.pageSize):jobsFirstPage=currentJobs.slice(0,pagination.pageSize);
|
|
334
345
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = jobsFirstPage;
|
|
@@ -368,26 +379,7 @@ function handlePageUrlParam() {
|
|
|
368
379
|
}
|
|
369
380
|
async function refreshFacetCounts(_$w,clearAll=false) {
|
|
370
381
|
|
|
371
|
-
console.log("refreshing facet counts");
|
|
372
|
-
|
|
373
382
|
secondarySearchIsFilled? countJobsPerField(currentSecondarySearchJobs):countJobsPerField(currentJobs);
|
|
374
|
-
// const fieldIds = Array.from(optionsByFieldId.keys());
|
|
375
|
-
// const currentJobsIds=currentJobs.map(job=>job._id);
|
|
376
|
-
// for (const fieldId of fieldIds) {
|
|
377
|
-
// let currentoptions=optionsByFieldId.get(fieldId)
|
|
378
|
-
// let counter=new Map();
|
|
379
|
-
// for(const option of currentoptions) {
|
|
380
|
-
// for (const jobId of currentJobsIds) {
|
|
381
|
-
// if (valueToJobs[option.value].includes(jobId)) {
|
|
382
|
-
// counter.set(option.value, (counter.get(option.value) || 0) + 1);
|
|
383
|
-
// }
|
|
384
|
-
// }
|
|
385
|
-
// }
|
|
386
|
-
// countsByFieldId.set(fieldId, counter);
|
|
387
|
-
// }
|
|
388
|
-
|
|
389
|
-
console.log("countsByFieldId: ", countsByFieldId);
|
|
390
|
-
|
|
391
383
|
for(const field of allfields) {
|
|
392
384
|
const query = (_$w(`#${FiltersIds[field.title]}input`).value || '').toLowerCase().trim();
|
|
393
385
|
clearAll? updateOptionsUI(_$w,field.title, field._id, '',true):updateOptionsUI(_$w,field.title, field._id, query);
|
|
@@ -397,7 +389,6 @@ async function refreshFacetCounts(_$w,clearAll=false) {
|
|
|
397
389
|
|
|
398
390
|
|
|
399
391
|
function countJobsPerField(jobs) {
|
|
400
|
-
console.log("counting jobs per field for jobs: ", jobs);
|
|
401
392
|
const fieldIds = Array.from(optionsByFieldId.keys());
|
|
402
393
|
const currentJobsIds=jobs.map(job=>job._id);
|
|
403
394
|
for (const fieldId of fieldIds) {
|
|
@@ -412,7 +403,6 @@ async function refreshFacetCounts(_$w,clearAll=false) {
|
|
|
412
403
|
}
|
|
413
404
|
countsByFieldId.set(fieldId, counter);
|
|
414
405
|
}
|
|
415
|
-
console.log("countsByFieldId inside countJobsPerField: ", countsByFieldId);
|
|
416
406
|
}
|
|
417
407
|
|
|
418
408
|
|
|
@@ -432,12 +422,22 @@ async function refreshFacetCounts(_$w,clearAll=false) {
|
|
|
432
422
|
|
|
433
423
|
function primarySearch(_$w,query) {
|
|
434
424
|
console.log("primary search query: ", query);
|
|
425
|
+
|
|
426
|
+
let filteredJobs=alljobs.filter(job=>job.title.toLowerCase().includes(query));
|
|
427
|
+
if(filteredJobs.length>0) {
|
|
428
|
+
alljobs=filteredJobs;
|
|
429
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("searchResult");
|
|
430
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data = alljobs
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("noResults");
|
|
434
|
+
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
|
|
435
438
|
}
|
|
436
439
|
async function secondarySearch(_$w,query) {
|
|
437
|
-
console.log("secondary search query: ", query);
|
|
438
440
|
if(query.length===0 || query===undefined || query==='') {
|
|
439
|
-
console.log("secondary search query is empty, resetting secondary search");
|
|
440
|
-
// allsecondarySearchJobs=currentJobs;
|
|
441
441
|
secondarySearchIsFilled=false;
|
|
442
442
|
await updateJobsAndNumbersAndFilters(_$w); // we do this here because of the case when searching the list and adding filters from the side, and we delete the search query, so we need to refresh the counts and the jobs
|
|
443
443
|
return;
|
|
@@ -461,20 +461,36 @@ async function secondarySearch(_$w,query) {
|
|
|
461
461
|
|
|
462
462
|
handlePaginationButtons(_$w);
|
|
463
463
|
updateTotalJobsCountText(_$w);
|
|
464
|
-
await refreshFacetCounts(_$w);
|
|
464
|
+
await refreshFacetCounts(_$w);
|
|
465
465
|
return allsecondarySearchJobs;
|
|
466
466
|
}
|
|
467
467
|
async function bindSearchInput(_$w) {
|
|
468
468
|
const primarySearchDebounced = debounce(() => {
|
|
469
|
-
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.
|
|
469
|
+
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value || '').toLowerCase().trim();
|
|
470
470
|
primarySearch(_$w, query);
|
|
471
471
|
}, 150);
|
|
472
472
|
const secondarySearchDebounced = debounce(async () => {
|
|
473
473
|
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).value || '').toLowerCase().trim();
|
|
474
474
|
await secondarySearch(_$w, query);
|
|
475
475
|
}, 150);
|
|
476
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.
|
|
476
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onInput(primarySearchDebounced);
|
|
477
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onClick(async () => {
|
|
478
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("categoryResults");
|
|
479
|
+
// let categroyFieldId;
|
|
480
|
+
// for(const field of allfields) {
|
|
481
|
+
// if(field.title==="Category") {
|
|
482
|
+
// categroyFieldId=field._id;
|
|
483
|
+
// break;
|
|
484
|
+
// }
|
|
485
|
+
// }
|
|
486
|
+
// let categorycounts=countsByFieldId.get(categroyFieldId);
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
//_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data = alljobs
|
|
490
|
+
//@@@@@@@@@@@@@@@@@
|
|
491
|
+
});
|
|
477
492
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).onInput(secondarySearchDebounced);
|
|
493
|
+
|
|
478
494
|
}
|
|
479
495
|
|
|
480
496
|
module.exports = {
|