sr-npm 1.7.250 → 1.7.252

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/data.js CHANGED
@@ -54,6 +54,13 @@ async function saveJobsDataToCMS() {
54
54
  return basicJob;
55
55
  });
56
56
 
57
+ // Sort jobs by title (ascending, case-insensitive, numeric-aware)
58
+ jobsData.sort((a, b) => {
59
+ const titleA = a.title || '';
60
+ const titleB = b.title || '';
61
+ return titleA.localeCompare(titleB, undefined, { sensitivity: 'base', numeric: true });
62
+ });
63
+
57
64
  const chunkSize = 1000;
58
65
  let totalSaved = 0;
59
66
  const totalChunks = Math.ceil(jobsData.length / chunkSize);
package/backend/utils.js CHANGED
@@ -48,7 +48,7 @@ function prepareToSaveArray(jobsPerField, cityLocations, field,citylocationAddre
48
48
  } else {
49
49
  return Object.entries(jobsPerField).map(([value, amount]) => ({
50
50
  title: value,
51
- _id: value.replace(/\s+/g, '').replace(/&/g, 'and'),
51
+ _id: sanitizeId(value),
52
52
  count: amount,
53
53
  }));
54
54
  }
@@ -63,6 +63,15 @@ function normalizeCityName(city) {
63
63
  .trim();
64
64
  }
65
65
 
