sr-npm 1.7.916 → 1.7.918

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.
@@ -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",
@@ -91,22 +90,27 @@ const supportTeamsPageIds={
91
90
  MOST_RECENT_JOBS_TITLE: "#mostRecentJobsTitle",
92
91
  valueToValueIdMap: {
93
92
  "Human Resouces":"PeopleSupport",
94
- "Buying":"Merchandise",
95
- "Tech":"InformationServices",
96
- "Planning":"Merchandise",
93
+ "Merchandise - Buying":"Merchandise",
94
+ "Technology, Data and Digital":"InformationServices",
95
+ "Merchandise - Planning":"Merchandise",
97
96
  "Digital":"ecommerceandDigital",// this field doesnt exists in the database
98
- "Marketing":"Marketing",
99
- "Finance":"Finance",// this field doesnt exists in the database
97
+ "Marketing and Market Media":"Marketing",
98
+ "Finance, Property and Legal":"Finance",// this field doesnt exists in the database
100
99
  "Services":"ServicesInstallation",
101
- "Design":"Merchandise",
102
- "Retail Operations":"Operations",// this field doesnt exists in the database
100
+ "Merchandise - Design and Sourcing":"Merchandise",
101
+ "Store Operations":"Operations",// this field doesnt exists in the database
103
102
  "Data":"InsightsandDataScience",// this field doesnt exists in the database
104
103
  "Property":"Property",// this field doesnt exists in the database,
105
104
  "Legal":"Legal",// this field doesnt exists in the database,
106
- "Supply Chain":"Logistics",
107
- "Contact Centre":"CustomerEngagementCentres",// this field doesnt exists in the database
105
+ "Supply Chain and Logistics":"Logistics",
106
+ "Contact Centres":"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
+ "Noel Leeming Commercial",
111
+ "Noel Leeming Services",
112
+ "Sustainability"
113
+ ])
110
114
  }
111
115
  const LINKS={
112
116
  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].add(position.id) : customValuesToJobs[visibility]=new Set([position.id])
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].add(position.id) : customValuesToJobs[position.typeOfEmployment.id]=new Set([position.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].add(position.id) : customValuesToJobs[valueId]=new Set([position.id])
104
+ customValuesToJobs[valueId] ? customValuesToJobs[valueId].push(position.id) : customValuesToJobs[valueId]=[position.id]
105
105
  }
106
106
  }
