sr-npm 1.2.23 → 1.2.24

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.
@@ -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
- const fieldId=normalizeString(field.fieldId)
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 {companyId ,templateType} = await getApiKeys();
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
- const basicJob = {
128
- _id: position.id,
129
- title: position.name || '',
130
- slug: generateSlug(position.name || ''),
131
- department: position.department?.label || 'Other',
132
- cityText: normalizeString(position.location?.city),
133
- location: position.location && Object.keys(position.location).length > 0
134
- ? position.location
135
- : {
136
- countryCode: "",
137
- country: "",
138
- city: "",
139
- postalCode: "",
140
- address: "",
141
- manual: false,
142
- remote: false,
143
- regionCode: ""
144
- },
145
- country: position.location?.country || '',
146
- remote: position.location?.remote || false,
147
- language: position.language?.label || '',
148
- brand: siteconfig.disableMultiBrand==="false" ? getBrand(position.customField) : '',
149
- jobDescription: null, // Will be filled later
150
- employmentType: position.typeOfEmployment.label,
151
- releasedDate: position.releasedDate,
152
- refId: position.refNumber
153
- };
154
-
155
- getCustomFieldsAndValuesFromPosition(position,customFieldsLabels,customFieldsValues);
156
- getEmploymentType(position,customFieldsValues);
157
- getLocation(position,basicJob);
158
- if(templateType===TEMPLATE_TYPE.INTERNAL){
159
- getVisibility(position,customFieldsValues);
160
- }
161
- return basicJob;
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
- await populateCustomFieldsCollection(customFieldsLabels,templateType);
166
- await populateCustomValuesCollection(customFieldsValues);
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,valueId, Array.from(customValuesToJobs[valueId]));
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
- _id: valueId,
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
  });
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.2.23",
3
+ "version": "1.2.24",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -264,14 +264,14 @@ async function loadData() {
264
264
  currentJobs=alljobs;
265
265
  }
266
266
  if(Object.keys(valueToJobs).length === 0){
267
- allvaluesobjects=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
267
+ allvaluesobjects = await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
268
268
  for (const value of allvaluesobjects) {
269
- valueToJobs[value._id]= value.jobIds;
269
+ valueToJobs[value.valueId]= value.jobIds;
270
270
  }
271
271
  }
272
272
  if(allfields.length===0) {
273
- allfields=await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
274
- allfields.push({_id:"Location",title:"Location"});
273
+ allfields = await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
274
+ allfields.push({ _id:"Location", title:"Location" });
275
275
  }
276
276
  } catch (error) {
277
277
  console.error('Failed to load data:', error);
@@ -282,7 +282,7 @@ async function loadJobsRepeater(_$w) {
282
282
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).onItemReady(($item, itemData) => {
283
283
  $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER_ITEM_TITLE).text = itemData.title;
284
284
  $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER_ITEM_TITLE).onClick(() => {
285
- location.to(itemData["link-jobs-title"] || itemData["link-copy-of-jobs-title"]);
285
+ location.to(itemData["link-jobs-title"] || itemData["link-jobs-refId-slug"]);
286
286
  });
287
287
  $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER_ITEM_LOCATION).text=itemData.location.fullLocation
288
288
  $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER_ITEM_EMPLOYMENT_TYPE).text=itemData.employmentType
