sr-npm 1.7.765 → 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 +49 -47
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,39 +29,43 @@ 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
|
-
//await location.to(`/search?category=${itemData._id}`);
|
|
60
|
-
// console.log("after location to");
|
|
61
|
-
// to(`/search?category=${itemData._id}`);
|
|
62
|
-
console.log("before handling shit")
|
|
64
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_CATEGORY_BUTTON).onClick(async () => {
|
|
65
|
+
await clearAll(_$w);
|
|
63
66
|
let encodedCategory=encodeURIComponent(itemData._id);
|
|
64
|
-
|
|
67
|
+
queryParams.add({ category:encodedCategory });
|
|
65
68
|
await handleUrlParams(_$w,{category:encodedCategory});
|
|
66
|
-
console.log("after handling url params");
|
|
67
69
|
});
|
|
68
70
|
});
|
|
69
71
|
}
|
|
@@ -438,8 +440,14 @@ async function refreshFacetCounts(_$w,clearAll=false) {
|
|
|
438
440
|
}
|
|
439
441
|
|
|
440
442
|
|
|
441
|
-
function primarySearch(_$w,query) {
|
|
443
|
+
async function primarySearch(_$w,query) {
|
|
442
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
|
+
}
|
|
443
451
|
|
|
444
452
|
let filteredJobs=alljobs.filter(job=>job.title.toLowerCase().includes(query));
|
|
445
453
|
console.log("filteredJobs.length: ", filteredJobs.length);
|
|
@@ -484,43 +492,37 @@ async function secondarySearch(_$w,query) {
|
|
|
484
492
|
return allsecondarySearchJobs;
|
|
485
493
|
}
|
|
486
494
|
async function bindSearchInput(_$w) {
|
|
487
|
-
const primarySearchDebounced = debounce(() => {
|
|
495
|
+
const primarySearchDebounced = debounce(async () => {
|
|
488
496
|
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value || '').toLowerCase().trim();
|
|
489
|
-
primarySearch(_$w, query);
|
|
497
|
+
await primarySearch(_$w, query);
|
|
490
498
|
}, 150);
|
|
491
499
|
const secondarySearchDebounced = debounce(async () => {
|
|
492
500
|
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).value || '').toLowerCase().trim();
|
|
493
501
|
await secondarySearch(_$w, query);
|
|
494
502
|
}, 150);
|
|
495
|
-
_$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
|
+
});
|
|
496
506
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onClick(async () => {
|
|
497
507
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
|
|
498
|
-
_$w
|
|
499
|
-
let categoryValues=[]
|
|
500
|
-
for(const value of allvaluesobjects) {
|
|
501
|
-
if(value.customField===CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
|
|
502
|
-
categoryValues.push({title:value.title+` (${value.totalJobs})` ,_id:value._id});
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
console.log("categoryValues: ", categoryValues);
|
|
506
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data = categoryValues;
|
|
507
|
-
// let categroyFieldId;
|
|
508
|
-
// for(const field of allfields) {
|
|
509
|
-
// if(field.title==="Category") {
|
|
510
|
-
// categroyFieldId=field._id;
|
|
511
|
-
// break;
|
|
512
|
-
// }
|
|
513
|
-
// }
|
|
514
|
-
// let categorycounts=countsByFieldId.get(categroyFieldId);
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
//_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data = alljobs
|
|
518
|
-
//@@@@@@@@@@@@@@@@@
|
|
508
|
+
await loadCategoriesListPrimarySearch(_$w);
|
|
519
509
|
});
|
|
520
510
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).onInput(secondarySearchDebounced);
|
|
521
511
|
|
|
522
512
|
}
|
|
523
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
|
+
|
|
524
526
|
module.exports = {
|
|
525
527
|
careersMultiBoxesPageOnReady,
|
|
526
528
|
secondarySearch
|