sr-npm 1.7.764 → 1.7.766
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 +1 -1
- package/pages/careersMultiBoxesPage.js +54 -45
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { COLLECTIONS,CUSTOM_VALUES_COLLECTION_FIELDS,JOBS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
|
|
2
|
-
const { queryParams
|
|
3
|
-
const {CAREERS_MULTI_BOXES_PAGE_CONSTS,FiltersIds,fieldTitlesInCMS,CATEGORY_CUSTOM_FIELD_ID_IN_CMS} = require('../backend/careersMultiBoxesPageIds');
|
|
2
|
+
const { queryParams} = require('wix-location-frontend');
|
|
4
3
|
const { location } = require("@wix/site-location");
|
|
4
|
+
const {CAREERS_MULTI_BOXES_PAGE_CONSTS,FiltersIds,fieldTitlesInCMS,CATEGORY_CUSTOM_FIELD_ID_IN_CMS} = require('../backend/careersMultiBoxesPageIds');
|
|
5
5
|
const { groupValuesByField, debounce, getAllRecords, getFieldById, getFieldByTitle,getCorrectOption,getOptionIndexFromCheckBox } = require('./pagesUtils');
|
|
6
6
|
|
|
7
7
|
let dontUpdateThisCheckBox;
|
|
@@ -16,13 +16,11 @@ let currentJobs=[] // current jobs that are displayed in the jobs repeater
|
|
|
16
16
|
let allsecondarySearchJobs=[] // secondary search results that are displayed in the jobs repeater
|
|
17
17
|
let currentSecondarySearchJobs=[] // current secondary search results that are displayed in the jobs repeater
|
|
18
18
|
let secondarySearchIsFilled=false // whether the secondary search is filled with results
|
|
19
|
-
let originalQueryParamas;
|
|
20
19
|
const pagination = {
|
|
21
20
|
pageSize: 10,
|
|
22
21
|
currentPage: 1,
|
|
23
22
|
};
|
|
24
23
|
async function careersMultiBoxesPageOnReady(_$w,urlParams) {
|
|
25
|
-
originalQueryParamas=urlParams;
|
|
26
24
|
console.log("careersMultiBoxesPageOnReady urlParams: ", urlParams);
|
|
27
25
|
await loadData(_$w);
|
|
28
26
|
await loadJobsRepeater(_$w);
|
|
@@ -31,41 +29,50 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
|
|
|
31
29
|
await loadSelectedValuesRepeater(_$w);
|
|
32
30
|
await bindSearchInput(_$w);
|
|
33
31
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CLEAR_ALL_BUTTON_ID).onClick(async () => {
|
|
34
|
-
|
|
35
|
-
if(selectedByField.size>0 || _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).value) {
|
|
36
|
-
for(const field of allfields) {
|
|
37
|
-
_$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = [];
|
|
38
|
-
}
|
|
39
|
-
selectedByField.clear();
|
|
40
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).value='';
|
|
41
|
-
secondarySearchIsFilled=false;
|
|
42
|
-
await updateJobsAndNumbersAndFilters(_$w,true);
|
|
43
|
-
}
|
|
32
|
+
await clearAll(_$w);
|
|
44
33
|
});
|
|
45
34
|
await loadPaginationButtons(_$w);
|
|
46
35
|
await handleUrlParams(_$w,urlParams);
|
|
47
36
|
}
|
|
48
37
|
|
|
38
|
+
async function clearAll(_$w) {
|
|
39
|
+
console.log("clear all button clicked");
|
|
40
|
+
if(selectedByField.size>0 || _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).value) {
|
|
41
|
+
for(const field of allfields) {
|
|
42
|
+
_$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = [];
|
|
43
|
+
}
|
|
44
|
+
selectedByField.clear();
|
|
45
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).value='';
|
|
46
|
+
secondarySearchIsFilled=false;
|
|
47
|
+
await updateJobsAndNumbersAndFilters(_$w,true);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
49
52
|
async function loadPrimarySearchRepeater(_$w) {
|
|
50
53
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
|
|
51
54
|
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_POSITION_BUTTON).label = itemData.title || '';
|
|
55
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_POSITION_BUTTON).onClick(async () => {
|
|
56
|
+
console.log("primary search position button clicked: ", itemData);
|
|
57
|
+
await location.to(itemData["link-jobs-title"]);
|
|
58
|
+
})
|
|
52
59
|
|
|
53
60
|
});
|
|
54
61
|
|
|
55
62
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
|
|
56
63
|
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_CATEGORY_BUTTON).label = itemData.title || '';
|
|
57
|
-
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_CATEGORY_BUTTON).onClick(async () => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// await handleUrlParams(_$w,originalQueryParamas);
|
|
64
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_CATEGORY_BUTTON).onClick(async () => {
|
|
65
|
+
await clearAll(_$w);
|
|
66
|
+
let encodedCategory=encodeURIComponent(itemData._id);
|
|
67
|
+
queryParams.add({ category:encodedCategory });
|
|
68
|
+
await handleUrlParams(_$w,{category:encodedCategory});
|
|
63
69
|
});
|
|
64
70
|
});
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
async function handleUrlParams(_$w,urlParams) {
|
|
68
74
|
let applyFiltering=false;
|
|
75
|
+
console.log("handleUrlParams urlParams: ", urlParams);
|
|
69
76
|
if(urlParams.brand) {
|
|
70
77
|
applyFiltering=await handleParams(_$w,"brand",urlParams.brand)
|
|
71
78
|
}
|
|
@@ -101,7 +108,9 @@ async function handleUrlParams(_$w,urlParams) {
|
|
|
101
108
|
|
|
102
109
|
async function handleParams(_$w,param,value) {
|
|
103
110
|
let applyFiltering=false;
|
|
111
|
+
console.log("handleParams param: ", param, " value: ", value);
|
|
104
112
|
const decodedValue = decodeURIComponent(value);
|
|
113
|
+
console.log("decodedValue: ", decodedValue);
|
|
105
114
|
const field=getFieldByTitle(fieldTitlesInCMS[param],allfields);
|
|
106
115
|
const options=optionsByFieldId.get(field._id);
|
|
107
116
|
console.log("all options availbe for this field: ", field.title, " are ", options);
|
|
@@ -431,8 +440,14 @@ async function refreshFacetCounts(_$w,clearAll=false) {
|
|
|
431
440
|
}
|
|
432
441
|
|
|
433
442
|
|
|
434
|
-
function primarySearch(_$w,query) {
|
|
443
|
+
async function primarySearch(_$w,query) {
|
|
435
444
|
console.log("primary search query: ", query);
|
|
445
|
+
if(query.length===0 || query===undefined || query==='') {
|
|
446
|
+
//await loadCategoriesListPrimarySearch(_$w);
|
|
447
|
+
console.log("loading categories list primary search");
|
|
448
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("categoryResults");
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
436
451
|
|
|
437
452
|
let filteredJobs=alljobs.filter(job=>job.title.toLowerCase().includes(query));
|
|
438
453
|
console.log("filteredJobs.length: ", filteredJobs.length);
|
|
@@ -477,43 +492,37 @@ async function secondarySearch(_$w,query) {
|
|
|
477
492
|
return allsecondarySearchJobs;
|
|
478
493
|
}
|
|
479
494
|
async function bindSearchInput(_$w) {
|
|
480
|
-
const primarySearchDebounced = debounce(() => {
|
|
495
|
+
const primarySearchDebounced = debounce(async () => {
|
|
481
496
|
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value || '').toLowerCase().trim();
|
|
482
|
-
primarySearch(_$w, query);
|
|
497
|
+
await primarySearch(_$w, query);
|
|
483
498
|
}, 150);
|
|
484
499
|
const secondarySearchDebounced = debounce(async () => {
|
|
485
500
|
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).value || '').toLowerCase().trim();
|
|
486
501
|
await secondarySearch(_$w, query);
|
|
487
502
|
}, 150);
|
|
488
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onInput(
|
|
503
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onInput(async () => {
|
|
504
|
+
await primarySearchDebounced();
|
|
505
|
+
});
|
|
489
506
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onClick(async () => {
|
|
490
507
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
|
|
491
|
-
_$w
|
|
492
|
-
let categoryValues=[]
|
|
493
|
-
for(const value of allvaluesobjects) {
|
|
494
|
-
if(value.customField===CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
|
|
495
|
-
categoryValues.push({title:value.title+` (${value.totalJobs})` ,_id:value._id});
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
console.log("categoryValues: ", categoryValues);
|
|
499
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data = categoryValues;
|
|
500
|
-
// let categroyFieldId;
|
|
501
|
-
// for(const field of allfields) {
|
|
502
|
-
// if(field.title==="Category") {
|
|
503
|
-
// categroyFieldId=field._id;
|
|
504
|
-
// break;
|
|
505
|
-
// }
|
|
506
|
-
// }
|
|
507
|
-
// let categorycounts=countsByFieldId.get(categroyFieldId);
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
//_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data = alljobs
|
|
511
|
-
//@@@@@@@@@@@@@@@@@
|
|
508
|
+
await loadCategoriesListPrimarySearch(_$w);
|
|
512
509
|
});
|
|
513
510
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).onInput(secondarySearchDebounced);
|
|
514
511
|
|
|
515
512
|
}
|
|
516
513
|
|
|
514
|
+
async function loadCategoriesListPrimarySearch(_$w) {
|
|
515
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("categoryResults");
|
|
516
|
+
let categoryValues=[]
|
|
517
|
+
for(const value of allvaluesobjects) {
|
|
518
|
+
if(value.customField===CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
|
|
519
|
+
categoryValues.push({title:value.title+` (${value.totalJobs})` ,_id:value._id});
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
console.log("categoryValues: ", categoryValues);
|
|
523
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data = categoryValues;
|
|
524
|
+
}
|
|
525
|
+
|
|
517
526
|
module.exports = {
|
|
518
527
|
careersMultiBoxesPageOnReady,
|
|
519
528
|
secondarySearch
|