@@ -315,23 +315,23 @@ async function loadJobsRepeater(_$w) {
315
315
  // 2) Load all values once and group them by referenced field
316
316
  let valuesByFieldId = groupValuesByField(allvaluesobjects, CUSTOM_VALUES_COLLECTION_FIELDS.CUSTOM_FIELD);
317
317
  valuesByFieldId.set("Location",cities)
318
- // Build CheckboxGroup options for this field
319
-
318
+
319
+ // Build CheckboxGroup options for this field
320
320
  const counter={}
321
321
  for(const city of cities) {
322
322
  counter[city.city]=city.count
323
323
  }
324
324
  for(const [key, value] of valuesByFieldId) {
325
- const field=getFieldById(key,allfields);
325
+ const field = getFieldById(key,allfields);
326
326
  let originalOptions=[];
327
- if(key==="Location") {
328
- originalOptions=value.map(city=>({
327
+ if(key === "Location") {
328
+ originalOptions = value.map(city=>({
329
329
  label: city.city,
330
- value: city._id
330
+ value: city.valueId
331
331
  }));
332
332
  }
333
333
  else{
334
- originalOptions=value
334
+ originalOptions = value
335
335
  }
336
336
  optionsByFieldId.set(key, originalOptions);
337
337
  for (const val of allvaluesobjects) {
@@ -350,7 +350,7 @@ async function loadJobsRepeater(_$w) {
350
350
  selectedByField.set(field._id, selected);
351
351
  if(fieldTitle==="brand" || fieldTitle==="storename") {
352
352
  //in this case we need the label not valueid
353
- const valueLabels=getValueFromValueId(selected,value);
353
+ const valueLabels = getValueFromValueId(selected, value);
354
354
  queryParams.add({ [fieldTitle] : valueLabels.map(val=>encodeURIComponent(val)).join(',') });
355
355
  }
356
356
  else{
@@ -363,8 +363,8 @@ async function loadJobsRepeater(_$w) {
363
363
  }
364
364
 
365
365
  await updateJobsAndNumbersAndFilters(_$w);
366
-
367
366
  });
367
+
368
368
  const runFilter = debounce(() => {
369
369
  const query = (_$w(`#${FiltersIds[field.title]}input`).value || '').toLowerCase().trim();
370
370
  updateOptionsUI(_$w, field.title, field._id, query);
@@ -379,11 +379,11 @@ async function loadJobsRepeater(_$w) {
379
379
  }
380
380
  }
381
381
 
382
- function getValueFromValueId(valueIds,value) {
383
- let valueLabels=[];
382
+ function getValueFromValueId(valueIds, value) {
383
+ let valueLabels = [];
384
384
  let currentVal
385
- for(const valueId of valueIds) {
386
- currentVal=value.find(val=>val.value===valueId);
385
+ for (const valueId of valueIds) {
386
+ currentVal = value.find(val => val.value === valueId);
387
387
  if(currentVal) {
388
388
  valueLabels.push(currentVal.label);
389
389
  }
@@ -556,8 +556,7 @@ async function refreshFacetCounts(_$w,clearAll=false) {
556
556
  }
557
557
  }
558
558
 
559
-
560
- function updateSelectedValuesRepeater(_$w) {
559
+ function updateSelectedValuesRepeater(_$w) {
561
560
  const selectedItems = [];
562
561
  for (const [fieldId, valueIds] of selectedByField.entries()) {
563
562
  const opts = optionsByFieldId.get(fieldId) || [];
@@ -568,7 +567,7 @@ async function refreshFacetCounts(_$w,clearAll=false) {
568
567
  }
569
568
  }
570
569
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).data = selectedItems;
571
- }
570
+ }
572
571
 
573
572
 
574
573
 
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
- bindPrimarySearch(_$w,allvaluesobjects,allJobs);
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
- if(siteconfig.twg==="external") {
25
- bindTeamRepeater(_$w)
26
- bindViewAllButton(_$w)
28
+
29
+ if(siteconfig.twg === "external") {
30
+ bindTeamRepeater(_$w)
31
+ bindViewAllButton(_$w)
27
32
  }
28
33
  }
29
34
  else{
30
-
31
- thisObjectVar=thisObject;
32
- await bind(_$w);
33
- await init(_$w);
35
+ thisObjectVar=thisObject;
36
+ bind(_$w);
37
+ init(_$w);
34
38
  }
35
-
36
39
  }
37
40
 
38
- function bind(_$w) {
41
+ function bind(_$w) {
39
42
 
40
43
  bindTeamRepeater(_$w);
41
44
 
@@ -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,62 @@ function loadPrimarySearchRepeater(_$w) {
132
132
  await primarySearchDebounced();
133
133
  });
134
134
 
135
- _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onClick(async () => {
136
- _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
137
- if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()!=='') {
138
- await primarySearch(_$w, _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim(), alljobs);
139
- }
140
- else {
141
- await loadCategoriesListPrimarySearch(_$w,allvaluesobjects);
142
- }
143
- });
135
+ _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onClick(async () => {
136
+ _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
144
137
 
145
- _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).onMouseOut(async () => {
146
- _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).collapse();
147
- });
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
+ });
148
145
 
149
- _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onKeyPress(async (event) => {
150
- if( event.key==='Enter') {
151
- console.log("primary search input key pressed");
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
+ });
168
+
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
- location.to(`${baseUrl}/search?keyword=${encodedKeyWord}`);
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");
186
187
  let categoryValues=[]
187
188
  for(const value of allvaluesobjects) {
188
189
  if(value.customField===CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
189
- categoryValues.push({title:value.title+` (${value.count})` ,_id:value._id});
190
+ categoryValues.push({title: value.title+` (${value.count})` , _id: value.valueId});
190
191
  }
191
192
  }
192
193
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data = categoryValues;
@@ -216,13 +217,13 @@ async function primarySearch(_$w,query,alljobs) {
216
217
 
217
218
  }
218
219
 
219
- async function getValueFromValueId(valueId) {
220
- const result=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
221
- console.log("result: ",result);
222
- console.log("valueId: ",valueId);
223
- return result.find(value=>value._id===valueId);
224
-
225
- }
220
+ async function getValueFromValueId(valueId) {
221
+ const result = await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
222
+ console.log("result: ",result);
223
+ console.log("valueId: ",valueId);
224
+
225
+ return result.find(value => value.valueId === valueId);
226
+ }
226
227
 
227
228
  async function getLatestJobsByValue(Value) {
228
229
  const jobs=Value.multiRefJobsCustomValues;
@@ -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
- const valueId=supportTeamsPageIds.valueToValueIdMap[currentItem.title_fld]
43
- const Value=await getValueFromValueId(valueId);
44
- if(Value===undefined) {
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;