sr-npm 3.1.6 → 3.1.8
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/collectionConsts.js +10 -1
- package/backend/data.js +65 -54
- package/backend/queries.js +1 -1
- package/package.json +1 -1
- package/pages/careersMultiBoxesPage.js +51 -50
- package/pages/homePage.js +16 -13
- package/pages/pagesUtils.js +51 -49
- package/pages/positionPage.js +1 -3
- package/pages/supportTeamsPage.js +6 -6
|
@@ -11,6 +11,7 @@ const COLLECTIONS = {
|
|
|
11
11
|
SUPPORT_TEAMS: 'SupportTeams',
|
|
12
12
|
|
|
13
13
|
}
|
|
14
|
+
|
|
14
15
|
const JOBS_COLLECTION_FIELDS = {
|
|
15
16
|
LOCATION: 'location',
|
|
16
17
|
TITLE: 'title',
|
|
@@ -34,25 +35,31 @@ const JOBS_COLLECTION_FIELDS = {
|
|
|
34
35
|
RELEASED_DATE: 'releasedDate',
|
|
35
36
|
REF_ID: 'refId',
|
|
36
37
|
}
|
|
38
|
+
|
|
37
39
|
const AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION_FIELDS = {
|
|
38
40
|
TITLE: 'title',
|
|
39
41
|
COUNT: 'count',
|
|
40
42
|
IMAGE: 'image',
|
|
41
43
|
}
|
|
44
|
+
|
|
42
45
|
const CUSTOM_VALUES_COLLECTION_FIELDS = {
|
|
46
|
+
VALUE_ID: 'valueId',
|
|
43
47
|
TITLE: 'title',
|
|
44
48
|
CUSTOM_FIELD: 'customField',
|
|
45
49
|
MULTI_REF_JOBS_CUSTOM_VALUES: 'multiRefJobsCustomValues',
|
|
46
50
|
count: 'count',
|
|
47
51
|
JOB_IDS: 'jobIds',
|
|
48
52
|
}
|
|
53
|
+
|
|
49
54
|
const CUSTOM_FIELDS_COLLECTION_FIELDS = {
|
|
50
55
|
TITLE: 'title',
|
|
51
56
|
}
|
|
57
|
+
|
|
52
58
|
const BRANDS_COLLECTION_FIELDS = {
|
|
53
59
|
TITLE: 'title',
|
|
54
60
|
COUNT: 'count',
|
|
55
61
|
}
|
|
62
|
+
|
|
56
63
|
const CITIES_COLLECTION_FIELDS = {
|
|
57
64
|
TITLE: 'title',
|
|
58
65
|
CITY: 'city',
|
|
@@ -61,6 +68,7 @@ const CITIES_COLLECTION_FIELDS = {
|
|
|
61
68
|
COUNTRY: 'country',
|
|
62
69
|
JOB_IDS: 'jobIds',
|
|
63
70
|
}
|
|
71
|
+
|
|
64
72
|
const COLLECTIONS_FIELDS = {
|
|
65
73
|
AMOUNT_OF_JOBS_PER_DEPARTMENT: [
|
|
66
74
|
{key:'title', type: 'TEXT'},
|
|
@@ -85,7 +93,7 @@ const COLLECTIONS_FIELDS = {
|
|
|
85
93
|
{key:'language', type: 'TEXT'},
|
|
86
94
|
{key:'remote', type: 'BOOLEAN'},
|
|
87
95
|
{key:'jobDescription', type: 'OBJECT'},
|
|
88
|
-
{key:'multiRefJobsCustomValues', type: 'MULTI_REFERENCE', typeMetadata: { multiReference: { referencedCollectionId: COLLECTIONS.CUSTOM_VALUES,referencingFieldKey:JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,referencingDisplayName:JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES } } },
|
|
96
|
+
{key:'multiRefJobsCustomValues', type: 'MULTI_REFERENCE', typeMetadata: { multiReference: { referencedCollectionId: COLLECTIONS.CUSTOM_VALUES, referencingFieldKey:JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,referencingDisplayName:JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES } } },
|
|
89
97
|
{key:'cityText', type: 'TEXT'},
|
|
90
98
|
{key:'applyLink', type: 'URL'},
|
|
91
99
|
{key:'referFriendLink', type: 'URL'},
|
|
@@ -114,6 +122,7 @@ const COLLECTIONS_FIELDS = {
|
|
|
114
122
|
{ key: 'count', type: 'NUMBER' },
|
|
115
123
|
],
|
|
116
124
|
CUSTOM_VALUES: [
|
|
125
|
+
{key:'valueId', type: 'TEXT'},
|
|
117
126
|
{key:'title', type: 'TEXT'},
|
|
118
127
|
{key:'customField', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.CUSTOM_FIELDS } } },
|
|
119
128
|
{key:'count', type: 'NUMBER'},
|
package/backend/data.js
CHANGED
|
@@ -40,7 +40,6 @@ function validatePosition(position) {
|
|
|
40
40
|
if (!position.location || !position.location.city || typeof position.location.remote !== 'boolean') {
|
|
41
41
|
throw new Error('Position location is required and must have a city and remote');
|
|
42
42
|
}
|
|
43
|
-
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
async function filterBasedOnBrand(positions) {
|
|
@@ -93,78 +92,83 @@ function getEmploymentType(position,customFieldsValues) {
|
|
|
93
92
|
customValuesToJobs[position.typeOfEmployment.id] ? customValuesToJobs[position.typeOfEmployment.id].add(position.id) : customValuesToJobs[position.typeOfEmployment.id]=new Set([position.id])
|
|
94
93
|
}
|
|
95
94
|
|
|
96
|
-
function getCustomFieldsAndValuesFromPosition(position,customFieldsLabels,customFieldsValues) {
|
|
95
|
+
function getCustomFieldsAndValuesFromPosition(position, customFieldsLabels, customFieldsValues) {
|
|
97
96
|
const customFieldsArray = Array.isArray(position?.customField) ? position.customField : [];
|
|
97
|
+
|
|
98
98
|
for (const field of customFieldsArray) {
|
|
99
99
|
if(EXCLUDED_CUSTOM_FIELDS.has(field.fieldLabel)) continue; //country and department are not custom fields, they are already in the job object
|
|
100
|
-
|
|
100
|
+
|
|
101
|
+
const fieldId = normalizeString(field.fieldId)
|
|
101
102
|
const fieldLabel = field.fieldLabel;
|
|
102
|
-
const valueId=normalizeString(field.valueId)
|
|
103
|
+
const valueId = normalizeString(field.valueId)
|
|
103
104
|
const valueLabel = field.valueLabel
|
|
104
105
|
customFieldsLabels[fieldId] = fieldLabel
|
|
106
|
+
|
|
105
107
|
// Build nested dictionary: fieldId -> { valueId: valueLabel }
|
|
106
108
|
if (!customFieldsValues[fieldId]) {
|
|
107
109
|
customFieldsValues[fieldId] = {};
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
customFieldsValues[fieldId][valueId] = valueLabel;
|
|
111
|
-
customValuesToJobs[valueId] ? customValuesToJobs[valueId].add(position.id) : customValuesToJobs[valueId]=new Set([position.id])
|
|
113
|
+
customValuesToJobs[valueId] ? customValuesToJobs[valueId].add(position.id) : customValuesToJobs[valueId] = new Set([position.id])
|
|
112
114
|
}
|
|
113
115
|
}
|
|
116
|
+
|
|
114
117
|
async function saveJobsDataToCMS() {
|
|
115
118
|
const positions = await fetchPositionsFromSRAPI();
|
|
116
119
|
const sourcePositions = await filterBasedOnBrand(positions);
|
|
117
120
|
const customFieldsLabels = {}
|
|
118
121
|
const customFieldsValues = {}
|
|
119
122
|
|
|
120
|
-
const {
|
|
123
|
+
const { templateType } = await getApiKeys();
|
|
121
124
|
if(siteconfig===undefined) {
|
|
122
125
|
await getSiteConfig();
|
|
123
126
|
}
|
|
124
127
|
// bulk insert to jobs collection without descriptions first
|
|
125
128
|
const jobsData = sourcePositions.map(position => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
129
|
+
const basicJob = {
|
|
130
|
+
_id: position.id,
|
|
131
|
+
title: position.name || '',
|
|
132
|
+
slug: generateSlug(position.name || ''),
|
|
133
|
+
department: position.department?.label || 'Other',
|
|
134
|
+
cityText: normalizeString(position.location?.city),
|
|
135
|
+
location: position.location && Object.keys(position.location).length > 0
|
|
136
|
+
? position.location
|
|
137
|
+
: {
|
|
138
|
+
countryCode: "",
|
|
139
|
+
country: "",
|
|
140
|
+
city: "",
|
|
141
|
+
postalCode: "",
|
|
142
|
+
address: "",
|
|
143
|
+
manual: false,
|
|
144
|
+
remote: false,
|
|
145
|
+
regionCode: ""
|
|
146
|
+
},
|
|
147
|
+
country: position.location?.country || '',
|
|
148
|
+
remote: position.location?.remote || false,
|
|
149
|
+
language: position.language?.label || '',
|
|
150
|
+
brand: siteconfig.disableMultiBrand==="false" ? getBrand(position.customField) : '',
|
|
151
|
+
jobDescription: null, // Will be filled later
|
|
152
|
+
employmentType: position.typeOfEmployment.label,
|
|
153
|
+
releasedDate: position.releasedDate,
|
|
154
|
+
refId: position.refNumber
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
getCustomFieldsAndValuesFromPosition(position, customFieldsLabels, customFieldsValues);
|
|
158
|
+
getEmploymentType(position, customFieldsValues);
|
|
159
|
+
getLocation(position,basicJob);
|
|
160
|
+
|
|
161
|
+
if(templateType === TEMPLATE_TYPE.INTERNAL){
|
|
162
|
+
getVisibility(position,customFieldsValues);
|
|
163
|
+
}
|
|
164
|
+
return basicJob;
|
|
162
165
|
});
|
|
163
166
|
|
|
164
167
|
if (siteconfig.customFields==="true") {
|
|
165
|
-
|
|
166
|
-
|
|
168
|
+
await populateCustomFieldsCollection(customFieldsLabels,templateType);
|
|
169
|
+
await populateCustomValuesCollection(customFieldsValues);
|
|
167
170
|
}
|
|
171
|
+
|
|
168
172
|
// Sort jobs by title (ascending, case-insensitive, numeric-aware)
|
|
169
173
|
jobsData.sort((a, b) => {
|
|
170
174
|
const titleA = a.title || '';
|
|
@@ -202,8 +206,8 @@ async function saveJobsDataToCMS() {
|
|
|
202
206
|
console.log(`✓ All chunks processed. Total jobs saved: ${totalSaved}/${jobsData.length}`);
|
|
203
207
|
}
|
|
204
208
|
|
|
205
|
-
async function insertJobsReference(valueId) {
|
|
206
|
-
await wixData.insertReference(COLLECTIONS.CUSTOM_VALUES, CUSTOM_VALUES_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,
|
|
209
|
+
async function insertJobsReference(id, valueId) {
|
|
210
|
+
await wixData.insertReference(COLLECTIONS.CUSTOM_VALUES, CUSTOM_VALUES_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES, id, Array.from(customValuesToJobs[valueId]));
|
|
207
211
|
}
|
|
208
212
|
|
|
209
213
|
async function populateCustomFieldsCollection(customFields,templateType) {
|
|
@@ -222,33 +226,38 @@ async function populateCustomFieldsCollection(customFields,templateType) {
|
|
|
222
226
|
}
|
|
223
227
|
async function populateCustomValuesCollection(customFieldsValues) {
|
|
224
228
|
let valuesToinsert=[]
|
|
229
|
+
|
|
225
230
|
for (const fieldId of Object.keys(customFieldsValues)) {
|
|
226
231
|
const valuesMap = customFieldsValues[fieldId] || {};
|
|
232
|
+
|
|
227
233
|
for (const valueId of Object.keys(valuesMap)) {
|
|
228
234
|
valuesToinsert.push({
|
|
229
|
-
|
|
235
|
+
valueId,
|
|
230
236
|
title: valuesMap[valueId],
|
|
231
237
|
customField: fieldId,
|
|
232
|
-
count:customValuesToJobs[valueId].size,
|
|
233
|
-
jobIds:Array.from(customValuesToJobs[valueId]),
|
|
238
|
+
count: customValuesToJobs[valueId].size,
|
|
239
|
+
jobIds: Array.from(customValuesToJobs[valueId]),
|
|
234
240
|
})
|
|
235
241
|
}
|
|
236
|
-
|
|
237
242
|
}
|
|
238
243
|
await wixData.bulkSave(COLLECTIONS.CUSTOM_VALUES, valuesToinsert);
|
|
239
244
|
}
|
|
245
|
+
|
|
240
246
|
async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS() {
|
|
241
247
|
console.log('🚀 Starting job descriptions update process for ALL jobs');
|
|
242
248
|
|
|
243
249
|
try {
|
|
244
250
|
let jobsWithNoDescriptions = await getJobsWithNoDescriptions();
|
|
251
|
+
|
|
245
252
|
if (siteconfig.customFields==="true") {
|
|
246
|
-
let customValues=await getAllCustomValues();
|
|
253
|
+
let customValues = await getAllCustomValues();
|
|
254
|
+
|
|
247
255
|
console.log("inserting jobs references to custom values collection");
|
|
248
256
|
console.log("customValues: ",customValues)
|
|
249
257
|
console.log("customValues.items: ",customValues.items)
|
|
258
|
+
|
|
250
259
|
for (const value of customValues.items) {
|
|
251
|
-
await insertJobsReference(value._id);
|
|
260
|
+
await insertJobsReference(value._id, value.valueId);
|
|
252
261
|
}
|
|
253
262
|
console.log("inserted jobs references to custom values collection successfully");
|
|
254
263
|
}
|
|
@@ -360,10 +369,12 @@ async function aggregateJobsByFieldToCMS({ field, collection }) {
|
|
|
360
369
|
return { success: false, error: err.message };
|
|
361
370
|
}
|
|
362
371
|
}
|
|
372
|
+
|
|
363
373
|
async function getAllCustomValues() {
|
|
364
374
|
let customValuesQuery = await wixData.query(COLLECTIONS.CUSTOM_VALUES).limit(1000).find();
|
|
365
375
|
return customValuesQuery;
|
|
366
376
|
}
|
|
377
|
+
|
|
367
378
|
async function getJobsWithNoDescriptions() {
|
|
368
379
|
let jobswithoutdescriptionsQuery = await wixData
|
|
369
380
|
.query(COLLECTIONS.JOBS)
|
|
@@ -522,7 +533,7 @@ async function clearCollections() {
|
|
|
522
533
|
}
|
|
523
534
|
|
|
524
535
|
async function markTemplateAsExternal() {
|
|
525
|
-
await createCollectionIfMissing(COLLECTIONS.TEMPLATE_TYPE, COLLECTIONS_FIELDS.TEMPLATE_TYPE,null,'singleItem');
|
|
536
|
+
await createCollectionIfMissing(COLLECTIONS.TEMPLATE_TYPE, COLLECTIONS_FIELDS.TEMPLATE_TYPE, null, 'singleItem');
|
|
526
537
|
const tempalte = await wixData.save(COLLECTIONS.TEMPLATE_TYPE, {
|
|
527
538
|
templateType: TEMPLATE_TYPE.EXTERNAL
|
|
528
539
|
});
|
|
@@ -530,7 +541,7 @@ async function markTemplateAsExternal() {
|
|
|
530
541
|
}
|
|
531
542
|
|
|
532
543
|
async function markTemplateAsInternal() {
|
|
533
|
-
await createCollectionIfMissing(COLLECTIONS.TEMPLATE_TYPE, COLLECTIONS_FIELDS.TEMPLATE_TYPE,null,'singleItem');
|
|
544
|
+
await createCollectionIfMissing(COLLECTIONS.TEMPLATE_TYPE, COLLECTIONS_FIELDS.TEMPLATE_TYPE, null, 'singleItem');
|
|
534
545
|
const tempalte = await wixData.save(COLLECTIONS.TEMPLATE_TYPE, {
|
|
535
546
|
templateType: TEMPLATE_TYPE.INTERNAL
|
|
536
547
|
});
|
package/backend/queries.js
CHANGED
|
@@ -21,7 +21,7 @@ async function getPositionsByField(field, value) {
|
|
|
21
21
|
async function getPositionWithMultiRefField(jobId)
|
|
22
22
|
{
|
|
23
23
|
return wixData
|
|
24
|
-
.queryReferenced(COLLECTIONS.JOBS,jobId,JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES)
|
|
24
|
+
.queryReferenced(COLLECTIONS.JOBS, jobId,JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES)
|
|
25
25
|
.then(result => result.items);
|
|
26
26
|
}
|
|
27
27
|
|
package/package.json
CHANGED
|
@@ -176,17 +176,15 @@ async function handleParams(_$w,param,values) {
|
|
|
176
176
|
for(const value of valuesAsArray) {
|
|
177
177
|
|
|
178
178
|
const decodedValue = decodeURIComponent(value);
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
const option=getCorrectOption(decodedValue,options,param);
|
|
179
|
+
const options = optionsByFieldId.get(field._id);
|
|
180
|
+
const option = getCorrectOption(decodedValue, options, param);
|
|
183
181
|
|
|
184
182
|
if(option) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
applyFiltering=true;
|
|
189
|
-
dontUpdateThisCheckBox=field._id;
|
|
183
|
+
const optionIndex = getOptionIndexFromCheckBox(_$w(`#${FiltersIds[field.title]}CheckBox`).options,option.value);
|
|
184
|
+
selectedIndices.push(optionIndex);
|
|
185
|
+
existing.push(option.value);
|
|
186
|
+
applyFiltering = true;
|
|
187
|
+
dontUpdateThisCheckBox = field._id;
|
|
190
188
|
}
|
|
191
189
|
else {
|
|
192
190
|
console.warn(`${param} value not found in dropdown options`);
|
|
@@ -264,14 +262,14 @@ async function loadData() {
|
|
|
264
262
|
currentJobs=alljobs;
|
|
265
263
|
}
|
|
266
264
|
if(Object.keys(valueToJobs).length === 0){
|
|
267
|
-
allvaluesobjects=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
265
|
+
allvaluesobjects = await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
268
266
|
for (const value of allvaluesobjects) {
|
|
269
|
-
valueToJobs[value.
|
|
267
|
+
valueToJobs[value.valueId]= value.jobIds;
|
|
270
268
|
}
|
|
271
269
|
}
|
|
272
270
|
if(allfields.length===0) {
|
|
273
|
-
allfields=await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
|
|
274
|
-
allfields.push({_id:"Location",title:"Location"});
|
|
271
|
+
allfields = await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
|
|
272
|
+
allfields.push({ _id:"Location", title:"Location" });
|
|
275
273
|
}
|
|
276
274
|
} catch (error) {
|
|
277
275
|
console.error('Failed to load data:', error);
|
|
@@ -308,63 +306,67 @@ async function loadJobsRepeater(_$w) {
|
|
|
308
306
|
async function loadFilters(_$w) {
|
|
309
307
|
try {
|
|
310
308
|
// 1) Load all categories (fields)
|
|
311
|
-
const cities=await getAllRecords(COLLECTIONS.CITIES);
|
|
309
|
+
const cities = await getAllRecords(COLLECTIONS.CITIES);
|
|
312
310
|
for(const city of cities) {
|
|
313
|
-
valueToJobs[city._id]=city.jobIds;
|
|
311
|
+
valueToJobs[city._id] = city.jobIds;
|
|
314
312
|
}
|
|
315
313
|
// 2) Load all values once and group them by referenced field
|
|
316
314
|
let valuesByFieldId = groupValuesByField(allvaluesobjects, CUSTOM_VALUES_COLLECTION_FIELDS.CUSTOM_FIELD);
|
|
317
315
|
valuesByFieldId.set("Location",cities)
|
|
318
|
-
|
|
319
|
-
|
|
316
|
+
|
|
317
|
+
// Build CheckboxGroup options for this field
|
|
320
318
|
const counter={}
|
|
321
319
|
for(const city of cities) {
|
|
322
320
|
counter[city.city]=city.count
|
|
323
321
|
}
|
|
322
|
+
|
|
324
323
|
for(const [key, value] of valuesByFieldId) {
|
|
325
|
-
const field=getFieldById(key,allfields);
|
|
324
|
+
const field = getFieldById(key,allfields);
|
|
326
325
|
let originalOptions=[];
|
|
327
|
-
if(key==="Location") {
|
|
328
|
-
originalOptions=value.map(city=>({
|
|
326
|
+
if(key === "Location") {
|
|
327
|
+
originalOptions = value.map(city=>({
|
|
329
328
|
label: city.city,
|
|
330
329
|
value: city._id
|
|
331
330
|
}));
|
|
332
331
|
}
|
|
333
332
|
else{
|
|
334
|
-
originalOptions=value
|
|
333
|
+
originalOptions = value
|
|
335
334
|
}
|
|
335
|
+
|
|
336
336
|
optionsByFieldId.set(key, originalOptions);
|
|
337
|
+
|
|
337
338
|
for (const val of allvaluesobjects) {
|
|
338
339
|
counter[val.title]=val.count
|
|
339
340
|
}
|
|
340
341
|
countsByFieldId.set(key, new Map(originalOptions.map(o => [o.value, counter[o.label]])));
|
|
341
|
-
updateOptionsUI(_$w,field.title, field._id, ''); // no search query
|
|
342
|
+
updateOptionsUI(_$w, field.title, field._id, ''); // no search query
|
|
343
|
+
|
|
342
344
|
_$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = []; // start empty
|
|
343
345
|
_$w(`#${FiltersIds[field.title]}CheckBox`).onChange(async (ev) => {
|
|
344
|
-
dontUpdateThisCheckBox=field._id;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
346
|
+
dontUpdateThisCheckBox = field._id;
|
|
347
|
+
const selected = ev.target.value; // array of selected value IDs
|
|
348
|
+
let fieldTitle=field.title.toLowerCase().replace(' ', '');
|
|
349
|
+
fieldTitle === "brands"? fieldTitle = "brand" : fieldTitle;
|
|
350
|
+
|
|
351
|
+
if (selected && selected.length) {
|
|
352
|
+
selectedByField.set(field._id, selected);
|
|
353
|
+
if(fieldTitle==="brand" || fieldTitle==="storename") {
|
|
354
|
+
//in this case we need the label not valueid
|
|
355
|
+
const valueLabels = getValueFromValueId(selected, value);
|
|
356
|
+
queryParams.add({ [fieldTitle] : valueLabels.map(val=>encodeURIComponent(val)).join(',') });
|
|
357
|
+
}
|
|
358
|
+
else{
|
|
359
|
+
queryParams.add({ [fieldTitle] : selected.map(val=>encodeURIComponent(val)).join(',') });
|
|
360
|
+
}
|
|
359
361
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
362
|
+
} else {
|
|
363
|
+
selectedByField.delete(field._id);
|
|
364
|
+
queryParams.remove([fieldTitle ]);
|
|
365
|
+
}
|
|
364
366
|
|
|
365
367
|
await updateJobsAndNumbersAndFilters(_$w);
|
|
366
|
-
|
|
367
368
|
});
|
|
369
|
+
|
|
368
370
|
const runFilter = debounce(() => {
|
|
369
371
|
const query = (_$w(`#${FiltersIds[field.title]}input`).value || '').toLowerCase().trim();
|
|
370
372
|
updateOptionsUI(_$w, field.title, field._id, query);
|
|
@@ -379,11 +381,11 @@ async function loadJobsRepeater(_$w) {
|
|
|
379
381
|
}
|
|
380
382
|
}
|
|
381
383
|
|
|
382
|
-
function getValueFromValueId(valueIds,value) {
|
|
383
|
-
let valueLabels=[];
|
|
384
|
+
function getValueFromValueId(valueIds, value) {
|
|
385
|
+
let valueLabels = [];
|
|
384
386
|
let currentVal
|
|
385
|
-
for(const valueId of valueIds) {
|
|
386
|
-
currentVal=value.find(val=>val.value===valueId);
|
|
387
|
+
for (const valueId of valueIds) {
|
|
388
|
+
currentVal = value.find(val => val.value === valueId);
|
|
387
389
|
if(currentVal) {
|
|
388
390
|
valueLabels.push(currentVal.label);
|
|
389
391
|
}
|
|
@@ -543,7 +545,7 @@ async function refreshFacetCounts(_$w,clearAll=false) {
|
|
|
543
545
|
const currentJobsIds=jobs.map(job=>job._id);
|
|
544
546
|
|
|
545
547
|
for (const fieldId of fieldIds) {
|
|
546
|
-
let currentoptions=optionsByFieldId.get(fieldId)
|
|
548
|
+
let currentoptions = optionsByFieldId.get(fieldId)
|
|
547
549
|
let counter=new Map();
|
|
548
550
|
for(const option of currentoptions) {
|
|
549
551
|
for (const jobId of currentJobsIds) {
|
|
@@ -556,8 +558,7 @@ async function refreshFacetCounts(_$w,clearAll=false) {
|
|
|
556
558
|
}
|
|
557
559
|
}
|
|
558
560
|
|
|
559
|
-
|
|
560
|
-
function updateSelectedValuesRepeater(_$w) {
|
|
561
|
+
function updateSelectedValuesRepeater(_$w) {
|
|
561
562
|
const selectedItems = [];
|
|
562
563
|
for (const [fieldId, valueIds] of selectedByField.entries()) {
|
|
563
564
|
const opts = optionsByFieldId.get(fieldId) || [];
|
|
@@ -568,7 +569,7 @@ async function refreshFacetCounts(_$w,clearAll=false) {
|
|
|
568
569
|
}
|
|
569
570
|
}
|
|
570
571
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).data = selectedItems;
|
|
571
|
-
|
|
572
|
+
}
|
|
572
573
|
|
|
573
574
|
|
|
574
575
|
|
package/pages/homePage.js
CHANGED
|
@@ -8,34 +8,37 @@ const { location } = require('@wix/site-location');
|
|
|
8
8
|
const {wixData} = require('wix-data');
|
|
9
9
|
const { COLLECTIONS } = require('../backend/collectionConsts');
|
|
10
10
|
const { bindPrimarySearch,getAllRecords,loadPrimarySearchRepeater } = require('./pagesUtils');
|
|
11
|
+
|
|
12
|
+
|
|
11
13
|
let thisObjectVar;
|
|
12
14
|
let searchByCityFlag=false;
|
|
13
15
|
let loadedCategories=false;
|
|
14
|
-
async function homePageOnReady(_$w,thisObject=null) {
|
|
15
16
|
|
|
17
|
+
async function homePageOnReady(_$w,thisObject=null) {
|
|
16
18
|
const queryResult = await wixData.query(COLLECTIONS.SITE_CONFIGS).find();
|
|
17
19
|
const siteconfig = queryResult.items[0];
|
|
20
|
+
|
|
18
21
|
if(siteconfig.twg) {
|
|
19
|
-
const allJobs=await getAllRecords(COLLECTIONS.JOBS);
|
|
20
|
-
const allvaluesobjects=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
21
|
-
|
|
22
|
+
const allJobs = await getAllRecords(COLLECTIONS.JOBS);
|
|
23
|
+
const allvaluesobjects = await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
24
|
+
|
|
25
|
+
bindPrimarySearch(_$w, allvaluesobjects, allJobs);
|
|
22
26
|
loadPrimarySearchRepeater(_$w)
|
|
23
27
|
console.log("siteconfig.twg: ",siteconfig.twg);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
|
|
29
|
+
if(siteconfig.twg === "external") {
|
|
30
|
+
bindTeamRepeater(_$w)
|
|
31
|
+
bindViewAllButton(_$w)
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
else{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
await init(_$w);
|
|
35
|
+
thisObjectVar=thisObject;
|
|
36
|
+
bind(_$w);
|
|
37
|
+
init(_$w);
|
|
34
38
|
}
|
|
35
|
-
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
function bind(_$w) {
|
|
39
42
|
|
|
40
43
|
bindTeamRepeater(_$w);
|
|
41
44
|
|
package/pages/pagesUtils.js
CHANGED
|
@@ -11,7 +11,7 @@ function groupValuesByField(values, refKey) {
|
|
|
11
11
|
if (!map.has(ref)) map.set(ref, []);
|
|
12
12
|
map.get(ref).push({
|
|
13
13
|
label: v.title ,
|
|
14
|
-
value: v.
|
|
14
|
+
value: v.valueId
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
return map;
|
|
@@ -121,7 +121,7 @@ function loadPrimarySearchRepeater(_$w) {
|
|
|
121
121
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
function bindPrimarySearch(_$w,allvaluesobjects,alljobs) {
|
|
124
|
+
function bindPrimarySearch(_$w, allvaluesobjects, alljobs) {
|
|
125
125
|
|
|
126
126
|
const primarySearchDebounced = debounce(async () => {
|
|
127
127
|
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value || '').toLowerCase().trim();
|
|
@@ -132,61 +132,63 @@ function loadPrimarySearchRepeater(_$w) {
|
|
|
132
132
|
await primarySearchDebounced();
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onClick(async () => {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
135
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onClick(async () => {
|
|
136
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
|
|
137
|
+
|
|
138
|
+
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()!=='') {
|
|
139
|
+
await primarySearch(_$w, _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim(), alljobs);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
await loadCategoriesListPrimarySearch(_$w, allvaluesobjects);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
144
145
|
|
|
145
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).onMouseOut(async () => {
|
|
146
|
-
|
|
147
|
-
});
|
|
146
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).onMouseOut(async () => {
|
|
147
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onKeyPress(async (event) => {
|
|
151
|
+
if( event.key==='Enter') {
|
|
152
|
+
console.log("primary search input key pressed");
|
|
153
|
+
console.log("_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value: ",_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
154
|
+
|
|
155
|
+
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()==='') {
|
|
156
|
+
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
157
|
+
const baseUrl = await location.baseUrl();
|
|
158
|
+
location.to(`${baseUrl}/search`);
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
163
|
+
const baseUrl = await location.baseUrl();
|
|
164
|
+
location.to(`${baseUrl}/search?keyword=${encodedKeyWord}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
148
168
|
|
|
149
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.
|
|
150
|
-
|
|
151
|
-
console.log("primary search input key pressed");
|
|
169
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_BUTTON).onClick(async () => {
|
|
170
|
+
console.log("primary search button clicked");
|
|
152
171
|
console.log("_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value: ",_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
172
|
+
|
|
153
173
|
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()==='') {
|
|
154
|
-
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
|
|
155
174
|
const baseUrl = await location.baseUrl();
|
|
156
175
|
location.to(`${baseUrl}/search`);
|
|
157
|
-
|
|
158
|
-
}
|
|
176
|
+
}
|
|
159
177
|
else {
|
|
160
178
|
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
161
179
|
const baseUrl = await location.baseUrl();
|
|
162
|
-
|
|
180
|
+
location.to(`${baseUrl}/search?keyword=${encodedKeyWord}`);
|
|
163
181
|
}
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_BUTTON).onClick(async () => {
|
|
168
|
-
console.log("primary search button clicked");
|
|
169
|
-
console.log("_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value: ",_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
170
|
-
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()==='') {
|
|
171
|
-
const baseUrl = await location.baseUrl();
|
|
172
|
-
location.to(`${baseUrl}/search`);
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
176
|
-
const baseUrl = await location.baseUrl();
|
|
177
|
-
location.to(`${baseUrl}/search?keyword=${encodedKeyWord}`);
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
|
|
182
|
+
});
|
|
182
183
|
}
|
|
183
184
|
|
|
184
|
-
async function loadCategoriesListPrimarySearch(_$w,allvaluesobjects) {
|
|
185
|
+
async function loadCategoriesListPrimarySearch(_$w, allvaluesobjects) {
|
|
185
186
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("categoryResults");
|
|
187
|
+
|
|
186
188
|
let categoryValues=[]
|
|
187
189
|
for(const value of allvaluesobjects) {
|
|
188
|
-
if(value.customField===CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
|
|
189
|
-
categoryValues.push({title:value.title+` (${value.count})` ,_id:value.
|
|
190
|
+
if(value.customField === CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
|
|
191
|
+
categoryValues.push({title: value.title+` (${value.count})` , _id: value.valueId});
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
194
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data = categoryValues;
|
|
@@ -216,13 +218,13 @@ async function primarySearch(_$w,query,alljobs) {
|
|
|
216
218
|
|
|
217
219
|
}
|
|
218
220
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
221
|
+
async function getValueFromValueId(valueId) {
|
|
222
|
+
const result = await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
223
|
+
console.log("result: ",result);
|
|
224
|
+
console.log("valueId: ",valueId);
|
|
225
|
+
|
|
226
|
+
return result.find(value => value.valueId === valueId);
|
|
227
|
+
}
|
|
226
228
|
|
|
227
229
|
async function getLatestJobsByValue(Value) {
|
|
228
230
|
const jobs=Value.multiRefJobsCustomValues;
|
package/pages/positionPage.js
CHANGED
|
@@ -58,7 +58,7 @@ async function getCategoryValue(customValues) {
|
|
|
58
58
|
_$w('#jobCategory').text = categoryValue.title;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const relatedJobs = await getRelatedJobs({ categoryValueId:categoryValue._id, itemId: item._id ,limit:5});
|
|
61
|
+
const relatedJobs = await getRelatedJobs({ categoryValueId: categoryValue._id, itemId: item._id ,limit:5});
|
|
62
62
|
_$w('#relatedJobsRepNoDepartment').onItemReady(($item, itemData) => {
|
|
63
63
|
$item('#relatedJobTitle').text = itemData.title;
|
|
64
64
|
$item('#relatedJobLocation').text = itemData.location.fullLocation;
|
|
@@ -124,8 +124,6 @@ async function getCategoryValue(customValues) {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
async function getRelatedJobs({ categoryValueId, itemId, limit = 1000 }) {
|
|
127
|
-
|
|
128
|
-
|
|
129
127
|
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();
|
|
130
128
|
return relatedJobs.items;
|
|
131
129
|
}
|
|
@@ -32,16 +32,16 @@ async function handlePeopleSection(_$w) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
async function handleRecentJobsSection(_$w) {
|
|
35
|
-
|
|
36
|
-
|
|
37
35
|
if(supportTeamsPageIds.excludeValues.has(currentItem.title_fld)) {
|
|
38
36
|
console.log("Value is excluded , collapsing recently Jobs Section ");
|
|
39
|
-
await collapseSection(_$w,supportTeamsPageSections.RECENT_JOBS);
|
|
37
|
+
await collapseSection(_$w, supportTeamsPageSections.RECENT_JOBS);
|
|
40
38
|
return;
|
|
41
39
|
}
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
40
|
+
|
|
41
|
+
const valueId = supportTeamsPageIds.valueToValueIdMap[currentItem.title_fld]
|
|
42
|
+
const Value = await getValueFromValueId(valueId);
|
|
43
|
+
|
|
44
|
+
if( Value === undefined ) {
|
|
45
45
|
console.log("Value is undefined , collapsing recently Jobs Section ");
|
|
46
46
|
await collapseSection(_$w,supportTeamsPageSections.RECENT_JOBS);
|
|
47
47
|
return;
|