sr-npm 1.2.75 → 1.2.77
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/careersMultiBoxesPageIds.js +8 -0
- package/package.json +1 -1
- package/pages/careersMultiBoxesPage.js +37 -13
- package/pages/careersPage.js +13 -13
- package/pages/homePage.js +7 -6
- package/pages/pagesUtils.js +3 -1
- package/public/primarySearchUtils.js +66 -74
- package/public/selectors.js +6 -2
|
@@ -31,6 +31,13 @@ const CAREERS_MULTI_BOXES_PAGE_CONSTS={
|
|
|
31
31
|
PRIMARY_SEARCH_CATEGORY_BUTTON: '#primarySearchCategoryButton',
|
|
32
32
|
RESULTS_CONTAINER: '#resultsContainer',
|
|
33
33
|
PRIMARY_SEARCH_BUTTON: '#primarySearchButton',
|
|
34
|
+
RESULTS_MULTI_STATE_BOX: '#multiStateBox1',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const PRIMARY_SEARCH_STATES={
|
|
38
|
+
CATEGORY_RESULTS: 'categoryResults',
|
|
39
|
+
JOB_RESULTS: 'jobResults',
|
|
40
|
+
NO_RESULTS: 'noResults',
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
const TWG_JOBS_COLLECTION_FIELDS={
|
|
@@ -81,4 +88,5 @@ module.exports = {
|
|
|
81
88
|
CATEGORY_CUSTOM_FIELD_ID_IN_CMS,
|
|
82
89
|
possibleUrlParams,
|
|
83
90
|
TWG_JOBS_COLLECTION_FIELDS,
|
|
91
|
+
PRIMARY_SEARCH_STATES,
|
|
84
92
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { COLLECTIONS,CUSTOM_VALUES_COLLECTION_FIELDS,JOBS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
|
|
2
|
-
const { CAREERS_PAGE_SELECTORS } = require('../public/selectors');
|
|
2
|
+
const { CAREERS_PAGE_SELECTORS, GLOBAL_SECTIONS_SELECTORS } = require('../public/selectors');
|
|
3
3
|
|
|
4
4
|
const { window } = require('@wix/site-window');
|
|
5
5
|
const { queryParams,onChange} = require('wix-location-frontend');
|
|
@@ -47,7 +47,6 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
|
|
|
47
47
|
onChange(async ()=>{
|
|
48
48
|
await handleBackAndForth(_$w);
|
|
49
49
|
});
|
|
50
|
-
|
|
51
50
|
await loadData(_$w);
|
|
52
51
|
await loadJobsRepeater(_$w); // if we remove the await here the job list will be flaky , it doesn't fill it properly
|
|
53
52
|
handlePrimarySearch(_$w, allvaluesobjects);
|
|
@@ -55,16 +54,14 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
|
|
|
55
54
|
loadSelectedValuesRepeater(_$w);
|
|
56
55
|
bindSearchInput(_$w);
|
|
57
56
|
loadPaginationButtons(_$w);
|
|
58
|
-
|
|
59
57
|
if (await window.formFactor() === "Mobile") {
|
|
60
58
|
handleFilterInMobile(_$w);
|
|
61
59
|
}
|
|
62
|
-
|
|
63
60
|
await handleUrlParams(_$w, urlParams);
|
|
64
61
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CLEAR_ALL_BUTTON_ID).onClick(async () => {
|
|
65
62
|
await clearAll(_$w);
|
|
66
63
|
});
|
|
67
|
-
|
|
64
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_MULTI_STATE_BOX).changeState("results");
|
|
68
65
|
}
|
|
69
66
|
|
|
70
67
|
async function handleBackAndForth(_$w){
|
|
@@ -150,7 +147,7 @@ async function handleUrlParams(_$w,urlParams,handleBackAndForth=false) {
|
|
|
150
147
|
applyFiltering = await queryPrimarySearchResults(_$w, decodeURIComponent(urlParams.keyword));
|
|
151
148
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value = decodeURIComponent(urlParams.keyword);
|
|
152
149
|
|
|
153
|
-
const items = await getAllDatasetItems(_$w,
|
|
150
|
+
const items = await getAllDatasetItems(_$w, GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET);
|
|
154
151
|
|
|
155
152
|
currentJobs = items;
|
|
156
153
|
keywordAllJobs = items;
|
|
@@ -439,16 +436,20 @@ function getValueFromValueId(valueIds, value) {
|
|
|
439
436
|
function updateOptionsUI(_$w,fieldTitle, fieldId, searchQuery,clearAll=false) {
|
|
440
437
|
let base = optionsByFieldId.get(fieldId) || [];
|
|
441
438
|
const countsMap = countsByFieldId.get(fieldId) || new Map();
|
|
442
|
-
if(dontUpdateThisCheckBox===fieldId && !clearAll)
|
|
439
|
+
if(dontUpdateThisCheckBox===fieldId && !clearAll && selectedByField.has(fieldId) )
|
|
443
440
|
{
|
|
444
|
-
|
|
445
|
-
|
|
441
|
+
dontUpdateThisCheckBox=null;
|
|
442
|
+
return;
|
|
446
443
|
}
|
|
447
444
|
let filteredbase=[]
|
|
448
445
|
for (const element of base)
|
|
449
446
|
{
|
|
450
447
|
if(countsMap.get(element.value))
|
|
451
448
|
{
|
|
449
|
+
if(countsMap.get(element.value)==-1)
|
|
450
|
+
{
|
|
451
|
+
countsMap.set(element.value,0);
|
|
452
|
+
}
|
|
452
453
|
filteredbase.push(element)
|
|
453
454
|
}
|
|
454
455
|
}
|
|
@@ -466,19 +467,31 @@ function getValueFromValueId(valueIds, value) {
|
|
|
466
467
|
: withCounts;
|
|
467
468
|
|
|
468
469
|
// Preserve currently selected values that are still visible
|
|
469
|
-
|
|
470
|
-
|
|
470
|
+
// let prevSelected=[]
|
|
471
|
+
// clearAll? prevSelected=[]:prevSelected= _$w(`#${FiltersIds[fieldTitle]}CheckBox`).value;
|
|
471
472
|
const visibleSet = new Set(filtered.map(o => o.value));
|
|
472
|
-
const preserved = prevSelected.filter(v => visibleSet.has(v));
|
|
473
|
+
//const preserved = prevSelected.filter(v => visibleSet.has(v));
|
|
473
474
|
if(filtered.length===0) {
|
|
474
475
|
_$w(`#${FiltersIds[fieldTitle]}MultiBox`).changeState(`${FiltersIds[fieldTitle]}NoResults`);
|
|
475
476
|
}
|
|
476
477
|
else{
|
|
477
478
|
_$w(`#${FiltersIds[fieldTitle]}MultiBox`).changeState(`${FiltersIds[fieldTitle]}Results`);
|
|
478
479
|
_$w(`#${FiltersIds[fieldTitle]}CheckBox`).options = filtered;
|
|
479
|
-
_$w(`#${FiltersIds[fieldTitle]}CheckBox`).value =
|
|
480
|
+
clearAll?_$w(`#${FiltersIds[fieldTitle]}CheckBox`).value=[]:_$w(`#${FiltersIds[fieldTitle]}CheckBox`).value = visibleSet
|
|
481
|
+
if(visibleSet.size>0 && selectedByField.has(fieldId)) {
|
|
482
|
+
let selectedindices=[];
|
|
483
|
+
for(const value of selectedByField.get(fieldId)) {
|
|
484
|
+
const options = optionsByFieldId.get(fieldId) || [];
|
|
485
|
+
const option = getCorrectOption(value,options,fieldTitle);
|
|
486
|
+
if(option) {
|
|
487
|
+
const optionIndex = getOptionIndexFromCheckBox(_$w(`#${FiltersIds[fieldTitle]}CheckBox`).options,option.value);
|
|
488
|
+
selectedindices.push(optionIndex);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
_$w(`#${FiltersIds[fieldTitle]}CheckBox`).selectedIndices = selectedindices;
|
|
480
492
|
}
|
|
481
493
|
}
|
|
494
|
+
}
|
|
482
495
|
|
|
483
496
|
async function applyJobFilters(_$w) {
|
|
484
497
|
let tempFilteredJobs=[];
|
|
@@ -591,7 +604,18 @@ async function refreshFacetCounts(_$w,clearAll=false) {
|
|
|
591
604
|
counter.set(option.value, (counter.get(option.value) || 0) + 1);
|
|
592
605
|
}
|
|
593
606
|
}
|
|
607
|
+
|
|
594
608
|
}
|
|
609
|
+
if(selectedByField.has(fieldId)) {
|
|
610
|
+
for (const value of selectedByField.get(fieldId)) {
|
|
611
|
+
console.log("value: ",value)
|
|
612
|
+
if(counter.get(value)===undefined)
|
|
613
|
+
{
|
|
614
|
+
//it is -1 as a flag, so in case it was selected and after selecting more filters from different field and suddenly no more jobs have it, we will show 0
|
|
615
|
+
counter.set(value, -1);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
595
619
|
countsByFieldId.set(fieldId, counter);
|
|
596
620
|
}
|
|
597
621
|
}
|
package/pages/careersPage.js
CHANGED
|
@@ -6,7 +6,7 @@ const { location } = require("@wix/site-location");
|
|
|
6
6
|
const { COLLECTIONS } = require('../backend/collectionConsts');
|
|
7
7
|
const { careersMultiBoxesPageOnReady } = require('./careersMultiBoxesPage');
|
|
8
8
|
const { debounce, getFilter} = require('../public/filterUtils');
|
|
9
|
-
const { CAREERS_PAGE_SELECTORS, FILTER_FIELDS } = require('../public/selectors');
|
|
9
|
+
const { CAREERS_PAGE_SELECTORS, FILTER_FIELDS, GLOBAL_SECTIONS_SELECTORS } = require('../public/selectors');
|
|
10
10
|
const { filterBrokenMarkers } = require('../public/utils');
|
|
11
11
|
|
|
12
12
|
let currentLoadedItems =100;
|
|
@@ -58,10 +58,10 @@ async function careersPageOnReady(_$w,thisObject=null,queryParams=null) {
|
|
|
58
58
|
|
|
59
59
|
function activateAutoLoad(_$w)
|
|
60
60
|
{
|
|
61
|
-
_$w(
|
|
61
|
+
_$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).onReady(() => {
|
|
62
62
|
updateCount(_$w);
|
|
63
63
|
_$w(CAREERS_PAGE_SELECTORS.FOOTER).onViewportEnter(() => {
|
|
64
|
-
if (currentLoadedItems<_$w(
|
|
64
|
+
if (currentLoadedItems<_$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getTotalCount()) {
|
|
65
65
|
loadMoreJobs(_$w);
|
|
66
66
|
}
|
|
67
67
|
else {
|
|
@@ -81,7 +81,7 @@ async function loadMoreJobs(_$w) {
|
|
|
81
81
|
pageParamSet = Number(pageParamSet) + 1;
|
|
82
82
|
}
|
|
83
83
|
if (shouldLoad) {
|
|
84
|
-
_$w(
|
|
84
|
+
_$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).loadMore();
|
|
85
85
|
console.log("loading more jobs");
|
|
86
86
|
|
|
87
87
|
currentLoadedItems = currentLoadedItems + itemsPerPage;
|
|
@@ -148,7 +148,7 @@ async function handlePageParam(_$w) {
|
|
|
148
148
|
//scrolls a bit to load the dataset data
|
|
149
149
|
await window.scrollTo(0, 200,{scrollAnimation:false});
|
|
150
150
|
for (let i = 2; i <= queryPageVar; i++) {
|
|
151
|
-
await _$w(
|
|
151
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).loadMore();
|
|
152
152
|
currentLoadedItems=currentLoadedItems+itemsPerPage
|
|
153
153
|
}
|
|
154
154
|
// the timeout is to wait for the repeater to render, then scroll to the last item.
|
|
@@ -170,7 +170,7 @@ async function handlePageParam(_$w) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
async function bind(_$w) {
|
|
173
|
-
await _$w(
|
|
173
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).onReady(async () => {
|
|
174
174
|
await updateCount(_$w);
|
|
175
175
|
await updateMapMarkers(_$w);
|
|
176
176
|
|
|
@@ -337,8 +337,8 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
|
|
|
337
337
|
});
|
|
338
338
|
|
|
339
339
|
const filter = await getFilter(filters, 'and');
|
|
340
|
-
await _$w(
|
|
341
|
-
await _$w(
|
|
340
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).setFilter(filter);
|
|
341
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).refresh();
|
|
342
342
|
|
|
343
343
|
const count = await updateCount(_$w);
|
|
344
344
|
console.log("updating map markers");
|
|
@@ -357,8 +357,8 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
|
|
|
357
357
|
async function resetFilters(_$w) {
|
|
358
358
|
_$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT, CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT, CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION, CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE, CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).value = '';
|
|
359
359
|
|
|
360
|
-
await _$w(
|
|
361
|
-
await _$w(
|
|
360
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).setFilter(wixData.filter());
|
|
361
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).refresh();
|
|
362
362
|
|
|
363
363
|
_$w(CAREERS_PAGE_SELECTORS.RESULTS_MULTI_STATE).changeState('results');
|
|
364
364
|
|
|
@@ -374,7 +374,7 @@ async function resetFilters(_$w) {
|
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
async function updateCount(_$w) {
|
|
377
|
-
const count = await _$w(
|
|
377
|
+
const count = await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getTotalCount();
|
|
378
378
|
_$w('#numOfPositionText').text = `Showing ${count} Open Positions`;
|
|
379
379
|
|
|
380
380
|
return count;
|
|
@@ -485,8 +485,8 @@ async function handleJobTypeParam(_$w,jobType) {
|
|
|
485
485
|
}
|
|
486
486
|
|
|
487
487
|
async function updateMapMarkers(_$w){
|
|
488
|
-
const numOfItems = await _$w(
|
|
489
|
-
const items = await _$w(
|
|
488
|
+
const numOfItems = await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getTotalCount();
|
|
489
|
+
const items = await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getItems(0, numOfItems);
|
|
490
490
|
const markers = filterBrokenMarkers(items.items).map(item => {
|
|
491
491
|
const location = item.locationAddress.location;
|
|
492
492
|
return {
|
package/pages/homePage.js
CHANGED
|
@@ -6,6 +6,7 @@ const {wixData} = require('wix-data');
|
|
|
6
6
|
const { COLLECTIONS } = require('../backend/collectionConsts');
|
|
7
7
|
const { getAllRecords } = require('./pagesUtils');
|
|
8
8
|
const { handlePrimarySearch } = require('../public/primarySearchUtils');
|
|
9
|
+
const { GLOBAL_SECTIONS_SELECTORS } = require('../public/selectors');
|
|
9
10
|
|
|
10
11
|
let thisObjectVar;
|
|
11
12
|
let searchByCityFlag=false;
|
|
@@ -161,10 +162,10 @@ async function handleSearchInput(_$w) {
|
|
|
161
162
|
|
|
162
163
|
let filter = await getFilter(searchByTitle);
|
|
163
164
|
|
|
164
|
-
await _$w(
|
|
165
|
-
await _$w(
|
|
165
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).setFilter(filter);
|
|
166
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).refresh();
|
|
166
167
|
|
|
167
|
-
count = _$w(
|
|
168
|
+
count = _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getTotalCount();
|
|
168
169
|
|
|
169
170
|
if (count > 0) {
|
|
170
171
|
searchByCityFlag = false;
|
|
@@ -172,9 +173,9 @@ async function handleSearchInput(_$w) {
|
|
|
172
173
|
_$w('#searchMultiStateBox').changeState('results');
|
|
173
174
|
} else {
|
|
174
175
|
filter = await getFilter(searchByCity);
|
|
175
|
-
await _$w(
|
|
176
|
-
await _$w(
|
|
177
|
-
count = _$w(
|
|
176
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).setFilter(filter);
|
|
177
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).refresh();
|
|
178
|
+
count = _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getTotalCount();
|
|
178
179
|
if( count > 0 )
|
|
179
180
|
{
|
|
180
181
|
searchByCityFlag = true;
|
package/pages/pagesUtils.js
CHANGED
|
@@ -78,10 +78,12 @@ function getFieldByTitle(title,allFields) {
|
|
|
78
78
|
|
|
79
79
|
function getCorrectOption(value,options,param) {
|
|
80
80
|
const standardizedValue = normalizeString(value.toLowerCase())
|
|
81
|
-
if(param==="employmenttype") //employmenttype have a problematic value
|
|
81
|
+
if(param==="employmenttype" || param==="Employment Type" || param==="Store Name") //employmenttype have a problematic value, added Employment Type for updateOptionsUI fuinction, added Store Name because Store name and location have for example Blenheim
|
|
82
82
|
{
|
|
83
|
+
//option.value is the id,
|
|
83
84
|
return options.find(option=>normalizeString(option.value.toLowerCase())===standardizedValue);
|
|
84
85
|
}
|
|
86
|
+
//option.label is what we see live in the UI
|
|
85
87
|
return options.find(option=>normalizeString(option.label.toLowerCase())===standardizedValue);
|
|
86
88
|
}
|
|
87
89
|
|
|
@@ -1,31 +1,61 @@
|
|
|
1
1
|
const { location } = require("@wix/site-location");
|
|
2
2
|
|
|
3
|
-
const { CAREERS_MULTI_BOXES_PAGE_CONSTS, CATEGORY_CUSTOM_FIELD_ID_IN_CMS } = require('../backend/careersMultiBoxesPageIds');
|
|
3
|
+
const { CAREERS_MULTI_BOXES_PAGE_CONSTS, CATEGORY_CUSTOM_FIELD_ID_IN_CMS, PRIMARY_SEARCH_STATES } = require('../backend/careersMultiBoxesPageIds');
|
|
4
|
+
const { GLOBAL_SECTIONS_SELECTORS } = require('../public/selectors');
|
|
4
5
|
const { getFilter } = require('../public/filterUtils');
|
|
5
6
|
const { debounce } = require('../pages/pagesUtils');
|
|
6
7
|
|
|
7
8
|
async function handlePrimarySearch(_$w, allvaluesobjects) {
|
|
8
9
|
// load the categories list before clicking on the primary search input
|
|
10
|
+
loadCategoryRepeaterData(_$w, allvaluesobjects);
|
|
11
|
+
|
|
12
|
+
// wait for the jobs dataset to be ready
|
|
13
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).onReadyAsync();
|
|
14
|
+
|
|
15
|
+
await bindPrimarySearch(_$w);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function loadCategoryRepeaterData(_$w, allvaluesobjects) {
|
|
9
19
|
let categoryValues=[]
|
|
10
20
|
for(const value of allvaluesobjects) {
|
|
11
21
|
if(value.customField === CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
|
|
12
22
|
categoryValues.push({title: value.title+` (${value.count})` , _id: value.valueId});
|
|
13
23
|
}
|
|
14
24
|
}
|
|
15
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data = categoryValues;
|
|
25
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data = categoryValues;
|
|
26
|
+
}
|
|
16
27
|
|
|
17
|
-
|
|
18
|
-
|
|
28
|
+
async function bindPrimarySearch(_$w) {
|
|
29
|
+
handleCategoryEvents(_$w);
|
|
19
30
|
|
|
20
|
-
await
|
|
31
|
+
await handleSearchInput(_$w);
|
|
32
|
+
|
|
33
|
+
// on mouse out collapse the results container
|
|
34
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).onMouseOut(async () => {
|
|
35
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// handle the click on the search button
|
|
39
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_BUTTON).onClick(async () => {
|
|
40
|
+
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()==='') {
|
|
41
|
+
const baseUrl = await location.baseUrl();
|
|
42
|
+
location.to(`${baseUrl}/search`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
46
|
+
const baseUrl = await location.baseUrl();
|
|
47
|
+
location.to(`${baseUrl}/search?keyword=${encodedKeyWord}`);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
21
50
|
}
|
|
22
51
|
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
52
|
+
function handleCategoryEvents(_$w) {
|
|
53
|
+
// set the label of the category repeater item
|
|
54
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
|
|
26
55
|
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_CATEGORY_BUTTON).label = itemData.title || '';
|
|
27
56
|
});
|
|
28
57
|
|
|
58
|
+
// handle the category repeater item on click
|
|
29
59
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER_ITEM).onClick(async (event) => {
|
|
30
60
|
const data = _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data;
|
|
31
61
|
const clickedItemData = data.find(
|
|
@@ -42,9 +72,10 @@ function getSearchQuery(_$w) {
|
|
|
42
72
|
return _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value?.toLowerCase().trim() || '';
|
|
43
73
|
}
|
|
44
74
|
|
|
45
|
-
async function handleSearchInput(_$w
|
|
46
|
-
_$w(
|
|
75
|
+
async function handleSearchInput(_$w) {
|
|
76
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).enable();
|
|
47
77
|
|
|
78
|
+
// on Input call the queryPrimarySearchResults function
|
|
48
79
|
const callQueryPrimarySearchResults = async () => {
|
|
49
80
|
await queryPrimarySearchResults(_$w, getSearchQuery(_$w));
|
|
50
81
|
}
|
|
@@ -52,7 +83,7 @@ async function handleSearchInput(_$w, allvaluesobjects) {
|
|
|
52
83
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onInput(async () => {
|
|
53
84
|
await debounce(() => callQueryPrimarySearchResults(), 300)();
|
|
54
85
|
});
|
|
55
|
-
|
|
86
|
+
|
|
56
87
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onClick(async () => {
|
|
57
88
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
|
|
58
89
|
|
|
@@ -61,95 +92,59 @@ async function handleSearchInput(_$w, allvaluesobjects) {
|
|
|
61
92
|
await queryPrimarySearchResults(_$w, searchQuery);
|
|
62
93
|
}
|
|
63
94
|
else {
|
|
64
|
-
|
|
95
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(PRIMARY_SEARCH_STATES.CATEGORY_RESULTS);
|
|
65
96
|
}
|
|
66
97
|
});
|
|
67
98
|
|
|
68
99
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onKeyPress(async (event) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
100
|
+
if( event.key === 'Enter') {
|
|
101
|
+
if(getSearchQuery(_$w) === '') {
|
|
102
|
+
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
103
|
+
const baseUrl = await location.baseUrl();
|
|
104
|
+
location.to(`${baseUrl}/search`);
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
109
|
+
const baseUrl = await location.baseUrl();
|
|
110
|
+
location.to(`${baseUrl}/search?keyword=${encodedKeyWord}`);
|
|
111
|
+
}
|
|
80
112
|
}
|
|
81
|
-
}
|
|
82
113
|
});
|
|
83
114
|
}
|
|
84
|
-
|
|
85
|
-
async function bindPrimarySearch(_$w, allvaluesobjects) {
|
|
86
|
-
loadPrimarySearchRepeater(_$w);
|
|
87
|
-
|
|
88
|
-
await handleSearchInput(_$w, allvaluesobjects);
|
|
89
|
-
|
|
90
|
-
// on mouse out collapse the results container
|
|
91
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).onMouseOut(async () => {
|
|
92
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// handle the click on the search button
|
|
96
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_BUTTON).onClick(async () => {
|
|
97
|
-
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()==='') {
|
|
98
|
-
const baseUrl = await location.baseUrl();
|
|
99
|
-
location.to(`${baseUrl}/search`);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
103
|
-
const baseUrl = await location.baseUrl();
|
|
104
|
-
location.to(`${baseUrl}/search?keyword=${encodedKeyWord}`);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async function loadCategoriesListPrimarySearch(_$w, allvaluesobjects) {
|
|
110
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("categoryResults");
|
|
111
|
-
|
|
112
|
-
let categoryValues=[]
|
|
113
|
-
for(const value of allvaluesobjects) {
|
|
114
|
-
if(value.customField === CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
|
|
115
|
-
categoryValues.push({title: value.title+` (${value.count})` , _id: value.valueId});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data = categoryValues;
|
|
119
|
-
}
|
|
120
115
|
|
|
121
116
|
async function queryPrimarySearchResults(_$w, query) {
|
|
122
117
|
if(query === undefined || query === '') {
|
|
123
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(
|
|
118
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(PRIMARY_SEARCH_STATES.CATEGORY_RESULTS);
|
|
124
119
|
return false;
|
|
125
120
|
}
|
|
126
121
|
|
|
127
122
|
const searchByTitle = [{field: 'title', searchTerm: query}];
|
|
128
123
|
const searchByCity = [{field: 'location.fullLocation', searchTerm: query}];
|
|
129
124
|
|
|
130
|
-
let filter = await getFilter(searchByTitle);
|
|
125
|
+
let filter = await getFilter(searchByTitle);
|
|
131
126
|
|
|
132
|
-
await _$w(
|
|
133
|
-
await _$w(
|
|
127
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).setFilter(filter);
|
|
128
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).refresh();
|
|
134
129
|
|
|
135
|
-
let count = _$w(
|
|
130
|
+
let count = _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getTotalCount();
|
|
136
131
|
|
|
137
132
|
if( count > 0 ) {
|
|
138
133
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
|
|
139
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(
|
|
134
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(PRIMARY_SEARCH_STATES.JOB_RESULTS);
|
|
140
135
|
}
|
|
141
136
|
else {
|
|
142
137
|
filter = await getFilter(searchByCity);
|
|
143
|
-
await _$w(
|
|
144
|
-
await _$w(
|
|
138
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).setFilter(filter);
|
|
139
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).refresh();
|
|
145
140
|
|
|
146
|
-
count = _$w(
|
|
141
|
+
count = _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getTotalCount();
|
|
147
142
|
if (count > 0) {
|
|
148
143
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
|
|
149
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(
|
|
144
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(PRIMARY_SEARCH_STATES.JOB_RESULTS);
|
|
150
145
|
}
|
|
151
146
|
else{
|
|
152
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(
|
|
147
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(PRIMARY_SEARCH_STATES.NO_RESULTS);
|
|
153
148
|
}
|
|
154
149
|
}
|
|
155
150
|
|
|
@@ -157,8 +152,5 @@ return count > 0;
|
|
|
157
152
|
}
|
|
158
153
|
|
|
159
154
|
module.exports = {
|
|
160
|
-
loadPrimarySearchRepeater,
|
|
161
|
-
bindPrimarySearch,
|
|
162
|
-
queryPrimarySearchResults,
|
|
163
155
|
handlePrimarySearch,
|
|
164
156
|
}
|
package/public/selectors.js
CHANGED
|
@@ -26,19 +26,22 @@ const CAREERS_PAGE_SELECTORS = {
|
|
|
26
26
|
OPEN_FILTERS_BUTTON: '#openFiltersButton',
|
|
27
27
|
CLOSE_FILTERS_BUTTON: '#closeFiltersButton',
|
|
28
28
|
RESET_FILTERS_BUTTON: '#resetFiltersButton',
|
|
29
|
-
RESET_FILTERS_BUTTON: '#resetFiltersButton',
|
|
30
29
|
|
|
31
30
|
RESULTS_MULTI_STATE: '#resultsMultiState',
|
|
32
31
|
BRANDS_DATASET: '#brandsDataset',
|
|
33
32
|
DEPARTMENTS_DATASET: '#departmentsDataset',
|
|
34
33
|
LOCATIONS_DATASET: '#locationsDataset',
|
|
35
34
|
JOB_TYPES_DATASET: '#jobTypesDataset',
|
|
36
|
-
JOBS_DATASET: '#jobsDataset',
|
|
37
35
|
|
|
38
36
|
GOOGLE_MAPS: '#googleMaps',
|
|
39
37
|
FOOTER: '#footer',
|
|
40
38
|
}
|
|
41
39
|
|
|
40
|
+
const GLOBAL_SECTIONS_SELECTORS = {
|
|
41
|
+
JOBS_DATASET: '#jobsDataset',
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
42
45
|
const FILTER_FIELDS = {
|
|
43
46
|
DEPARTMENT: 'department',
|
|
44
47
|
LOCATION: 'cityText',
|
|
@@ -49,5 +52,6 @@ const FILTER_FIELDS = {
|
|
|
49
52
|
|
|
50
53
|
module.exports = {
|
|
51
54
|
CAREERS_PAGE_SELECTORS,
|
|
55
|
+
GLOBAL_SECTIONS_SELECTORS,
|
|
52
56
|
FILTER_FIELDS,
|
|
53
57
|
}
|