sr-npm 1.0.21 → 1.2.1

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.
@@ -3,12 +3,12 @@ const {wixData} = require('wix-data');
3
3
  const { window } = require('@wix/site-window');
4
4
  const { query,queryParams,onChange} = require("wix-location-frontend");
5
5
  const { location } = require("@wix/site-location");
6
-
7
- const {
8
- debounce,
9
- getFilter,
10
- } = require('../public/filterUtils');
6
+ const { COLLECTIONS } = require('../backend/collectionConsts');
7
+ const { careersMultiBoxesPageOnReady } = require('./careersMultiBoxesPage');
8
+ const { debounce, getFilter} = require('../public/filterUtils');
9
+ const { CAREERS_PAGE_SELECTORS, FILTER_FIELDS } = require('../public/selectors');
11
10
  const { filterBrokenMarkers } = require('../public/utils');
11
+
12
12
  let currentLoadedItems =100;
13
13
  const itemsPerPage = 100;
14
14
  let allJobs=[]
@@ -20,32 +20,59 @@ const {
20
20
  let queryDepartmentVar;
21
21
  let queryLocationVar;
22
22
  let queryJobTypeVar;
23
+ let queryBrandVar;
23
24
  let searchInputBlurredFirstTime=true;
24
- let deletedParam=false;
25
- async function careersPageOnReady(_$w,thisObject,queryParams) {
26
- console.log("queryParams: ", queryParams);
27
- const { page, keyWord, department, location,jobType } = queryParams;
28
- queryPageVar=page;
29
- queryKeyWordVar=keyWord;
30
- queryDepartmentVar=department;
31
- queryLocationVar=location;
32
- queryJobTypeVar=jobType;
33
- thisObjectVar=thisObject;
34
- allJobs=await getAllPositions();
35
- await activateAutoLoad(_$w);
36
- await bind(_$w);
37
- await init(_$w);
38
- await handleUrlParams(_$w);
25
+ let siteconfig;
26
+
27
+ async function careersPageOnReady(_$w,thisObject=null,queryParams=null) {
28
+ if(siteconfig===undefined) {
29
+ const queryResult = await wixData.query(COLLECTIONS.SITE_CONFIGS).find();
30
+ siteconfig = queryResult.items[0];
31
+ }
32
+
33
+ if (await window.formFactor() === "Mobile") {
34
+ handleFilterInMobile(_$w);
35
+ }
36
+
37
+ if(siteconfig.customFields==="true") {
38
+ await careersMultiBoxesPageOnReady(_$w,queryParams);
39
+ }
40
+ else{
41
+ console.log("queryParams: ", queryParams);
42
+ const { page, keyWord, department, location,jobType,brand } = queryParams;
43
+ queryPageVar=page;
44
+ queryKeyWordVar=keyWord;
45
+ queryDepartmentVar=department;
46
+ queryLocationVar=location;
47
+ queryJobTypeVar=jobType;
48
+ queryBrandVar=brand;
49
+ thisObjectVar=thisObject;
50
+ allJobs = await getAllPositions();
51
+
52
+ activateAutoLoad(_$w);
53
+ await bind(_$w);
54
+ init(_$w);
55
+ await handleBrandDropdown(_$w);
56
+ await handleUrlParams(_$w);
39
57
 
58
+ }
59
+
60
+
61
+ }
62
+
63
+ function handleFilterInMobile(_$w) {
64
+ _$w(CAREERS_PAGE_SELECTORS.FILTER_ICON).onClick(()=>{
65
+ _$w(CAREERS_PAGE_SELECTORS.FILTER_BOX).expand();
66
+ });
40
67
  }
41
68
 
42
69
 
43
70
  function activateAutoLoad(_$w)
44
71
  {
45
- _$w("#jobsDataset").onReady(() => {
72
+ _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).onReady(() => {
46
73
  updateCount(_$w);
47
- _$w("#section2").onViewportEnter(() => {
48
- if (currentLoadedItems<_$w("#jobsDataset").getTotalCount()) {
74
+ _$w(CAREERS_PAGE_SELECTORS.FOOTER).onViewportEnter(() => {
75
+ if (currentLoadedItems<_$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).getTotalCount()) {
49
76
  loadMoreJobs(_$w);
50
77
  }
51
78
  else {
@@ -65,10 +92,12 @@ async function loadMoreJobs(_$w) {
65
92
  pageParamSet = Number(pageParamSet) + 1;
66
93
  }
67
94
  if (shouldLoad) {
68
- _$w("#jobsDataset").loadMore();
95
+ _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).loadMore();
69
96
  console.log("loading more jobs");
97
+
70
98
  currentLoadedItems = currentLoadedItems + itemsPerPage;
71
- const data = _$w("#positionsRepeater").data;
99
+ const data = _$w(CAREERS_PAGE_SELECTORS.POSITIONS_REPEATER).data;
100
+
72
101
  console.log("data length is : ", data.length);
73
102
  setPageParamInUrl();
74
103
  }
@@ -91,6 +120,9 @@ async function handleUrlParams(_$w) {
91
120
  if (queryKeyWordVar) {
92
121
  await handleKeyWordParam(_$w,queryKeyWordVar);
93
122
  }
123
+ if (queryBrandVar && _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).isVisible) { //if it is not visible, ignore it
124
+ await handleBrandParam(_$w,queryBrandVar);
125
+ }
94
126
  if (queryPageVar) {
95
127
  await handlePageParam(_$w);
96
128
  }
@@ -107,7 +139,7 @@ async function handleUrlParams(_$w) {
107
139
  }
108
140
 
109
141
  async function handleKeyWordParam(_$w,keyWord) {
110
- _$w('#searchInput').value = keyWord;
142
+ _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT).value = keyWord;
111
143
  // Use applyFilters to maintain consistency instead of directly setting filter
112
144
  }
113
145
 
@@ -127,18 +159,18 @@ async function handlePageParam(_$w) {
127
159
  //scrolls a bit to load the dataset data
128
160
  await window.scrollTo(0, 200,{scrollAnimation:false});
129
161
  for (let i = 2; i <= queryPageVar; i++) {
130
- await _$w("#jobsDataset").loadMore();
162
+ await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).loadMore();
131
163
  currentLoadedItems=currentLoadedItems+itemsPerPage
132
164
  }
133
165
  // the timeout is to wait for the repeater to render, then scroll to the last item.
134
166
  setTimeout(() => {
135
- const data = _$w("#positionsRepeater").data;
167
+ const data = _$w(CAREERS_PAGE_SELECTORS.POSITIONS_REPEATER).data;
136
168
  if (data && data.length > 0) {
137
169
  //the dataset each time it loads 100 items
138
170
  const lastIndex = data.length - itemsPerPage;
139
- _$w("#positionsRepeater").forEachItem(async ($item, itemData, index) => {
171
+ _$w(CAREERS_PAGE_SELECTORS.POSITIONS_REPEATER).forEachItem(async ($item, itemData, index) => {
140
172
  if (index === lastIndex) {
141
- await $item("#positionItem").scrollTo();
173
+ await $item(CAREERS_PAGE_SELECTORS.POSITION_ITEM).scrollTo();
142
174
  console.log("finishied scrolling inside handlePageParam")
143
175
  }
144
176
  });
@@ -149,40 +181,40 @@ async function handlePageParam(_$w) {
149
181
  }
150
182
 
151
183
  async function bind(_$w) {
152
- await _$w('#jobsDataset').onReady(async () => {
184
+ await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).onReady(async () => {
153
185
  await updateCount(_$w);
154
186
  await updateMapMarkers(_$w);
155
187
 
156
188
  });
157
189
 
158
190
  if (await window.formFactor() === "Mobile") {
159
- _$w('#dropdownsContainer').collapse();
191
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_CONTAINER).collapse();
160
192
  }
161
193
 
162
194
  }
163
195
 
164
196
  function init(_$w) {
165
197
  const debouncedSearch = debounce(()=>applyFilters(_$w), 400,thisObjectVar);
166
- _$w('#searchInput').onInput(debouncedSearch);
167
- _$w('#searchInput').onBlur(()=>{
168
- if(searchInputBlurredFirstTime && _$w('#searchInput').value.trim() !== '')
198
+ _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT).onInput(debouncedSearch);
199
+ _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT).onBlur(()=>{
200
+ if(searchInputBlurredFirstTime && _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT).value.trim() !== '')
169
201
  {
170
- _$w('#searchInput').focus();
202
+ _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT).focus();
171
203
  searchInputBlurredFirstTime=false;
172
204
  }
173
205
  });
174
- _$w('#dropdownDepartment, #dropdownLocation, #dropdownJobType').onChange(()=>{
206
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT, CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION, CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE, CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).onChange(()=>{
175
207
  console.log("dropdown onChange is triggered");
176
208
  applyFilters(_$w);
177
209
  });
178
- _$w('#resetFiltersButton, #clearSearch').onClick(()=>resetFilters(_$w));
210
+ _$w(CAREERS_PAGE_SELECTORS.RESET_FILTERS_BUTTON, CAREERS_PAGE_SELECTORS.CLEAR_SEARCH).onClick(()=>resetFilters(_$w));
179
211
 
180
- _$w('#openFiltersButton').onClick(()=>{
181
- _$w('#dropdownsContainer, #closeFiltersButton').expand();
212
+ _$w(CAREERS_PAGE_SELECTORS.OPEN_FILTERS_BUTTON).onClick(()=>{
213
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_CONTAINER, CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).expand();
182
214
  });
183
215
 
184
- _$w('#closeFiltersButton').onClick(()=>{
185
- _$w('#dropdownsContainer, #closeFiltersButton').collapse();
216
+ _$w(CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).onClick(()=>{
217
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_CONTAINER, CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).collapse();
186
218
  });
187
219
 
188
220
  //URL onChange
@@ -201,7 +233,7 @@ async function handleBackAndForth(_$w){
201
233
  else{
202
234
  queryDepartmentVar=undefined;
203
235
  deletedParam=true;
204
- _$w('#dropdownDepartment').value = '';
236
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT).value = '';
205
237
  }
206
238
  if(newQueryParams.location){
207
239
  queryLocationVar=newQueryParams.location;
@@ -209,7 +241,7 @@ async function handleBackAndForth(_$w){
209
241
  else{
210
242
  queryLocationVar=undefined;
211
243
  deletedParam=true
212
- _$w('#dropdownLocation').value = '';
244
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION).value = '';
213
245
  }
214
246
  if(newQueryParams.keyWord){
215
247
  queryKeyWordVar=newQueryParams.keyWord;
@@ -217,7 +249,7 @@ async function handleBackAndForth(_$w){
217
249
  else{
218
250
  queryKeyWordVar=undefined;
219
251
  deletedParam=true;
220
- _$w('#searchInput').value = '';
252
+ _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT).value = '';
221
253
  }
222
254
  if(newQueryParams.jobType){
223
255
  queryJobTypeVar=newQueryParams.jobType;
@@ -225,8 +257,18 @@ async function handleBackAndForth(_$w){
225
257
  else{
226
258
  queryJobTypeVar=undefined;
227
259
  deletedParam=true;
228
- _$w('#dropdownJobType').value = '';
260
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE).value = '';
261
+ }
262
+ if(_$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).isVisible){
263
+ if(newQueryParams.brand){
264
+ queryBrandVar=newQueryParams.brand;
229
265
  }
266
+ else{
267
+ queryBrandVar=undefined;
268
+ deletedParam=true;
269
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).value = '';
270
+ }
271
+ }
230
272
  await handleUrlParams(_$w);
231
273
 
232
274
  }
@@ -234,10 +276,11 @@ async function handleBackAndForth(_$w){
234
276
  async function applyFilters(_$w, skipUrlUpdate = false) {
235
277
  console.log("applying filters");
236
278
  const dropdownFiltersMapping = [
237
- { elementId: '#dropdownDepartment', field: 'department', value: _$w('#dropdownDepartment').value },
238
- { elementId: '#dropdownLocation', field: 'cityText', value: _$w('#dropdownLocation').value },
239
- { elementId: '#dropdownJobType', field: 'remote', value: _$w('#dropdownJobType').value},
240
- { elementId: '#searchInput', field: 'title', value: _$w('#searchInput').value }
279
+ { elementId: CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT, field: 'department', value: _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT).value },
280
+ { elementId: CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION, field: 'cityText', value: _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION).value },
281
+ { elementId: CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE, field: 'remote', value: _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE).value},
282
+ { elementId: CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND, field: 'brand', value: _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).value},
283
+ { elementId: CAREERS_PAGE_SELECTORS.SEARCH_INPUT, field: 'title', value: _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT).value }
241
284
  ];
242
285
  console.log("dropdownFiltersMapping: ", dropdownFiltersMapping);
243
286
 
@@ -256,16 +299,16 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
256
299
  // build filters
257
300
  if (filter.value && filter.value.trim() !== '') {
258
301
  if (!skipUrlUpdate) {
259
- if(filter.field === 'title'){
302
+ if(filter.field === FILTER_FIELDS.SEARCH){
260
303
  queryParams.add({ keyWord: filter.value });
261
304
  }
262
- if(filter.field === 'department'){
305
+ if(filter.field === FILTER_FIELDS.DEPARTMENT){
263
306
  queryParams.add({ department: encodeURIComponent(filter.value) });
264
307
  }
265
- if(filter.field === 'cityText'){
308
+ if(filter.field === FILTER_FIELDS.LOCATION){
266
309
  queryParams.add({ location: encodeURIComponent(filter.value) });
267
310
  }
268
- if(filter.field === 'remote'){
311
+ if(filter.field === FILTER_FIELDS.JOB_TYPE){
269
312
  if(filter.value === 'true'){
270
313
  queryParams.add({ jobType: encodeURIComponent("remote") });
271
314
  }
@@ -273,8 +316,11 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
273
316
  queryParams.add({ jobType: encodeURIComponent("onsite") });
274
317
  }
275
318
  }
319
+ if(filter.field === FILTER_FIELDS.BRAND){
320
+ queryParams.add({ brand: encodeURIComponent(filter.value) });
321
+ }
276
322
  }
277
- if(filter.field === 'remote') {
323
+ if(filter.field === FILTER_FIELDS.JOB_TYPE) {
278
324
  value = filter.value === 'true';
279
325
  } else {
280
326
  value = filter.value;
@@ -283,54 +329,58 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
283
329
  }
284
330
  else{
285
331
  if (!skipUrlUpdate) {
286
- if(filter.field === 'title'){
332
+ if(filter.field === FILTER_FIELDS.SEARCH){
287
333
  queryParams.remove(["keyWord" ]);
288
334
  }
289
- if(filter.field === 'department'){
335
+ if(filter.field === FILTER_FIELDS.DEPARTMENT){
290
336
  console.log("removing department from url")
291
337
  queryParams.remove(["department" ]);
292
338
  }
293
- if(filter.field === 'cityText'){
339
+ if(filter.field === FILTER_FIELDS.LOCATION){
294
340
  console.log("removing location from url")
295
341
  queryParams.remove(["location" ]);
296
342
  }
297
- if(filter.field === 'remote'){
343
+ if(filter.field === FILTER_FIELDS.JOB_TYPE){
298
344
  console.log("removing jobType from url")
299
345
  queryParams.remove(["jobType" ]);
300
346
  }
347
+ if(filter.field === FILTER_FIELDS.BRAND){
348
+ console.log("removing brand from url")
349
+ queryParams.remove(["brand" ]);
350
+ }
301
351
  }
302
352
  }
303
353
  });
304
354
 
305
355
  const filter = await getFilter(filters, 'and');
306
- await _$w('#jobsDataset').setFilter(filter);
307
- await _$w('#jobsDataset').refresh();
356
+ await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).setFilter(filter);
357
+ await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).refresh();
308
358
 
309
359
  const count = await updateCount(_$w);
310
360
  console.log("updating map markers");
311
361
  await updateMapMarkers(_$w);
312
362
  console.log("updating map markers completed");
313
- count ? _$w('#resultsMultiState').changeState('results') : _$w('#resultsMultiState').changeState('noResults');
363
+ count ? _$w(CAREERS_PAGE_SELECTORS.RESULTS_MULTI_STATE).changeState('results') : _$w(CAREERS_PAGE_SELECTORS.RESULTS_MULTI_STATE).changeState('noResults');
314
364
 
315
365
 
316
366
  // Update reset button state
317
367
  const hasActiveFilters = filters.length > 0;
318
- hasActiveFilters? _$w('#resetFiltersButton').enable() : _$w('#resetFiltersButton').disable();
368
+ hasActiveFilters? _$w(CAREERS_PAGE_SELECTORS.RESET_FILTERS_BUTTON).enable() : _$w(CAREERS_PAGE_SELECTORS.RESET_FILTERS_BUTTON).disable();
319
369
 
320
370
 
321
371
  }
322
372
 
323
373
  async function resetFilters(_$w) {
324
- _$w('#searchInput, #dropdownDepartment, #dropdownLocation, #dropdownJobType').value = '';
374
+ _$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 = '';
325
375
 
326
- await _$w('#jobsDataset').setFilter(wixData.filter());
327
- await _$w('#jobsDataset').refresh();
376
+ await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).setFilter(wixData.filter());
377
+ await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).refresh();
328
378
 
329
- _$w('#resultsMultiState').changeState('results');
379
+ _$w(CAREERS_PAGE_SELECTORS.RESULTS_MULTI_STATE).changeState('results');
330
380
 
331
- _$w('#resetFiltersButton').disable();
381
+ _$w(CAREERS_PAGE_SELECTORS.RESET_FILTERS_BUTTON).disable();
332
382
 
333
- queryParams.remove(["keyWord", "department","page","location","jobType"]);
383
+ queryParams.remove(["keyWord", "department","page","location","jobType","brand"]);
334
384
 
335
385
 
336
386
  await updateCount(_$w);
@@ -340,7 +390,7 @@ async function resetFilters(_$w) {
340
390
  }
341
391
 
342
392
  async function updateCount(_$w) {
343
- const count = await _$w('#jobsDataset').getTotalCount();
393
+ const count = await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).getTotalCount();
344
394
  _$w('#numOfPositionText').text = `Showing ${count} Open Positions`;
345
395
 
346
396
  return count;
@@ -351,19 +401,19 @@ async function handleDepartmentParam(_$w,department) {
351
401
 
352
402
 
353
403
 
354
- let dropdownOptions = _$w('#dropdownDepartment').options;
404
+ let dropdownOptions = _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT).options;
355
405
  console.log("dropdown options:", dropdownOptions);
356
406
  const optionsFromCMS=await wixData.query("AmountOfJobsPerDepartment").find();
357
407
  //+1 because of the "All" option
358
408
 
359
409
  if(dropdownOptions.length!==optionsFromCMS.items.length+1){
360
- fixDropdownOptions('#dropdownDepartment',optionsFromCMS, _$w);
410
+ fixDropdownOptions(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT,optionsFromCMS, _$w);
361
411
  }
362
412
 
363
- if (_$w('#dropdownDepartment').options.find(option => option.value === departmentValue))
413
+ if (_$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT).options.find(option => option.value === departmentValue))
364
414
  {
365
415
  console.log("department value found in dropdown options ",departmentValue);
366
- _$w('#dropdownDepartment').value = departmentValue;
416
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT).value = departmentValue;
367
417
  }
368
418
  else{
369
419
  console.warn("department value not found in dropdown options");
@@ -392,18 +442,18 @@ function fixDropdownOptions(dropdown,optionsFromCMS, _$w){
392
442
 
393
443
  async function handleLocationParam(_$w,location) {
394
444
  const locationValue = decodeURIComponent(location);
395
- let dropdownOptions = _$w('#dropdownLocation').options;
445
+ let dropdownOptions = _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION).options;
396
446
  console.log("location dropdown options:", dropdownOptions);
397
447
  const optionsFromCMS=await wixData.query("cities").find();
398
448
  //+1 because of the "All" option
399
449
  if(dropdownOptions.length!==optionsFromCMS.items.length+1){
400
- fixDropdownOptions('#dropdownLocation',optionsFromCMS, _$w);
450
+ fixDropdownOptions(CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION,optionsFromCMS, _$w);
401
451
  }
402
452
 
403
- const option=_$w('#dropdownLocation').options.find(option => option.value.toLowerCase() === locationValue.toLowerCase())
453
+ const option=_$w(CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION).options.find(option => option.value.toLowerCase() === locationValue.toLowerCase())
404
454
 
405
455
  if(option){
406
- _$w('#dropdownLocation').value = option.value;
456
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION).value = option.value;
407
457
  }
408
458
  else{
409
459
  console.warn("location value not found in dropdown options");
@@ -412,9 +462,27 @@ async function handleLocationParam(_$w,location) {
412
462
 
413
463
  }
414
464
 
465
+ async function handleBrandParam(_$w,brand){
466
+ const brandValue = decodeURIComponent(brand);
467
+ let dropdownOptions = _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).options;
468
+ console.log("brand dropdown options:", dropdownOptions);
469
+ const optionsFromCMS=await wixData.query(COLLECTIONS.BRANDS).find();
470
+ if(dropdownOptions.length!==optionsFromCMS.items.length+1){
471
+ fixDropdownOptions(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND,optionsFromCMS, _$w);
472
+ }
473
+ const option=_$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).options.find(option => option.value.toLowerCase() === brandValue.toLowerCase())
474
+ if(option){
475
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).value = option.value;
476
+ }
477
+ else{
478
+ console.warn("brand value not found in dropdown options");
479
+ queryParams.remove(["brand"]);
480
+ }
481
+ }
482
+
415
483
  async function handleJobTypeParam(_$w,jobType) {
416
484
  const jobTypeValue = decodeURIComponent(jobType);
417
- let dropdownOptions = _$w('#dropdownJobType').options;
485
+ let dropdownOptions = _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE).options;
418
486
  console.log("jobType dropdown options:", dropdownOptions);
419
487
  let option;
420
488
  if(jobTypeValue.toLowerCase()==="remote"){
@@ -424,7 +492,7 @@ async function handleJobTypeParam(_$w,jobType) {
424
492
  option="false";
425
493
  }
426
494
  if(option){
427
- _$w('#dropdownJobType').value = option;
495
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE).value = option;
428
496
  }
429
497
  else{
430
498
  console.warn("jobType value not found in dropdown options");
@@ -433,8 +501,8 @@ async function handleJobTypeParam(_$w,jobType) {
433
501
  }
434
502
 
435
503
  async function updateMapMarkers(_$w){
436
- const numOfItems = await _$w('#jobsDataset').getTotalCount();
437
- const items = await _$w('#jobsDataset').getItems(0, numOfItems);
504
+ const numOfItems = await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).getTotalCount();
505
+ const items = await _$w(CAREERS_PAGE_SELECTORS.JOBS_DATASET).getItems(0, numOfItems);
438
506
  const markers = filterBrokenMarkers(items.items).map(item => {
439
507
  const location = item.locationAddress.location;
440
508
  return {
@@ -447,11 +515,22 @@ async function updateMapMarkers(_$w){
447
515
  };
448
516
  });
449
517
  //@ts-ignore
450
- _$w('#googleMaps').setMarkers(markers);
518
+ _$w(CAREERS_PAGE_SELECTORS.GOOGLE_MAPS).setMarkers(markers);
451
519
 
452
520
  }
453
521
 
454
-
522
+ async function handleBrandDropdown(_$w){
523
+ if(siteconfig.disableMultiBrand==="false"){
524
+ const brands=await wixData.query(COLLECTIONS.BRANDS).find();
525
+ if(brands.items.length>1){
526
+ console.log("showing brand dropdown");
527
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).show();
528
+ }
529
+ }
530
+ else{
531
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).hide();
532
+ }
533
+ }
455
534
  module.exports = {
456
535
  careersPageOnReady,
457
536
  };
package/pages/homePage.js CHANGED
@@ -5,23 +5,37 @@ const {
5
5
  const { handleOnLocationClick } = require('../public/mapUtils');
6
6
  const { filterBrokenMarkers } = require('../public/utils');
7
7
  const { location } = require('@wix/site-location');
8
+ const {wixData} = require('wix-data');
9
+ const { COLLECTIONS } = require('../backend/collectionConsts');
10
+ const { bindPrimarySearch,getAllRecords,loadPrimarySearchRepeater } = require('./pagesUtils');
8
11
  let thisObjectVar;
9
12
  let searchByCityFlag=false;
10
- async function homePageOnReady(_$w,thisObject) {
13
+ let loadedCategories=false;
14
+ async function homePageOnReady(_$w,thisObject=null) {
15
+
16
+ const queryResult = await wixData.query(COLLECTIONS.SITE_CONFIGS).find();
17
+ const siteconfig = queryResult.items[0];
18
+ if(siteconfig.categorySearch==="true") {
19
+ const allJobs=await getAllRecords(COLLECTIONS.JOBS);
20
+ const allvaluesobjects=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
21
+ bindPrimarySearch(_$w,allvaluesobjects,allJobs);
22
+ loadPrimarySearchRepeater(_$w)
23
+ bindTeamRepeater(_$w)
24
+ bindViewAllButton(_$w)
25
+ }
26
+ else{
27
+
11
28
  thisObjectVar=thisObject;
12
29
  await bind(_$w);
13
30
  await init(_$w);
31
+ }
14
32
 
15
33
  }
16
34
 
17
35
  function bind(_$w) {
18
- _$w('#teamRepeater').onItemReady(($item, itemData) => {
19
- $item('#teamButton').label = `View ${itemData.count} Open Positions`;
20
- $item('#teamButton').onClick(()=>{
21
- const department = encodeURIComponent(itemData.title);
22
- location.to(`/positions?department=${department}`);
23
- });
24
- });
36
+
37
+ bindTeamRepeater(_$w);
38
+
25
39
 
26
40
  _$w('#citiesDataset').onReady(async () => {
27
41
  const numOfItems = await _$w('#citiesDataset').getTotalCount();
@@ -47,6 +61,63 @@ async function homePageOnReady(_$w,thisObject) {
47
61
  });
48
62
  }
49
63
 
64
+ function bindTeamRepeater(_$w) {
65
+ _$w('#teamRepeater').onItemReady(($item, itemData) => {
66
+ $item('#teamButton').label = `View ${itemData.count} Open Positions`;
67
+ // const department = encodeURIComponent(itemData.title);
68
+ // if (itemData.customField) {
69
+ // [$item('#teamButton'), $item('#teamButton2')].forEach(btn => {
70
+ // btn.onClick(() => {
71
+ // location.to(`/search?category=${department}`);
72
+ // });
73
+ // });
74
+
75
+ // }
76
+ // else{
77
+ // $item('#teamButton').onClick(()=>{
78
+ // location.to(`/positions?department=${department}`);
79
+ // });
80
+ // }
81
+ });
82
+
83
+ _$w("#teamRepeaterItem").onClick((event) => {
84
+
85
+ const $item = _$w.at(event.context);
86
+
87
+ if(_$w("#categoriesDataset")) {
88
+ const clickedItemData = $item("#categoriesDataset").getCurrentItem();
89
+ const department = encodeURIComponent(clickedItemData.title);
90
+ location.to(`/search?category=${department}`);
91
+ }
92
+ else
93
+ {
94
+ console.log("check SR templates and do this ")
95
+
96
+ }
97
+ });
98
+
99
+
100
+ }
101
+
102
+ function bindViewAllButton(_$w) {
103
+
104
+ _$w('#viewAllCategoriesButton').onClick(()=>{
105
+ if(!loadedCategories) {
106
+ loadedCategories=true;
107
+ _$w('#viewAllCategoriesButton').label = "View Less";
108
+ _$w("#categoriesDataset").loadMore();
109
+ }
110
+ else{
111
+ loadedCategories=false;
112
+ _$w('#viewAllCategoriesButton').label = "View All";
113
+ _$w("#categoriesDataset").loadPage(1);
114
+ }
115
+ });
116
+ }
117
+
118
+
119
+
120
+
50
121
  function init(_$w) {
51
122
  const debouncedInput = debounce(()=>handleSearchInput(_$w), 400,thisObjectVar);
52
123
 
package/pages/index.js CHANGED
@@ -2,5 +2,11 @@ module.exports = {
2
2
  ...require('./positionPage'),
3
3
  ...require('./homePage'),
4
4
  ...require('./careersPage'),
5
+ ...require('./careersMultiBoxesPage'),
6
+ ...require('./pagesUtils'),
7
+ ...require('./brandPage'),
8
+ ...require('./supportTeamsPage'),
9
+ ...require('./masterPage'),
10
+ ...require('./boardPeoplePage'),
5
11
  };
6
12
 
@@ -0,0 +1,35 @@
1
+ const{isElementExistOnPage} = require('psdev-utils');
2
+ const { location } = require("@wix/site-location");
3
+ const { LINKS } = require('../backend/consts');
4
+
5
+
6
+ let companyIdGlobal;
7
+ async function masterPageOnReady(_$w,getApiKeys) {
8
+ const {companyId,templateType} = await getApiKeys();
9
+ companyIdGlobal=companyId;
10
+ bindButton(_$w,"myApplication");
11
+ bindButton(_$w,"myReferrals");
12
+ bindButton(_$w,"login");
13
+ }
14
+
15
+ function bindButton(_$w,buttonName) {
16
+ if(isElementExistOnPage(_$w(`#${buttonName}Button`))){
17
+ if(buttonName==="login"){
18
+
19
+ _$w(`#${buttonName}Button`).onClick(()=>{
20
+ location.to(LINKS[buttonName].replace("${companyId}",companyIdGlobal));
21
+ });
22
+ }
23
+ else{
24
+ _$w(`#${buttonName}Button`).onClick(()=>{
25
+ location.to(LINKS[buttonName]);
26
+ });
27
+ }
28
+ }
29
+ else{
30
+ console.log(`${buttonName} button not found`);
31
+ }
32
+ }
33
+ module.exports = {
34
+ masterPageOnReady,
35
+ };