sr-npm 3.1.26 → 3.1.28
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 +4 -0
- package/backend/consts.js +1 -1
- package/backend/data.js +77 -121
- package/package.json +2 -1
- package/pages/careersMultiBoxesPage.js +79 -39
- package/pages/pagesUtils.js +8 -2
- package/pages/positionPage.js +25 -4
- package/public/selectors.js +19 -0
|
@@ -46,6 +46,7 @@ const TWG_JOBS_COLLECTION_FIELDS={
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const CATEGORY_CUSTOM_FIELD_ID_IN_CMS='5cd8c873c9e77c0008aa7d23';
|
|
49
|
+
const COMPANY_SEGMENT_CUSTOM_FIELD_ID_IN_CMS='5cd8c7ebc9e77c00072d8bc7';
|
|
49
50
|
|
|
50
51
|
// used for filters - don't add anything else here
|
|
51
52
|
const fieldTitlesInCMS={
|
|
@@ -81,11 +82,14 @@ const possibleUrlParams=[
|
|
|
81
82
|
"storename",
|
|
82
83
|
]
|
|
83
84
|
|
|
85
|
+
|
|
86
|
+
|
|
84
87
|
module.exports = {
|
|
85
88
|
CAREERS_MULTI_BOXES_PAGE_CONSTS,
|
|
86
89
|
FiltersIds,
|
|
87
90
|
fieldTitlesInCMS,
|
|
88
91
|
CATEGORY_CUSTOM_FIELD_ID_IN_CMS,
|
|
92
|
+
COMPANY_SEGMENT_CUSTOM_FIELD_ID_IN_CMS,
|
|
89
93
|
possibleUrlParams,
|
|
90
94
|
TWG_JOBS_COLLECTION_FIELDS,
|
|
91
95
|
PRIMARY_SEARCH_STATES,
|
package/backend/consts.js
CHANGED
package/backend/data.js
CHANGED
|
@@ -114,7 +114,7 @@ function getCustomFieldsAndValuesFromPosition(position, customFieldsLabels, cust
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
async function
|
|
117
|
+
async function retrieveJobsData() {
|
|
118
118
|
const positions = await fetchPositionsFromSRAPI();
|
|
119
119
|
const sourcePositions = await filterBasedOnBrand(positions);
|
|
120
120
|
const customFieldsLabels = {}
|
|
@@ -165,6 +165,7 @@ async function saveJobsDataToCMS() {
|
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
if (siteconfig.customFields==="true") {
|
|
168
|
+
|
|
168
169
|
await populateCustomFieldsCollection(customFieldsLabels,templateType);
|
|
169
170
|
await populateCustomValuesCollection(customFieldsValues);
|
|
170
171
|
}
|
|
@@ -175,35 +176,7 @@ async function saveJobsDataToCMS() {
|
|
|
175
176
|
const titleB = b.title || '';
|
|
176
177
|
return titleA.localeCompare(titleB, undefined, { sensitivity: 'base', numeric: true });
|
|
177
178
|
});
|
|
178
|
-
|
|
179
|
-
const chunkSize = 1000;
|
|
180
|
-
let totalSaved = 0;
|
|
181
|
-
const totalChunks = Math.ceil(jobsData.length / chunkSize);
|
|
182
|
-
|
|
183
|
-
console.log(
|
|
184
|
-
`Processing ${jobsData.length} jobs in ${totalChunks} chunks of max ${chunkSize} items each`
|
|
185
|
-
);
|
|
186
|
-
console.log("truncating jobs collection");
|
|
187
|
-
await wixData.truncate(COLLECTIONS.JOBS);
|
|
188
|
-
await chunkedBulkOperation({
|
|
189
|
-
items: jobsData,
|
|
190
|
-
chunkSize,
|
|
191
|
-
processChunk: async (chunk, chunkNumber) => {
|
|
192
|
-
console.log(`Saving chunk ${chunkNumber}/${totalChunks}: ${chunk.length} jobs`);
|
|
193
|
-
try {
|
|
194
|
-
const result = await wixData.bulkSave(COLLECTIONS.JOBS, chunk);
|
|
195
|
-
const saved = result.inserted + result.updated || chunk.length;
|
|
196
|
-
totalSaved += saved;
|
|
197
|
-
console.log(
|
|
198
|
-
`✓ Chunk ${chunkNumber} saved successfully. Inserted: ${result.inserted}, Updated: ${result.updated}`
|
|
199
|
-
);
|
|
200
|
-
} catch (error) {
|
|
201
|
-
console.error(`✗ Error saving chunk ${chunkNumber}:`, error);
|
|
202
|
-
throw error;
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
});
|
|
206
|
-
console.log(`✓ All chunks processed. Total jobs saved: ${totalSaved}/${jobsData.length}`);
|
|
179
|
+
return jobsData;
|
|
207
180
|
}
|
|
208
181
|
|
|
209
182
|
async function insertJobsReference(id, valueId) {
|
|
@@ -243,51 +216,16 @@ async function populateCustomValuesCollection(customFieldsValues) {
|
|
|
243
216
|
await wixData.bulkSave(COLLECTIONS.CUSTOM_VALUES, valuesToinsert);
|
|
244
217
|
}
|
|
245
218
|
|
|
246
|
-
async function
|
|
219
|
+
async function retrieveJobsDescriptionsAndLocationApplyUrlReferences(jobsWithNoDescriptions) {
|
|
247
220
|
console.log('🚀 Starting job descriptions update process for ALL jobs');
|
|
248
221
|
|
|
249
222
|
try {
|
|
250
|
-
let jobsWithNoDescriptions = await getJobsWithNoDescriptions();
|
|
251
|
-
|
|
252
|
-
if (siteconfig.customFields==="true") {
|
|
253
|
-
let customValues = await getAllCustomValues();
|
|
254
|
-
|
|
255
|
-
console.log("inserting jobs references to custom values collection");
|
|
256
|
-
console.log("customValues: ",customValues)
|
|
257
|
-
console.log("customValues.items: ",customValues.items)
|
|
258
|
-
|
|
259
|
-
for (const value of customValues.items) {
|
|
260
|
-
await insertJobsReference(value._id, value.valueId);
|
|
261
|
-
}
|
|
262
|
-
console.log("inserted jobs references to custom values collection successfully");
|
|
263
|
-
}
|
|
264
223
|
|
|
265
|
-
let totalUpdated = 0;
|
|
266
|
-
let totalFailed = 0;
|
|
267
|
-
let totalProcessed = 0;
|
|
268
|
-
|
|
269
|
-
console.log(
|
|
270
|
-
`Total jobs in database without descriptions: ${jobsWithNoDescriptions?.items?.length}`
|
|
271
|
-
);
|
|
272
|
-
|
|
273
|
-
if (jobsWithNoDescriptions.items.length === 0) {
|
|
274
|
-
console.log('No jobs found in database');
|
|
275
|
-
return { success: true, message: 'No jobs found' };
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const API_CHUNK_SIZE = 80;
|
|
280
|
-
const pageChunks = Math.ceil(jobsWithNoDescriptions.items.length / API_CHUNK_SIZE);
|
|
281
224
|
const richContentConverterToken = await getTokenFromCMS(TOKEN_NAME.RICH_CONTENT_CONVERTER_TOKEN);
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
console.log(` Processing API chunk ${chunkNumber}/${pageChunks} (${chunk.length} jobs)`);
|
|
287
|
-
const chunkPromises = chunk.map(async job => {
|
|
288
|
-
try {
|
|
289
|
-
const jobDetails = await fetchJobDescription(job._id);
|
|
290
|
-
const richContentDescription=await htmlRichContentConverter(jobDetails.jobAd.sections,richContentConverterToken);
|
|
225
|
+
|
|
226
|
+
const jobsWithDescriptions=await Promise.all(jobsWithNoDescriptions.map( async job => {
|
|
227
|
+
const jobDetails = await fetchJobDescription(job._id);
|
|
228
|
+
const richContentDescription= await htmlRichContentConverter(jobDetails.jobAd.sections,richContentConverterToken);
|
|
291
229
|
const jobLocation = fetchJobLocation(jobDetails);
|
|
292
230
|
const {applyLink , referFriendLink} = fetchApplyAndReferFriendLink(jobDetails);
|
|
293
231
|
const updatedJob = {
|
|
@@ -297,40 +235,10 @@ async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS() {
|
|
|
297
235
|
applyLink: applyLink,
|
|
298
236
|
referFriendLink: referFriendLink,
|
|
299
237
|
};
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
console.error(` ❌ Failed to update ${job.title} (${job._id}):`, error);
|
|
304
|
-
return { success: false, jobId: job._id, title: job.title, error: error.message };
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
const chunkResults = await Promise.all(chunkPromises);
|
|
308
|
-
const chunkSuccesses = chunkResults.filter(r => r.success).length;
|
|
309
|
-
const chunkFailures = chunkResults.filter(r => !r.success).length;
|
|
310
|
-
totalUpdated += chunkSuccesses;
|
|
311
|
-
totalFailed += chunkFailures;
|
|
312
|
-
totalProcessed += chunk.length;
|
|
313
|
-
console.log(
|
|
314
|
-
` API chunk ${chunkNumber} completed: ${chunkSuccesses} success, ${chunkFailures} failed`
|
|
315
|
-
);
|
|
316
|
-
},
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
|
|
238
|
+
return updatedJob;
|
|
239
|
+
}))
|
|
240
|
+
return {success: true, updatedJobs: jobsWithDescriptions};
|
|
320
241
|
|
|
321
|
-
console.log(`\n✅ Finished updating ALL job descriptions`);
|
|
322
|
-
console.log(`📊 Final Results:`);
|
|
323
|
-
console.log(` Total jobs processed: ${totalProcessed}`);
|
|
324
|
-
console.log(` Total updated: ${totalUpdated}`);
|
|
325
|
-
console.log(` Total failed: ${totalFailed}`);
|
|
326
|
-
|
|
327
|
-
return {
|
|
328
|
-
success: true,
|
|
329
|
-
totalProcessed: totalProcessed,
|
|
330
|
-
totalUpdated: totalUpdated,
|
|
331
|
-
totalFailed: totalFailed,
|
|
332
|
-
message: `Successfully updated ${totalUpdated} job descriptions out of ${totalProcessed} total jobs`,
|
|
333
|
-
};
|
|
334
242
|
} catch (error) {
|
|
335
243
|
console.error('❌ Error in updateJobDescriptions:', error);
|
|
336
244
|
throw error;
|
|
@@ -375,14 +283,7 @@ async function getAllCustomValues() {
|
|
|
375
283
|
return customValuesQuery;
|
|
376
284
|
}
|
|
377
285
|
|
|
378
|
-
|
|
379
|
-
let jobswithoutdescriptionsQuery = await wixData
|
|
380
|
-
.query(COLLECTIONS.JOBS)
|
|
381
|
-
.limit(1000)
|
|
382
|
-
.isEmpty('jobDescription')
|
|
383
|
-
.find();
|
|
384
|
-
return jobswithoutdescriptionsQuery;
|
|
385
|
-
}
|
|
286
|
+
|
|
386
287
|
|
|
387
288
|
/**
|
|
388
289
|
* @param {Object} params
|
|
@@ -507,20 +408,36 @@ async function syncJobsFast() {
|
|
|
507
408
|
try{
|
|
508
409
|
console.log("Syncing jobs fast");
|
|
509
410
|
await createCollections();
|
|
510
|
-
|
|
411
|
+
|
|
511
412
|
await fillSecretManagerMirror();
|
|
512
413
|
|
|
513
|
-
console.log("
|
|
514
|
-
|
|
515
|
-
|
|
414
|
+
console.log("retrieving jobs data from SR API");
|
|
415
|
+
|
|
416
|
+
const jobsData = await retrieveJobsData();
|
|
417
|
+
|
|
418
|
+
console.log("retrieved jobs data from SR API successfully");
|
|
516
419
|
|
|
517
|
-
console.log("
|
|
518
|
-
|
|
420
|
+
console.log("retrieving jobs descriptions and location apply url from SR API");
|
|
421
|
+
|
|
422
|
+
const status=await retrieveJobsDescriptionsAndLocationApplyUrlReferences(jobsData);
|
|
423
|
+
if(status.success){
|
|
424
|
+
|
|
425
|
+
await clearCollections();
|
|
426
|
+
const updatedJobs=status.updatedJobs;
|
|
427
|
+
console.log("saving jobs to CMS");
|
|
428
|
+
await saveJobsToCMS(updatedJobs);
|
|
429
|
+
|
|
430
|
+
if (siteconfig.customFields==="true") {
|
|
431
|
+
await insertJobsReferencesToCustomValuesCollection();
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
console.log("saved jobs data, descriptions and location apply url to CMS successfully");
|
|
519
435
|
|
|
520
|
-
console.log("saved jobs descriptions and location apply url to CMS successfully");
|
|
521
436
|
await aggregateJobs();
|
|
522
437
|
await referenceJobs();
|
|
438
|
+
|
|
523
439
|
console.log("syncing jobs fast finished successfully");
|
|
440
|
+
|
|
524
441
|
}
|
|
525
442
|
catch (error) {
|
|
526
443
|
error.message="Error syncing jobs: "+error.message;
|
|
@@ -529,7 +446,46 @@ async function syncJobsFast() {
|
|
|
529
446
|
|
|
530
447
|
}
|
|
531
448
|
|
|
449
|
+
async function saveJobsToCMS(updatedJobs) {
|
|
450
|
+
const chunkSize = 1000;
|
|
451
|
+
let totalSaved = 0;
|
|
452
|
+
const totalChunks = Math.ceil(updatedJobs.length / chunkSize);
|
|
453
|
+
|
|
454
|
+
console.log(
|
|
455
|
+
`Processing ${updatedJobs.length} jobs in ${totalChunks} chunks of max ${chunkSize} items each`
|
|
456
|
+
);
|
|
457
|
+
|
|
458
|
+
await chunkedBulkOperation({
|
|
459
|
+
items: updatedJobs,
|
|
460
|
+
chunkSize,
|
|
461
|
+
processChunk: async (chunk, chunkNumber) => {
|
|
462
|
+
console.log(`Saving chunk ${chunkNumber}/${totalChunks}: ${chunk.length} jobs`);
|
|
463
|
+
try {
|
|
464
|
+
const result = await wixData.bulkSave(COLLECTIONS.JOBS, chunk);
|
|
465
|
+
const saved = result.inserted + result.updated || chunk.length;
|
|
466
|
+
totalSaved += saved;
|
|
467
|
+
console.log(
|
|
468
|
+
`✓ Chunk ${chunkNumber} saved successfully. Inserted: ${result.inserted}, Updated: ${result.updated}`
|
|
469
|
+
);
|
|
470
|
+
} catch (error) {
|
|
471
|
+
console.error(`✗ Error saving chunk ${chunkNumber}:`, error);
|
|
472
|
+
throw error;
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
});
|
|
476
|
+
console.log(`✓ All chunks processed. Total jobs saved: ${totalSaved}/${updatedJobs.length}`);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
async function insertJobsReferencesToCustomValuesCollection() {
|
|
480
|
+
console.log("inserting jobs references to custom values collection");
|
|
532
481
|
|
|
482
|
+
let customValues = await getAllCustomValues();
|
|
483
|
+
|
|
484
|
+
for (const value of customValues.items) {
|
|
485
|
+
await insertJobsReference(value._id, value.valueId);
|
|
486
|
+
}
|
|
487
|
+
console.log("inserted jobs references to custom values collection successfully");
|
|
488
|
+
}
|
|
533
489
|
async function clearCollections() {
|
|
534
490
|
console.log("clearing collections");
|
|
535
491
|
if(siteconfig===undefined) {
|
|
@@ -538,8 +494,8 @@ async function clearCollections() {
|
|
|
538
494
|
await Promise.all([
|
|
539
495
|
wixData.truncate(COLLECTIONS.CITIES),
|
|
540
496
|
wixData.truncate(COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT),
|
|
541
|
-
wixData.truncate(COLLECTIONS.JOBS),
|
|
542
497
|
wixData.truncate(COLLECTIONS.BRANDS),
|
|
498
|
+
wixData.truncate(COLLECTIONS.JOBS),
|
|
543
499
|
siteconfig.customFields==="true" ? wixData.truncate(COLLECTIONS.CUSTOM_VALUES) : null,
|
|
544
500
|
siteconfig.customFields==="true" ? wixData.truncate(COLLECTIONS.CUSTOM_FIELDS) : null,
|
|
545
501
|
]);
|
|
@@ -589,8 +545,8 @@ module.exports = {
|
|
|
589
545
|
referenceJobs,
|
|
590
546
|
aggregateJobs,
|
|
591
547
|
createCollections,
|
|
592
|
-
saveJobsDataToCMS,
|
|
593
|
-
saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS,
|
|
548
|
+
saveJobsDataToCMS: retrieveJobsData,
|
|
549
|
+
saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS: retrieveJobsDescriptionsAndLocationApplyUrlReferences,
|
|
594
550
|
aggregateJobsByFieldToCMS,
|
|
595
551
|
referenceJobsToField,
|
|
596
552
|
fillSecretManagerMirror,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sr-npm",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.28",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@wix/essentials": "^0.1.24",
|
|
23
23
|
"@wix/secrets": "1.0.53",
|
|
24
24
|
"@wix/site-location": "^1.0.0",
|
|
25
|
+
"@wix/site-seo": "^1.21.0",
|
|
25
26
|
"@wix/site-window": "^1.0.0",
|
|
26
27
|
"axios": "^1.11.0",
|
|
27
28
|
"jest": "^30.0.5",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { COLLECTIONS,CUSTOM_VALUES_COLLECTION_FIELDS,JOBS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
|
|
2
|
-
const { CAREERS_PAGE_SELECTORS, GLOBAL_SECTIONS_SELECTORS } = require('../public/selectors');
|
|
2
|
+
const { CAREERS_PAGE_SELECTORS, GLOBAL_SECTIONS_SELECTORS, SEARCH_RESULTS_SELECTORS, MOBILE_FILTER_BOX_SELECTORS } = require('../public/selectors');
|
|
3
3
|
|
|
4
4
|
const { window } = require('@wix/site-window');
|
|
5
5
|
const { queryParams,onChange} = require('wix-location-frontend');
|
|
@@ -18,7 +18,8 @@ const { groupValuesByField,
|
|
|
18
18
|
getFieldByTitle,
|
|
19
19
|
getCorrectOption,
|
|
20
20
|
getOptionIndexFromCheckBox,
|
|
21
|
-
getAllDatasetItems
|
|
21
|
+
getAllDatasetItems,
|
|
22
|
+
handleSEOTitle
|
|
22
23
|
} = require('./pagesUtils');
|
|
23
24
|
const { handlePrimarySearch, queryPrimarySearchResults } = require('../public/primarySearchUtils');
|
|
24
25
|
|
|
@@ -39,7 +40,7 @@ let secondarySearchIsFilled=false // whether the secondary search is filled with
|
|
|
39
40
|
let keywordAllJobs; // all jobs that are displayed in the jobs repeater when the keyword is filled
|
|
40
41
|
let ActivateURLOnchange=true; // whether to activate the url onchange
|
|
41
42
|
let considerAllJobs=false; // whether to consider all jobs or not
|
|
42
|
-
|
|
43
|
+
let collapseFilterBoxWhenWindowReduced=false; // whether to collapse the filter box when the window is reduced
|
|
43
44
|
const pagination = {
|
|
44
45
|
pageSize: 10,
|
|
45
46
|
currentPage: 1,
|
|
@@ -62,25 +63,68 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
|
|
|
62
63
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CLEAR_ALL_BUTTON_ID).onClick(async () => {
|
|
63
64
|
await clearAll(_$w);
|
|
64
65
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
|
|
67
|
+
handleFilterButton(_$w);
|
|
68
|
+
setInterval(async () => {
|
|
69
|
+
const windowinfo=await window.getBoundingRect();
|
|
70
|
+
if(windowinfo.window.width>1000){
|
|
71
|
+
|
|
72
|
+
handleWindowResize(_$w,true);
|
|
73
|
+
}
|
|
74
|
+
else{
|
|
75
|
+
handleWindowResize(_$w);
|
|
76
|
+
}
|
|
77
|
+
}, 600);
|
|
78
|
+
|
|
68
79
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_MULTI_STATE_BOX).changeState("results");
|
|
69
80
|
}
|
|
70
81
|
|
|
82
|
+
async function handleWindowResize(_$w,desktop=false) {
|
|
83
|
+
if(desktop){
|
|
84
|
+
collapseFilterBoxWhenWindowReduced=true;
|
|
85
|
+
MOBILE_FILTER_BOX_SELECTORS.forEach(selector => {
|
|
86
|
+
_$w(selector).expand();
|
|
87
|
+
});
|
|
88
|
+
SEARCH_RESULTS_SELECTORS.forEach(selector => {
|
|
89
|
+
_$w(selector).expand();
|
|
90
|
+
});
|
|
91
|
+
_$w(CAREERS_PAGE_SELECTORS.FILTER_ICON).collapse();
|
|
92
|
+
_$w(CAREERS_PAGE_SELECTORS.EXIT_BUTTON).collapse();
|
|
93
|
+
_$w(CAREERS_PAGE_SELECTORS.REFINE_SEARCH_BUTTON).collapse();
|
|
94
|
+
}
|
|
95
|
+
else{
|
|
96
|
+
const formFactor = await window.formFactor();
|
|
97
|
+
if(formFactor==="Desktop" && collapseFilterBoxWhenWindowReduced){
|
|
98
|
+
_$w(CAREERS_PAGE_SELECTORS.FILTER_BOX).collapse();
|
|
99
|
+
collapseFilterBoxWhenWindowReduced=false;
|
|
100
|
+
}
|
|
101
|
+
if(_$w(CAREERS_PAGE_SELECTORS.FILTER_ICON).collapsed && _$w(CAREERS_PAGE_SELECTORS.EXIT_BUTTON).collapsed && _$w(CAREERS_PAGE_SELECTORS.REFINE_SEARCH_BUTTON).collapsed){
|
|
102
|
+
_$w(CAREERS_PAGE_SELECTORS.FILTER_ICON).expand();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
71
108
|
async function handleBackAndForth(_$w){
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
ActivateURLOnchange=true;
|
|
109
|
+
if(ActivateURLOnchange) {
|
|
110
|
+
await clearAll(_$w);
|
|
111
|
+
}
|
|
112
|
+
else{
|
|
113
|
+
ActivateURLOnchange=true;
|
|
114
|
+
}
|
|
79
115
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
116
|
+
// if(ActivateURLOnchange) {
|
|
117
|
+
// const newQueryParams=await location.query();
|
|
118
|
+
// console.log("newQueryParams: ", newQueryParams);
|
|
119
|
+
// ActivateURLOnchange=false;
|
|
120
|
+
// await clearAll(_$w,true);
|
|
121
|
+
// await handleUrlParams(_$w,newQueryParams,true);
|
|
122
|
+
// ActivateURLOnchange=true;
|
|
123
|
+
|
|
124
|
+
// }
|
|
125
|
+
// else{
|
|
126
|
+
// ActivateURLOnchange=true;
|
|
127
|
+
// }
|
|
84
128
|
}
|
|
85
129
|
|
|
86
130
|
async function clearAll(_$w,urlOnChange=false) {
|
|
@@ -105,38 +149,24 @@ async function clearAll(_$w,urlOnChange=false) {
|
|
|
105
149
|
|
|
106
150
|
}
|
|
107
151
|
|
|
108
|
-
function
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
CAREERS_PAGE_SELECTORS.PAGINATION_BTN,
|
|
112
|
-
CAREERS_PAGE_SELECTORS.HEAD_BTNS,
|
|
113
|
-
CAREERS_PAGE_SELECTORS.SELECTED_VALUES_REPEATER,
|
|
114
|
-
CAREERS_PAGE_SELECTORS.BUTTOM_TXT,
|
|
115
|
-
CAREERS_PAGE_SELECTORS.SECTION_24,
|
|
116
|
-
CAREERS_PAGE_SELECTORS.SECTION_3,
|
|
117
|
-
CAREERS_PAGE_SELECTORS.LINE_3,
|
|
118
|
-
CAREERS_PAGE_SELECTORS.FILTER_ICON];
|
|
119
|
-
|
|
120
|
-
const mobileFilterBoxSelectors = [
|
|
121
|
-
CAREERS_PAGE_SELECTORS.FILTER_BOX,
|
|
122
|
-
CAREERS_PAGE_SELECTORS.REFINE_SEARCH_BUTTON,
|
|
123
|
-
CAREERS_PAGE_SELECTORS.EXIT_BUTTON,
|
|
124
|
-
];
|
|
152
|
+
async function handleFilterButton(_$w) {
|
|
153
|
+
|
|
154
|
+
|
|
125
155
|
|
|
126
156
|
_$w(CAREERS_PAGE_SELECTORS.FILTER_ICON).onClick(()=>{
|
|
127
|
-
|
|
157
|
+
MOBILE_FILTER_BOX_SELECTORS.forEach(selector => {
|
|
128
158
|
_$w(selector).expand();
|
|
129
159
|
});
|
|
130
|
-
|
|
160
|
+
SEARCH_RESULTS_SELECTORS.forEach(selector => {
|
|
131
161
|
_$w(selector).collapse();
|
|
132
162
|
});
|
|
133
163
|
});
|
|
134
164
|
|
|
135
165
|
const exitFilterBox = () => {
|
|
136
|
-
|
|
166
|
+
MOBILE_FILTER_BOX_SELECTORS.forEach(selector => {
|
|
137
167
|
_$w(selector).collapse();
|
|
138
168
|
});
|
|
139
|
-
|
|
169
|
+
SEARCH_RESULTS_SELECTORS.forEach(selector => {
|
|
140
170
|
_$w(selector).expand();
|
|
141
171
|
});
|
|
142
172
|
}
|
|
@@ -150,10 +180,18 @@ function handleFilterInMobile(_$w) {
|
|
|
150
180
|
});
|
|
151
181
|
|
|
152
182
|
//onmobile we should collapse the filter box and the refine search button by default
|
|
153
|
-
|
|
183
|
+
const formFactor = await window.formFactor();
|
|
184
|
+
if(formFactor === "Mobile" || formFactor === "Tablet") {
|
|
185
|
+
MOBILE_FILTER_BOX_SELECTORS.forEach(selector => {
|
|
154
186
|
_$w(selector).collapse();
|
|
155
187
|
});
|
|
156
188
|
}
|
|
189
|
+
else
|
|
190
|
+
{
|
|
191
|
+
collapseFilterBoxWhenWindowReduced=true
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
}
|
|
157
195
|
|
|
158
196
|
|
|
159
197
|
async function handleUrlParams(_$w,urlParams,handleBackAndForth=false) {
|
|
@@ -169,6 +207,7 @@ async function handleUrlParams(_$w,urlParams,handleBackAndForth=false) {
|
|
|
169
207
|
|
|
170
208
|
currentJobs = items;
|
|
171
209
|
keywordAllJobs = items;
|
|
210
|
+
await handleSEOTitle(`${decodeURIComponent(urlParams.keyword)} Search Results | The Warehouse Group`);
|
|
172
211
|
}
|
|
173
212
|
|
|
174
213
|
for (const url of possibleUrlParams)
|
|
@@ -400,6 +439,7 @@ async function loadJobsRepeater(_$w) {
|
|
|
400
439
|
|
|
401
440
|
_$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = []; // start empty
|
|
402
441
|
_$w(`#${FiltersIds[field.title]}CheckBox`).onChange(async (ev) => {
|
|
442
|
+
|
|
403
443
|
dontUpdateThisCheckBox=field._id;
|
|
404
444
|
const selected = ev.target.value; // array of selected value IDs
|
|
405
445
|
let fieldTitle=field.title.toLowerCase().replace(' ', '');
|
package/pages/pagesUtils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { items: wixData } = require('@wix/data');
|
|
2
2
|
const { JOBS_COLLECTION_FIELDS,COLLECTIONS } = require('../backend/collectionConsts');
|
|
3
3
|
const { normalizeString } = require('../backend/utils');
|
|
4
|
-
|
|
4
|
+
const { seo } = require('@wix/site-seo');
|
|
5
5
|
function groupValuesByField(values, refKey) {
|
|
6
6
|
const map = new Map();
|
|
7
7
|
for (const v of values) {
|
|
@@ -106,6 +106,11 @@ async function getLatestJobsByValue(Value) {
|
|
|
106
106
|
return latestJobs;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
async function handleSEOTitle(title) {
|
|
110
|
+
await seo.setTitle(title);
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
109
114
|
module.exports = {
|
|
110
115
|
groupValuesByField,
|
|
111
116
|
debounce,
|
|
@@ -117,5 +122,6 @@ module.exports = {
|
|
|
117
122
|
getLatestJobsByValue,
|
|
118
123
|
getValueFromValueId,
|
|
119
124
|
getAllRecordsWithoutMultiRef,
|
|
120
|
-
getAllDatasetItems
|
|
125
|
+
getAllDatasetItems,
|
|
126
|
+
handleSEOTitle
|
|
121
127
|
}
|
package/pages/positionPage.js
CHANGED
|
@@ -5,13 +5,34 @@ const { TWG_JOBS_COLLECTION_FIELDS } = require('../backend/careersMultiBoxesPage
|
|
|
5
5
|
const { items: wixData } = require('@wix/data');
|
|
6
6
|
const { location } = require("@wix/site-location");
|
|
7
7
|
const{isElementExistOnPage} = require('psdev-utils');
|
|
8
|
+
const { COMPANY_SEGMENT_CUSTOM_FIELD_ID_IN_CMS } = require('../backend/careersMultiBoxesPageIds');
|
|
8
9
|
const {
|
|
9
10
|
appendQueryParams
|
|
10
11
|
} = require('../public/utils');
|
|
11
12
|
|
|
12
13
|
|
|
14
|
+
let siteconfig;
|
|
15
|
+
let multiRefField;
|
|
13
16
|
async function positionPageOnReady(_$w) {
|
|
14
|
-
|
|
17
|
+
if(siteconfig===undefined) {
|
|
18
|
+
siteconfig = await wixData.query(COLLECTIONS.SITE_CONFIGS).find().then(result => result.items[0]);
|
|
19
|
+
}
|
|
20
|
+
const item = await _$w('#datasetJobsItem').getCurrentItem();
|
|
21
|
+
|
|
22
|
+
if(siteconfig.customFields==="true") {
|
|
23
|
+
multiRefField=await getPositionWithMultiRefField(item._id);
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
const companysegmentValue=multiRefField.filter(field => field.customField===COMPANY_SEGMENT_CUSTOM_FIELD_ID_IN_CMS && field.title===siteconfig.showNotifyMeForCompanySegment);
|
|
27
|
+
|
|
28
|
+
if(companysegmentValue===undefined || companysegmentValue.length===0) {
|
|
29
|
+
|
|
30
|
+
_$w("#notifyMe").hide()
|
|
31
|
+
console.log(`companysegmentValue is ${siteconfig.showNotifyMeForCompanySegment}, hiding notifyMe`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
}
|
|
15
36
|
await bind(_$w);
|
|
16
37
|
|
|
17
38
|
|
|
@@ -35,6 +56,8 @@ async function getCategoryValue(customValues) {
|
|
|
35
56
|
const item = await _$w('#datasetJobsItem').getCurrentItem();
|
|
36
57
|
console.log("item: ",item);
|
|
37
58
|
|
|
59
|
+
|
|
60
|
+
|
|
38
61
|
handleReferFriendButton(_$w,item);
|
|
39
62
|
handleApplyButton(_$w,item);
|
|
40
63
|
|
|
@@ -49,9 +72,7 @@ async function getCategoryValue(customValues) {
|
|
|
49
72
|
if(isElementExistOnPage(_$w('#relatedJobsRepNoDepartment'))) // when there is no department, we filter based on category
|
|
50
73
|
{
|
|
51
74
|
|
|
52
|
-
const
|
|
53
|
-
const categoryValue=await getCategoryValue(multiRefField);
|
|
54
|
-
|
|
75
|
+
const categoryValue=await getCategoryValue(multiRefField);
|
|
55
76
|
if(isElementExistOnPage(_$w('#jobCategory'))) {
|
|
56
77
|
_$w('#jobCategory').text = categoryValue.title;
|
|
57
78
|
}
|
package/public/selectors.js
CHANGED
|
@@ -50,8 +50,27 @@ const FILTER_FIELDS = {
|
|
|
50
50
|
SEARCH: 'title',
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
|
|
54
|
+
const SEARCH_RESULTS_SELECTORS = [
|
|
55
|
+
CAREERS_PAGE_SELECTORS.RESULT_BOX,
|
|
56
|
+
CAREERS_PAGE_SELECTORS.PAGINATION_BTN,
|
|
57
|
+
CAREERS_PAGE_SELECTORS.HEAD_BTNS,
|
|
58
|
+
CAREERS_PAGE_SELECTORS.SELECTED_VALUES_REPEATER,
|
|
59
|
+
CAREERS_PAGE_SELECTORS.BUTTOM_TXT,
|
|
60
|
+
CAREERS_PAGE_SELECTORS.SECTION_24,
|
|
61
|
+
CAREERS_PAGE_SELECTORS.SECTION_3,
|
|
62
|
+
CAREERS_PAGE_SELECTORS.LINE_3,
|
|
63
|
+
CAREERS_PAGE_SELECTORS.FILTER_ICON];
|
|
64
|
+
|
|
65
|
+
const MOBILE_FILTER_BOX_SELECTORS = [
|
|
66
|
+
CAREERS_PAGE_SELECTORS.FILTER_BOX,
|
|
67
|
+
CAREERS_PAGE_SELECTORS.REFINE_SEARCH_BUTTON,
|
|
68
|
+
CAREERS_PAGE_SELECTORS.EXIT_BUTTON,
|
|
69
|
+
];
|
|
53
70
|
module.exports = {
|
|
54
71
|
CAREERS_PAGE_SELECTORS,
|
|
55
72
|
GLOBAL_SECTIONS_SELECTORS,
|
|
56
73
|
FILTER_FIELDS,
|
|
74
|
+
SEARCH_RESULTS_SELECTORS,
|
|
75
|
+
MOBILE_FILTER_BOX_SELECTORS,
|
|
57
76
|
}
|