sr-npm 1.7.915 → 1.7.917
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 +0 -2
- package/backend/consts.js +8 -2
- package/backend/data.js +9 -11
- package/package.json +1 -1
- package/pages/careersMultiBoxesPage.js +45 -37
- package/pages/careersPage.js +0 -5
- package/pages/homePage.js +7 -4
- package/pages/pagesUtils.js +25 -39
- package/pages/positionPage.js +3 -20
- package/pages/supportTeamsPage.js +8 -10
- package/tests/multiSearchBoxCareers.spec.js +1 -1
|
@@ -22,9 +22,7 @@ const CAREERS_MULTI_BOXES_PAGE_CONSTS={
|
|
|
22
22
|
JOBS_MULTI_STATE_BOX:"#jobsMultiStateBox",
|
|
23
23
|
PRIMARY_SEARCH_INPUT: '#primarySearchInput',
|
|
24
24
|
JOB_RESULTS_REPEATER: '#jobResultsRepeater',
|
|
25
|
-
JOB_RESULTS_REPEATER_ITEM: '#jobResultsRepeaterItem',
|
|
26
25
|
CATEGORY_RESULTS_REPEATER: '#categoryResultsRepeater',
|
|
27
|
-
CATEGORY_RESULTS_REPEATER_ITEM: '#categoryResultsRepeaterItem',
|
|
28
26
|
PRIMARY_SEARCH_MULTI_BOX: '#primarySearchMultiBox',
|
|
29
27
|
PRIMARY_SEARCH_POSITION_BUTTON: '#primarySearchPositionButton',
|
|
30
28
|
PRIMARY_SEARCH_CATEGORY_BUTTON: '#primarySearchCategoryButton',
|
package/backend/consts.js
CHANGED
|
@@ -82,7 +82,6 @@ const TASK_TYPE = {
|
|
|
82
82
|
|
|
83
83
|
const supportTeamsPageIds={
|
|
84
84
|
RECENTLEY_ADDED_JOBS: "#recentleyAddedJobs",
|
|
85
|
-
RECENTLEY_ADDED_JOBS_ITEM: "#recentleyAddedJobsItem",
|
|
86
85
|
JOB_LOCATION: "#jobLocation",
|
|
87
86
|
JOB_TITLE: "#jobTitle",
|
|
88
87
|
SEE_ALL_JOBS_TEXT: "#seeAllJobsText",
|
|
@@ -106,7 +105,14 @@ const supportTeamsPageIds={
|
|
|
106
105
|
"Supply Chain":"Logistics",
|
|
107
106
|
"Contact Centre":"CustomerEngagementCentres",// this field doesnt exists in the database
|
|
108
107
|
"Commercial":"CommercialSales",// this field doesnt exists in the database
|
|
109
|
-
}
|
|
108
|
+
},
|
|
109
|
+
excludeValues: new Set([
|
|
110
|
+
"Human Resouces",
|
|
111
|
+
"Buying",
|
|
112
|
+
"Tech",
|
|
113
|
+
"Planning",
|
|
114
|
+
"Digital",
|
|
115
|
+
])
|
|
110
116
|
}
|
|
111
117
|
const LINKS={
|
|
112
118
|
myApplication:'https://www.smartrecruiters.com/app/employee-portal/68246e5512d84f4c00a19e62/job-applications',
|
package/backend/data.js
CHANGED
|
@@ -75,7 +75,7 @@ function getVisibility(position,customFieldsValues) {
|
|
|
75
75
|
let visibility;
|
|
76
76
|
position.visibility.toLowerCase()==="public"? visibility="external" : visibility="internal";
|
|
77
77
|
customFieldsValues["Visibility"][visibility] = visibility;
|
|
78
|
-
customValuesToJobs[visibility] ? customValuesToJobs[visibility].
|
|
78
|
+
customValuesToJobs[visibility] ? customValuesToJobs[visibility].push(position.id) : customValuesToJobs[visibility]=[position.id]
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
function getEmploymentType(position,customFieldsValues) {
|
|
@@ -83,7 +83,7 @@ function getEmploymentType(position,customFieldsValues) {
|
|
|
83
83
|
customFieldsValues["employmentType"] = {};
|
|
84
84
|
}
|
|
85
85
|
customFieldsValues["employmentType"][position.typeOfEmployment.id] = position.typeOfEmployment.label;
|
|
86
|
-
customValuesToJobs[position.typeOfEmployment.id] ? customValuesToJobs[position.typeOfEmployment.id].
|
|
86
|
+
customValuesToJobs[position.typeOfEmployment.id] ? customValuesToJobs[position.typeOfEmployment.id].push(position.id) : customValuesToJobs[position.typeOfEmployment.id]=[position.id]
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
function getCustomFieldsAndValuesFromPosition(position,customFieldsLabels,customFieldsValues) {
|
|
@@ -101,7 +101,7 @@ function getCustomFieldsAndValuesFromPosition(position,customFieldsLabels,custom
|
|
|
101
101
|
}
|
|
102
102
|
customFieldsValues[fieldId][valueId] = valueLabel;
|
|
103
103
|
|
|
104
|
-
customValuesToJobs[valueId] ? customValuesToJobs[valueId].
|
|
104
|
+
customValuesToJobs[valueId] ? customValuesToJobs[valueId].push(position.id) : customValuesToJobs[valueId]=[position.id]
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
async function saveJobsDataToCMS() {
|
|
@@ -153,7 +153,7 @@ async function saveJobsDataToCMS() {
|
|
|
153
153
|
await getSiteConfig();
|
|
154
154
|
}
|
|
155
155
|
if (siteconfig.customFields==="true") {
|
|
156
|
-
await populateCustomFieldsCollection(customFieldsLabels
|
|
156
|
+
await populateCustomFieldsCollection(customFieldsLabels);
|
|
157
157
|
await populateCustomValuesCollection(customFieldsValues);
|
|
158
158
|
}
|
|
159
159
|
// Sort jobs by title (ascending, case-insensitive, numeric-aware)
|
|
@@ -194,15 +194,13 @@ async function saveJobsDataToCMS() {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
async function insertJobsReference(valueId) {
|
|
197
|
-
await wixData.insertReference(COLLECTIONS.CUSTOM_VALUES, CUSTOM_VALUES_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,valueId,
|
|
197
|
+
await wixData.insertReference(COLLECTIONS.CUSTOM_VALUES, CUSTOM_VALUES_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,valueId, customValuesToJobs[valueId]);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
async function populateCustomFieldsCollection(customFields
|
|
200
|
+
async function populateCustomFieldsCollection(customFields) {
|
|
201
201
|
let fieldstoinsert=[]
|
|
202
202
|
customFields["employmentType"] = "Employment Type";
|
|
203
|
-
|
|
204
|
-
customFields["Visibility"] = "Visibility";
|
|
205
|
-
}
|
|
203
|
+
customFields["Visibility"] = "Visibility";
|
|
206
204
|
for(const ID of Object.keys(customFields)){
|
|
207
205
|
fieldstoinsert.push({
|
|
208
206
|
title: customFields[ID],
|
|
@@ -220,8 +218,8 @@ async function populateCustomValuesCollection(customFieldsValues) {
|
|
|
220
218
|
_id: valueId,
|
|
221
219
|
title: valuesMap[valueId],
|
|
222
220
|
customField: fieldId,
|
|
223
|
-
count:customValuesToJobs[valueId].
|
|
224
|
-
jobIds:
|
|
221
|
+
count:customValuesToJobs[valueId].length,
|
|
222
|
+
jobIds:customValuesToJobs[valueId],
|
|
225
223
|
})
|
|
226
224
|
}
|
|
227
225
|
|
package/package.json
CHANGED
|
@@ -16,20 +16,21 @@ 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 keywordAllJobs; // all jobs that are displayed in the jobs repeater when the keyword is filled
|
|
20
19
|
const pagination = {
|
|
21
20
|
pageSize: 10,
|
|
22
21
|
currentPage: 1,
|
|
23
22
|
};
|
|
24
23
|
async function careersMultiBoxesPageOnReady(_$w,urlParams) {
|
|
25
24
|
await loadData(_$w);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
|
|
26
|
+
await Promise.all([
|
|
27
|
+
loadJobsRepeater(_$w),
|
|
28
|
+
loadPrimarySearchRepeater(_$w),
|
|
29
|
+
loadFilters(_$w),
|
|
30
|
+
loadSelectedValuesRepeater(_$w),
|
|
31
|
+
bindSearchInput(_$w),
|
|
32
|
+
loadPaginationButtons(_$w)
|
|
33
|
+
]);
|
|
33
34
|
await handleUrlParams(_$w, urlParams);
|
|
34
35
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CLEAR_ALL_BUTTON_ID).onClick(async () => {
|
|
35
36
|
await clearAll(_$w);
|
|
@@ -46,8 +47,6 @@ async function clearAll(_$w) {
|
|
|
46
47
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).value='';
|
|
47
48
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value='';
|
|
48
49
|
secondarySearchIsFilled=false;
|
|
49
|
-
currentJobs=alljobs;
|
|
50
|
-
keywordAllJobs=undefined;
|
|
51
50
|
await updateJobsAndNumbersAndFilters(_$w,true);
|
|
52
51
|
}
|
|
53
52
|
}
|
|
@@ -56,13 +55,7 @@ async function clearAll(_$w) {
|
|
|
56
55
|
async function handleUrlParams(_$w,urlParams) {
|
|
57
56
|
try {
|
|
58
57
|
let applyFiltering=false;
|
|
59
|
-
|
|
60
|
-
if(urlParams.keyword) {
|
|
61
|
-
applyFiltering=await primarySearch(_$w, decodeURIComponent(urlParams.keyword), alljobs);
|
|
62
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value=decodeURIComponent(urlParams.keyword);
|
|
63
|
-
currentJobs=_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data;
|
|
64
|
-
keywordAllJobs=_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data;
|
|
65
|
-
}
|
|
58
|
+
let keyword=false
|
|
66
59
|
if(urlParams.brand) {
|
|
67
60
|
applyFiltering=await handleParams(_$w,"brand",urlParams.brand)
|
|
68
61
|
}
|
|
@@ -72,9 +65,18 @@ async function handleUrlParams(_$w,urlParams) {
|
|
|
72
65
|
if(urlParams.category) {
|
|
73
66
|
applyFiltering=await handleParams(_$w,"category",urlParams.category)
|
|
74
67
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
if(urlParams.keyword) {
|
|
69
|
+
applyFiltering=await primarySearch(_$w, decodeURIComponent(urlParams.keyword), alljobs);
|
|
70
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value=decodeURIComponent(urlParams.keyword);
|
|
71
|
+
keyword=true;
|
|
72
|
+
if(applyFiltering)
|
|
73
|
+
{
|
|
74
|
+
currentJobs=_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
if(applyFiltering) {
|
|
79
|
+
await updateJobsAndNumbersAndFilters(_$w,false,keyword);
|
|
78
80
|
}
|
|
79
81
|
if(urlParams.page) {
|
|
80
82
|
if(Number.isNaN(Number(urlParams.page)) || Number(urlParams.page)<=1 || Number(urlParams.page)>Math.ceil(currentJobs.length/pagination.pageSize)) {
|
|
@@ -119,7 +121,7 @@ async function handleParams(_$w,param,value) {
|
|
|
119
121
|
return applyFiltering;
|
|
120
122
|
}
|
|
121
123
|
|
|
122
|
-
function loadPaginationButtons(_$w) {
|
|
124
|
+
async function loadPaginationButtons(_$w) {
|
|
123
125
|
try {
|
|
124
126
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_NEXT).onClick(async () => {
|
|
125
127
|
let nextPageJobs=currentJobs.slice(pagination.pageSize*pagination.currentPage,pagination.pageSize*(pagination.currentPage+1));
|
|
@@ -141,7 +143,7 @@ async function handleParams(_$w,param,value) {
|
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
145
|
|
|
144
|
-
function loadSelectedValuesRepeater(_$w) {
|
|
146
|
+
async function loadSelectedValuesRepeater(_$w) {
|
|
145
147
|
try {
|
|
146
148
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).onItemReady(($item, itemData) => {
|
|
147
149
|
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER_ITEM_LABEL).text = itemData.label || '';
|
|
@@ -168,7 +170,7 @@ async function handleParams(_$w,param,value) {
|
|
|
168
170
|
await updateJobsAndNumbersAndFilters(_$w);
|
|
169
171
|
});
|
|
170
172
|
});
|
|
171
|
-
|
|
173
|
+
await updateSelectedValuesRepeater(_$w);
|
|
172
174
|
} catch (error) {
|
|
173
175
|
console.error('Failed to load selected values repeater:', error);
|
|
174
176
|
}
|
|
@@ -286,8 +288,8 @@ async function loadJobsRepeater(_$w) {
|
|
|
286
288
|
|
|
287
289
|
|
|
288
290
|
|
|
289
|
-
async function updateJobsAndNumbersAndFilters(_$w,clearAll=false) {
|
|
290
|
-
await applyJobFilters(_$w); // re-query jobs
|
|
291
|
+
async function updateJobsAndNumbersAndFilters(_$w,clearAll=false,keyword=false) {
|
|
292
|
+
await applyJobFilters(_$w,keyword); // re-query jobs
|
|
291
293
|
await refreshFacetCounts(_$w,clearAll); // recompute and update counts in all lists
|
|
292
294
|
await updateSelectedValuesRepeater(_$w);
|
|
293
295
|
updateTotalJobsCountText(_$w);
|
|
@@ -295,7 +297,15 @@ async function loadJobsRepeater(_$w) {
|
|
|
295
297
|
|
|
296
298
|
function updateOptionsUI(_$w,fieldTitle, fieldId, searchQuery,clearAll=false) {
|
|
297
299
|
let base = optionsByFieldId.get(fieldId) || [];
|
|
300
|
+
console.log("base: ",base)
|
|
301
|
+
console.log("optionsByFieldId : ",optionsByFieldId)
|
|
302
|
+
console.log("countsByFieldId : ",countsByFieldId)
|
|
298
303
|
const countsMap = countsByFieldId.get(fieldId) || new Map();
|
|
304
|
+
console.log("countsMap: ",countsMap)
|
|
305
|
+
console.log("fieldTitle: ",fieldTitle)
|
|
306
|
+
console.log("fieldId: ",fieldId)
|
|
307
|
+
console.log("searchQuery: ",searchQuery)
|
|
308
|
+
console.log("clearAll: ",clearAll)
|
|
299
309
|
|
|
300
310
|
if(dontUpdateThisCheckBox===fieldId && !clearAll)
|
|
301
311
|
{
|
|
@@ -310,6 +320,7 @@ async function loadJobsRepeater(_$w) {
|
|
|
310
320
|
filteredbase.push(element)
|
|
311
321
|
}
|
|
312
322
|
}
|
|
323
|
+
console.log("filteredbase: ",filteredbase)
|
|
313
324
|
// Build display options with counts
|
|
314
325
|
const withCounts = filteredbase.map(o => {
|
|
315
326
|
const count = countsMap.get(o.value)
|
|
@@ -319,6 +330,7 @@ async function loadJobsRepeater(_$w) {
|
|
|
319
330
|
};
|
|
320
331
|
});
|
|
321
332
|
// Apply search
|
|
333
|
+
console.log("withCounts: ",withCounts)
|
|
322
334
|
const filtered = searchQuery
|
|
323
335
|
? withCounts.filter(o => (o.label || '').toLowerCase().includes(searchQuery))
|
|
324
336
|
: withCounts;
|
|
@@ -327,23 +339,19 @@ async function loadJobsRepeater(_$w) {
|
|
|
327
339
|
let prevSelected=[]
|
|
328
340
|
clearAll? prevSelected=[]:prevSelected= _$w(`#${FiltersIds[fieldTitle]}CheckBox`).value;
|
|
329
341
|
const visibleSet = new Set(filtered.map(o => o.value));
|
|
342
|
+
console.log("visibleSet: ",visibleSet)
|
|
330
343
|
const preserved = prevSelected.filter(v => visibleSet.has(v));
|
|
331
|
-
|
|
332
|
-
_$w(`#${FiltersIds[fieldTitle]}MultiBox`).changeState(`${FiltersIds[fieldTitle]}NoResults`);
|
|
333
|
-
}
|
|
334
|
-
else{
|
|
335
|
-
_$w(`#${FiltersIds[fieldTitle]}MultiBox`).changeState(`${FiltersIds[fieldTitle]}Results`);
|
|
344
|
+
console.log("preserved: ",preserved)
|
|
336
345
|
_$w(`#${FiltersIds[fieldTitle]}CheckBox`).options = filtered;
|
|
337
346
|
_$w(`#${FiltersIds[fieldTitle]}CheckBox`).value = preserved;
|
|
338
|
-
}
|
|
339
347
|
}
|
|
340
348
|
|
|
341
|
-
async function applyJobFilters(_$w) {
|
|
349
|
+
async function applyJobFilters(_$w,keyword=false) {
|
|
342
350
|
let tempFilteredJobs=[];
|
|
343
351
|
let finalFilteredJobs=[];
|
|
344
352
|
secondarySearchIsFilled? finalFilteredJobs=allsecondarySearchJobs:finalFilteredJobs=alljobs;
|
|
345
|
-
if(
|
|
346
|
-
finalFilteredJobs=
|
|
353
|
+
if(keyword) {
|
|
354
|
+
finalFilteredJobs=currentJobs
|
|
347
355
|
}
|
|
348
356
|
let addedJobsIds=new Set();
|
|
349
357
|
// AND across categories, OR within each category
|
|
@@ -433,7 +441,6 @@ async function refreshFacetCounts(_$w,clearAll=false) {
|
|
|
433
441
|
function countJobsPerField(jobs) {
|
|
434
442
|
const fieldIds = Array.from(optionsByFieldId.keys());
|
|
435
443
|
const currentJobsIds=jobs.map(job=>job._id);
|
|
436
|
-
|
|
437
444
|
for (const fieldId of fieldIds) {
|
|
438
445
|
let currentoptions=optionsByFieldId.get(fieldId)
|
|
439
446
|
let counter=new Map();
|
|
@@ -492,9 +499,10 @@ async function secondarySearch(_$w,query) {
|
|
|
492
499
|
await refreshFacetCounts(_$w);
|
|
493
500
|
return allsecondarySearchJobs;
|
|
494
501
|
}
|
|
495
|
-
|
|
502
|
+
async function bindSearchInput(_$w) {
|
|
496
503
|
try {
|
|
497
|
-
|
|
504
|
+
await bindPrimarySearch(_$w,allvaluesobjects,alljobs);
|
|
505
|
+
|
|
498
506
|
|
|
499
507
|
const secondarySearchDebounced = debounce(async () => {
|
|
500
508
|
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).value || '').toLowerCase().trim();
|
package/pages/careersPage.js
CHANGED
|
@@ -507,16 +507,11 @@ async function updateMapMarkers(_$w){
|
|
|
507
507
|
}
|
|
508
508
|
|
|
509
509
|
async function handleBrandDropdown(_$w){
|
|
510
|
-
if(siteconfig.disableMultiBrand==="false"){
|
|
511
510
|
const brands=await wixData.query(COLLECTIONS.BRANDS).find();
|
|
512
511
|
if(brands.items.length>1){
|
|
513
512
|
console.log("showing brand dropdown");
|
|
514
513
|
_$w('#dropdownBrand').show();
|
|
515
514
|
}
|
|
516
|
-
}
|
|
517
|
-
else{
|
|
518
|
-
_$w('#dropdownBrand').hide();
|
|
519
|
-
}
|
|
520
515
|
}
|
|
521
516
|
module.exports = {
|
|
522
517
|
careersPageOnReady,
|
package/pages/homePage.js
CHANGED
|
@@ -18,10 +18,13 @@ async function homePageOnReady(_$w,thisObject=null) {
|
|
|
18
18
|
if(siteconfig.categorySearch==="true") {
|
|
19
19
|
const allJobs=await getAllRecords(COLLECTIONS.JOBS);
|
|
20
20
|
const allvaluesobjects=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
await Promise.all([
|
|
22
|
+
bindPrimarySearch(_$w,allvaluesobjects,allJobs),
|
|
23
|
+
loadPrimarySearchRepeater(_$w),
|
|
24
|
+
bindTeamRepeater(_$w),
|
|
25
|
+
bindViewAllButton(_$w),
|
|
26
|
+
|
|
27
|
+
]);
|
|
25
28
|
}
|
|
26
29
|
else{
|
|
27
30
|
|
package/pages/pagesUtils.js
CHANGED
|
@@ -60,36 +60,30 @@ function groupValuesByField(values, refKey) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
function loadPrimarySearchRepeater(_$w) {
|
|
64
|
-
|
|
63
|
+
async function loadPrimarySearchRepeater(_$w) {
|
|
64
|
+
try {
|
|
65
65
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
|
|
66
|
-
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_POSITION_BUTTON).label = itemData.title || '';
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const clickedItemData = data.find(
|
|
72
|
-
(item) => item._id === event.context.itemId,
|
|
73
|
-
);
|
|
74
|
-
location.to(clickedItemData["link-jobs-title"]);
|
|
66
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_POSITION_BUTTON).label = itemData.title || '';
|
|
67
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_POSITION_BUTTON).onClick(() => {
|
|
68
|
+
location.to(itemData["link-jobs-title"]);
|
|
69
|
+
})
|
|
70
|
+
|
|
75
71
|
});
|
|
72
|
+
|
|
76
73
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
|
|
77
74
|
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_CATEGORY_BUTTON).label = itemData.title || '';
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const data = _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data;
|
|
82
|
-
const clickedItemData = data.find(
|
|
83
|
-
(item) => item._id === event.context.itemId,
|
|
84
|
-
);
|
|
85
|
-
const baseUrl = await location.baseUrl();
|
|
86
|
-
const encodedCategory=encodeURIComponent(clickedItemData._id);
|
|
75
|
+
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_CATEGORY_BUTTON).onClick(async () => {
|
|
76
|
+
const baseUrl = await location.baseUrl();
|
|
77
|
+
const encodedCategory=encodeURIComponent(itemData._id);
|
|
87
78
|
location.to(`${baseUrl}/search?category=${encodedCategory}`);
|
|
88
|
-
|
|
89
|
-
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error('Failed to load primary search repeater:', error);
|
|
83
|
+
}
|
|
90
84
|
}
|
|
91
85
|
|
|
92
|
-
function bindPrimarySearch(_$w,allvaluesobjects,alljobs) {
|
|
86
|
+
async function bindPrimarySearch(_$w,allvaluesobjects,alljobs) {
|
|
93
87
|
|
|
94
88
|
const primarySearchDebounced = debounce(async () => {
|
|
95
89
|
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value || '').toLowerCase().trim();
|
|
@@ -116,12 +110,8 @@ _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).onMouseOut(async () => {
|
|
|
116
110
|
|
|
117
111
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onKeyPress(async (event) => {
|
|
118
112
|
if( event.key==='Enter') {
|
|
119
|
-
console.log("primary search input key pressed");
|
|
120
|
-
console.log("_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value: ",_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
121
113
|
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()==='') {
|
|
122
|
-
|
|
123
|
-
const baseUrl = await location.baseUrl();
|
|
124
|
-
location.to(`${baseUrl}/search`);
|
|
114
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
125
115
|
|
|
126
116
|
}
|
|
127
117
|
else {
|
|
@@ -133,11 +123,8 @@ _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onKeyPress(async (even
|
|
|
133
123
|
});
|
|
134
124
|
|
|
135
125
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_BUTTON).onClick(async () => {
|
|
136
|
-
console.log("primary search button clicked");
|
|
137
|
-
console.log("_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value: ",_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
138
126
|
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()==='') {
|
|
139
|
-
|
|
140
|
-
location.to(`${baseUrl}/search`);
|
|
127
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
141
128
|
}
|
|
142
129
|
else {
|
|
143
130
|
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
@@ -168,26 +155,25 @@ async function primarySearch(_$w,query,alljobs) {
|
|
|
168
155
|
let filteredJobs=alljobs.filter(job=>job.title.toLowerCase().includes(query));
|
|
169
156
|
if(filteredJobs.length>0) {
|
|
170
157
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("jobResults");
|
|
158
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data = filteredJobs
|
|
159
|
+
return true;
|
|
171
160
|
}
|
|
172
161
|
else {
|
|
173
162
|
console.log("searching by location")
|
|
163
|
+
//search by location
|
|
174
164
|
filteredJobs=alljobs.filter(job=>job.location.fullLocation.toLowerCase().includes(query));
|
|
175
165
|
if(filteredJobs.length>0) {
|
|
176
166
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("jobResults");
|
|
167
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data = filteredJobs
|
|
168
|
+
return true;
|
|
177
169
|
}
|
|
178
|
-
else{
|
|
179
170
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("noResults");
|
|
180
|
-
|
|
171
|
+
return false;
|
|
181
172
|
}
|
|
182
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data = filteredJobs
|
|
183
|
-
return filteredJobs.length>0;
|
|
184
|
-
|
|
185
173
|
}
|
|
186
174
|
|
|
187
175
|
async function getValueFromValueId(valueId) {
|
|
188
176
|
const result=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
189
|
-
console.log("result: ",result);
|
|
190
|
-
console.log("valueId: ",valueId);
|
|
191
177
|
return result.find(value=>value._id===valueId);
|
|
192
178
|
|
|
193
179
|
}
|
package/pages/positionPage.js
CHANGED
|
@@ -51,7 +51,7 @@ async function getCategoryValueId(customValues) {
|
|
|
51
51
|
}
|
|
52
52
|
if(_$w('#relatedJobsRepNoDepartment')) // when there is no department, we filter based on category
|
|
53
53
|
{
|
|
54
|
-
const relatedJobs
|
|
54
|
+
const relatedJobs=await getRelatedJobs(categoryValueId,item._id,5);
|
|
55
55
|
_$w('#relatedJobsRepNoDepartment').onItemReady(($item, itemData) => {
|
|
56
56
|
$item('#relatedJobTitle').text = itemData.title;
|
|
57
57
|
$item('#relatedJobLocation').text = itemData.location.fullLocation;
|
|
@@ -89,8 +89,7 @@ async function getCategoryValueId(customValues) {
|
|
|
89
89
|
function handleApplyButton(_$w,item) {
|
|
90
90
|
try{
|
|
91
91
|
_$w('#applyButton').target="_blank";//so it can open in new tab
|
|
92
|
-
|
|
93
|
-
const url=buildApplyLinkWithQueryParams(item.applyLink,query);
|
|
92
|
+
const url=appendQueryParams(item.applyLink,query);
|
|
94
93
|
_$w('#applyButton').link=url; //so it can be clicked
|
|
95
94
|
}
|
|
96
95
|
catch(error){
|
|
@@ -100,23 +99,7 @@ async function getCategoryValueId(customValues) {
|
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
|
|
103
|
-
function
|
|
104
|
-
if (!url || typeof url !== 'string' || !url.startsWith('http')) {
|
|
105
|
-
console.warn(`Invalid URL ${url}, button link will not be set`);
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (!query || typeof query !== 'object') {
|
|
110
|
-
console.warn(`Invalid query params ${query}, button link will not be set`);
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return appendQueryParams(url, query);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async function getRelatedJobs({ categoryValueId, itemId, limit = 1000 }) {
|
|
118
|
-
|
|
119
|
-
|
|
102
|
+
async function getRelatedJobs(categoryValueId,itemId,limit=1000) {
|
|
120
103
|
const relatedJobs=await wixData.query(COLLECTIONS.JOBS).include(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES).hasSome(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,[categoryValueId]).ne("_id",itemId).limit(limit).find();
|
|
121
104
|
return relatedJobs.items;
|
|
122
105
|
}
|
|
@@ -15,10 +15,13 @@ async function handleRecentJobsSection(_$w) {
|
|
|
15
15
|
|
|
16
16
|
const currentItem= _$w(supportTeamsPageIds.TEAM_SUPPORT_DYNAMIC_DATASET).getCurrentItem();
|
|
17
17
|
console.log("currentItem: ",currentItem);
|
|
18
|
+
if(supportTeamsPageIds.excludeValues.has(currentItem.title_fld)) {
|
|
19
|
+
console.log("Value is excluded , collapsing recently Jobs Section ");
|
|
20
|
+
await collapseSection(_$w);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
18
23
|
const valueId=supportTeamsPageIds.valueToValueIdMap[currentItem.title_fld]
|
|
19
|
-
console.log("valueId: ",valueId);
|
|
20
24
|
const Value=await getValueFromValueId(valueId);
|
|
21
|
-
console.log("Value: ",Value);
|
|
22
25
|
const latestsJobs=await getLatestJobsByValue(Value);
|
|
23
26
|
|
|
24
27
|
if(latestsJobs.length === 0) {
|
|
@@ -29,17 +32,12 @@ async function handleRecentJobsSection(_$w) {
|
|
|
29
32
|
_$w(supportTeamsPageIds.RECENTLEY_ADDED_JOBS).onItemReady(($item, itemData) => {
|
|
30
33
|
$item(supportTeamsPageIds.JOB_TITLE).text = itemData.title;
|
|
31
34
|
$item(supportTeamsPageIds.JOB_LOCATION).text = itemData.location.fullLocation;
|
|
32
|
-
|
|
35
|
+
$item(supportTeamsPageIds.JOB_TITLE).onClick( () => {
|
|
36
|
+
location.to(itemData["link-jobs-title"]);
|
|
37
|
+
})
|
|
33
38
|
});
|
|
34
39
|
|
|
35
40
|
_$w(supportTeamsPageIds.RECENTLEY_ADDED_JOBS).data = latestsJobs;
|
|
36
|
-
_$w(supportTeamsPageIds.RECENTLEY_ADDED_JOBS_ITEM).onClick((event) => {
|
|
37
|
-
const data = _$w(supportTeamsPageIds.RECENTLEY_ADDED_JOBS).data;
|
|
38
|
-
const clickedItemData = data.find(
|
|
39
|
-
(item) => item._id === event.context.itemId,
|
|
40
|
-
);
|
|
41
|
-
location.to(clickedItemData["link-jobs-title"]);
|
|
42
|
-
});
|
|
43
41
|
|
|
44
42
|
_$w(supportTeamsPageIds.SEE_ALL_JOBS_TEXT).onClick( () => {
|
|
45
43
|
location.to(`/search?category=${Value.title}`);
|
|
@@ -160,7 +160,7 @@ describe('primarySearch function tests', () => {
|
|
|
160
160
|
|
|
161
161
|
|
|
162
162
|
expect(mockprimarySearchMultiBox.changeState).toHaveBeenCalledWith('noResults');
|
|
163
|
-
expect(mockprimarySearcJobResult.data
|
|
163
|
+
expect(mockprimarySearcJobResult.data).toBeNull();
|
|
164
164
|
});
|
|
165
165
|
|
|
166
166
|
it('should fill category repeater when clicking on empty primary search input', async () => {
|