107
107
  async function saveJobsDataToCMS() {
@@ -111,9 +111,7 @@ async function saveJobsDataToCMS() {
111
111
  const customFieldsValues = {}
112
112
 
113
113
  const {companyId,templateType} = await getApiKeys();
114
- if(siteconfig===undefined) {
115
- await getSiteConfig();
116
- }
114
+
117
115
  // bulk insert to jobs collection without descriptions first
118
116
  const jobsData = sourcePositions.map(position => {
119
117
 
@@ -137,7 +135,7 @@ async function saveJobsDataToCMS() {
137
135
  country: position.location?.country || '',
138
136
  remote: position.location?.remote || false,
139
137
  language: position.language?.label || '',
140
- brand: siteconfig.disableMultiBrand==="false" ? getBrand(position.customField) : '',
138
+ brand: getBrand(position.customField),
141
139
  jobDescription: null, // Will be filled later
142
140
  employmentType: position.typeOfEmployment.label,
143
141
  releasedDate: position.releasedDate
@@ -151,9 +149,11 @@ async function saveJobsDataToCMS() {
151
149
  }
152
150
  return basicJob;
153
151
  });
154
-
152
+ if(siteconfig===undefined) {
153
+ await getSiteConfig();
154
+ }
155
155
  if (siteconfig.customFields==="true") {
156
- await populateCustomFieldsCollection(customFieldsLabels,templateType);
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, Array.from(customValuesToJobs[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,templateType) {
200
+ async function populateCustomFieldsCollection(customFields) {
201
201
  let fieldstoinsert=[]
202
202
  customFields["employmentType"] = "Employment Type";
203
- if(templateType===TEMPLATE_TYPE.INTERNAL){
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].size,
224
- jobIds:Array.from(customValuesToJobs[valueId]),
221
+ count:customValuesToJobs[valueId].length,
222
+ jobIds:customValuesToJobs[valueId],
225
223
  })
226
224
  }
227
225
 
@@ -468,15 +466,9 @@ async function aggregateJobs() {
468
466
 
469
467
  async function referenceJobs() {
470
468
  console.log("Reference jobs");
471
- if(siteconfig===undefined) {
472
- await getSiteConfig();
473
- }
474
469
  await referenceJobsToField({ referenceField: JOBS_COLLECTION_FIELDS.DEPARTMENT_REF, sourceCollection: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT, jobField: JOBS_COLLECTION_FIELDS.DEPARTMENT });
475
470
  await referenceJobsToField({ referenceField: JOBS_COLLECTION_FIELDS.CITY, sourceCollection: COLLECTIONS.CITIES, jobField: JOBS_COLLECTION_FIELDS.CITY_TEXT });
476
- if(siteconfig.disableMultiBrand==="false"){
477
- await referenceJobsToField({ referenceField: JOBS_COLLECTION_FIELDS.BRAND_REF, sourceCollection: COLLECTIONS.BRANDS, jobField: JOBS_COLLECTION_FIELDS.BRAND });
478
- }
479
-
471
+ await referenceJobsToField({ referenceField: JOBS_COLLECTION_FIELDS.BRAND_REF, sourceCollection: COLLECTIONS.BRANDS, jobField: JOBS_COLLECTION_FIELDS.BRAND });
480
472
  console.log("finished referencing jobs");
481
473
  }
482
474
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.916",
3
+ "version": "1.7.918",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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
- loadJobsRepeater(_$w);
27
- loadPrimarySearchRepeater(_$w);
28
- await loadFilters(_$w);
29
- loadSelectedValuesRepeater(_$w);
30
- bindSearchInput(_$w);
31
- loadPaginationButtons(_$w);
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
- if(applyFiltering || keywordAllJobs) {
77
- await updateJobsAndNumbersAndFilters(_$w);
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
- updateSelectedValuesRepeater(_$w);
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
- if(filtered.length===0) {
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(keywordAllJobs) {
346
- finalFilteredJobs=keywordAllJobs
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
- function bindSearchInput(_$w) {
502
+ async function bindSearchInput(_$w) {
496
503
  try {
497
- bindPrimarySearch(_$w,allvaluesobjects,alljobs);
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();
@@ -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
- bindPrimarySearch(_$w,allvaluesobjects,allJobs);
22
- loadPrimarySearchRepeater(_$w)
23
- bindTeamRepeater(_$w)
24
- bindViewAllButton(_$w)
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
 
@@ -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
- _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER_ITEM).onClick((event) => {
70
- const data = _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER_ITEM).data;
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
- _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER_ITEM).onClick(async (event) => {
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
- // _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
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
- const baseUrl = await location.baseUrl();
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
  }
@@ -10,7 +10,7 @@ const {
10
10
  } = require('../public/utils');
11
11
 
12
12
 
13
-
13
+ let siteconfig;
14
14
 
15
15
  async function positionPageOnReady(_$w) {
16
16
 
@@ -32,11 +32,24 @@ async function getCategoryValueId(customValues) {
32
32
 
33
33
 
34
34
  async function bind(_$w) {
35
+ siteconfig=await wixData.query(COLLECTIONS.SITE_CONFIGS).find().then(result => result.items[0]);
35
36
  _$w('#datasetJobsItem').onReady(async () => {
36
37
 
37
38
  const item = await _$w('#datasetJobsItem').getCurrentItem();
39
+ if(siteconfig.customFields==="true"){
38
40
  const multiRefField=await getPositionWithMultiRefField(item._id);
39
41
  const categoryValueId=await getCategoryValueId(multiRefField);
42
+ const relatedJobs=await getRelatedJobs(categoryValueId,item._id,5);
43
+ if(_$w('#relatedJobsRepNoDepartment')) // when there is no department, we filter based on category
44
+ {
45
+ const relatedJobs=await getRelatedJobs(categoryValueId,item._id,5);
46
+ _$w('#relatedJobsRepNoDepartment').onItemReady(($item, itemData) => {
47
+ $item('#relatedJobTitle').text = itemData.title;
48
+ $item('#relatedJobLocation').text = itemData.location.fullLocation;
49
+ });
50
+ _$w('#relatedJobsRepNoDepartment').data = relatedJobs;
51
+ }
52
+ }
40
53
  handleReferFriendButton(_$w,item);
41
54
  handleApplyButton(_$w,item);
42
55
 
@@ -49,25 +62,18 @@ async function getCategoryValueId(customValues) {
49
62
  {
50
63
  _$w('#additionalInfoText').text = htmlToText(item.jobDescription.additionalInformation.text);
51
64
  }
52
- if(_$w('#relatedJobsRepNoDepartment')) // when there is no department, we filter based on category
53
- {
54
- const relatedJobs = await getRelatedJobs({ categoryValueId, itemId: item._id ,limit:5});
55
- _$w('#relatedJobsRepNoDepartment').onItemReady(($item, itemData) => {
56
- $item('#relatedJobTitle').text = itemData.title;
57
- $item('#relatedJobLocation').text = itemData.location.fullLocation;
58
- });
59
- _$w('#relatedJobsRepNoDepartment').data = relatedJobs;
60
-
61
-
62
- }
65
+
63
66
  });
67
+ if(isElementExistOnPage(_$w('#relatedJobsNoDepartmentItem')))
68
+ {
64
69
  _$w('#relatedJobsNoDepartmentItem').onClick((event) => {
65
70
  const data = _$w("#relatedJobsRepNoDepartment").data;
66
- const clickedItemData = data.find(
67
- (item) => item._id === event.context.itemId,
68
- );
69
- location.to(clickedItemData["link-jobs-title"]);
70
- });
71
+ const clickedItemData = data.find(
72
+ (item) => item._id === event.context.itemId,
73
+ );
74
+ location.to(clickedItemData["link-jobs-title"]);
75
+ });
76
+ }
71
77
  if(isElementExistOnPage(_$w('#relatedJobsDataset')))
72
78
  {
73
79
  _$w('#relatedJobsDataset').onReady(() => {
@@ -89,8 +95,7 @@ async function getCategoryValueId(customValues) {
89
95
  function handleApplyButton(_$w,item) {
90
96
  try{
91
97
  _$w('#applyButton').target="_blank";//so it can open in new tab
92
-
93
- const url=buildApplyLinkWithQueryParams(item.applyLink,query);
98
+ const url=appendQueryParams(item.applyLink,query);
94
99
  _$w('#applyButton').link=url; //so it can be clicked
95
100
  }
96
101
  catch(error){
@@ -100,23 +105,7 @@ async function getCategoryValueId(customValues) {
100
105
  }
101
106
  }
102
107
 
103
- function buildApplyLinkWithQueryParams(url, query) {
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
-
108
+ async function getRelatedJobs(categoryValueId,itemId,limit=1000) {
120
109
  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
110
  return relatedJobs.items;
122
111
  }
@@ -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.length).toBe(0);
163
+ expect(mockprimarySearcJobResult.data).toBeNull();
164
164
  });
165
165
 
166
166
  it('should fill category repeater when clicking on empty primary search input', async () => {