66
+ function sanitizeId(input) {
67
+ if (!input) return '';
68
+ const withoutDiacritics = String(input)
69
+ .normalize('NFD')
70
+ .replace(/\p{Diacritic}/gu, '');
71
+ const withAnd = withoutDiacritics.replace(/&/g, 'and');
72
+ return withAnd.replace(/[^A-Za-z0-9-]/g, '');
73
+ }
74
+
66
75
  module.exports = {
67
76
  chunkedBulkOperation,
68
77
  delay,
@@ -70,4 +79,5 @@ module.exports = {
70
79
  fillCityLocationAndLocationAddress,
71
80
  prepareToSaveArray,
72
81
  normalizeCityName,
82
+ sanitizeId,
73
83
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.250",
3
+ "version": "1.7.252",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -18,9 +18,7 @@ const {
18
18
  let queryKeyWordVar;
19
19
  let queryDepartmentVar;
20
20
  let queryLocationVar;
21
- let baseUrl;
22
21
  async function careersPageOnReady(_$w,thisObject,queryParams) {
23
- baseUrl = await location.baseUrl();
24
22
  console.log("queryParams: ", queryParams);
25
23
  const { page, keyWord, department, location } = queryParams;
26
24
  queryPageVar=page;
@@ -53,7 +51,6 @@ function activateAutoLoad(_$w)
53
51
  }
54
52
 
55
53
  async function loadMoreJobs(_$w) {
56
- //const query = await location.query();
57
54
  let shouldLoad = false;
58
55
  if (pageParamSet == 0) {
59
56
  shouldLoad = true;
@@ -86,7 +83,6 @@ async function setPageParamInUrl() {
86
83
 
87
84
  }
88
85
  async function handleUrlParams(_$w) {
89
- // const query = await location.query();
90
86
  if (queryKeyWordVar) {
91
87
  await handleKeyWordParam(_$w,queryKeyWordVar);
92
88
  }
@@ -147,15 +143,17 @@ async function handlePageParam(_$w) {
147
143
  async function bind(_$w) {
148
144
  await _$w('#jobsDataset').onReady(async () => {
149
145
  await updateCount(_$w);
146
+ await updateMapMarkers(_$w);
150
147
 
151
148
  });
152
149
 
153
- if (await window.formFactor === "Mobile") {
150
+ if (await window.formFactor() === "Mobile") {
154
151
  _$w('#dropdownsContainer').collapse();
155
152
  }
156
153
 
157
154
  _$w('#positionsRepeater').onItemReady(async ($item, itemData) => {
158
155
  $item('#positionItem').onClick(async () => {
156
+ let baseUrl = await location.baseUrl();
159
157
  to(`${baseUrl}/jobs/${itemData._id}`);
160
158
  });
161
159
  });
@@ -175,15 +173,18 @@ function init(_$w) {
175
173
  _$w('#closeFiltersButton').onClick(()=>{
176
174
  _$w('#dropdownsContainer, #closeFiltersButton').collapse();
177
175
  });
176
+
178
177
  }
179
178
 
180
179
  async function applyFilters(_$w, skipUrlUpdate = false) {
180
+ console.log("applying filters");
181
181
  const dropdownFiltersMapping = [
182
182
  { elementId: '#dropdownDepartment', field: 'department', value: _$w('#dropdownDepartment').value },
183
183
  { elementId: '#dropdownLocation', field: 'cityText', value: _$w('#dropdownLocation').value },
184
184
  { elementId: '#dropdownJobType', field: 'remote', value: _$w('#dropdownJobType').value},
185
185
  { elementId: '#searchInput', field: 'title', value: _$w('#searchInput').value }
186
186
  ];
187
+ console.log("dropdownFiltersMapping: ", dropdownFiltersMapping);
187
188
 
188
189
 
189
190
 
@@ -241,7 +242,7 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
241
242
 
242
243
  const count = await updateCount(_$w);
243
244
  console.log("updating map markers");
244
- await updateMapMarkers(_$w,count);
245
+ await updateMapMarkers(_$w);
245
246
  console.log("updating map markers completed");
246
247
  count ? _$w('#resultsMultiState').changeState('results') : _$w('#resultsMultiState').changeState('noResults');
247
248
 
@@ -261,9 +262,13 @@ async function resetFilters(_$w) {
261
262
 
262
263
  _$w('#resetFiltersButton').disable();
263
264
 
264
- queryParams.remove(["keyWord", "department","page"]);
265
+ queryParams.remove(["keyWord", "department","page","location"]);
266
+
265
267
 
266
268
  await updateCount(_$w);
269
+ console.log("reseting map markers");
270
+ await updateMapMarkers(_$w);
271
+ console.log("reseting map markers completed");
267
272
  }
268
273
 
269
274
  async function updateCount(_$w) {
@@ -341,27 +346,36 @@ async function handleLocationParam(_$w,location) {
341
346
 
342
347
  }
343
348
 
344
- async function updateMapMarkers(_$w,count){
345
- if(count>0){
349
+ async function updateMapMarkers(_$w){
346
350
  const numOfItems = await _$w('#jobsDataset').getTotalCount();
347
351
  const items = await _$w('#jobsDataset').getItems(0, numOfItems);
348
- const markers = items.items.map(item => {
349
- const location = item.locationAddress.location;
350
- return {
351
- location: {
352
- latitude: location.latitude,
353
- longitude: location.longitude
354
- },
355
- address: item.locationAddress.formatted,
356
- title: item.title,
357
- };
358
- });
352
+ const markers = items.items
353
+ .filter(item => {
354
+ const locationAddress = item.locationAddress;
355
+ const location = locationAddress && locationAddress.location;
356
+ return (
357
+ location !== undefined &&
358
+ location !== null &&
359
+ location.latitude !== undefined &&
360
+ location.latitude !== null &&
361
+ location.longitude !== undefined &&
362
+ location.longitude !== null
363
+ );
364
+ })
365
+ .map(item => {
366
+ const location = item.locationAddress.location;
367
+ return {
368
+ location: {
369
+ latitude: location.latitude,
370
+ longitude: location.longitude
371
+ },
372
+ address: item.locationAddress.formatted,
373
+ title: item.title
374
+ };
375
+ });
359
376
  //@ts-ignore
360
- _$w('#googleMaps').setMarkers(markers);
361
- }
362
- else{
363
- _$w('#googleMaps').setMarkers([]);
364
- }
377
+ await _$w('#googleMaps').setMarkers(markers);
378
+
365
379
  }
366
380
 
367
381