sr-npm 1.7.192 → 1.7.193

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.192",
3
+ "version": "1.7.193",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -16,11 +16,12 @@ const {
16
16
  let queryPageVar;
17
17
  let queryKeyWordVar;
18
18
  let queryDepartmentVar;
19
-
20
- async function careersPageOnReady(_$w,thisObject,querypage,querykeyWord,querydepartment) {
19
+ let queryLocationVar;
20
+ async function careersPageOnReady(_$w,thisObject,querypage,querykeyWord,querydepartment,querylocation) {
21
21
  queryPageVar=querypage;
22
22
  queryKeyWordVar=querykeyWord;
23
23
  queryDepartmentVar=querydepartment;
24
+ queryLocationVar=querylocation;
24
25
  thisObjectVar=thisObject;
25
26
  allJobs=await getAllPositions();
26
27
  await handleUrlParams(_$w);
@@ -90,6 +91,9 @@ async function handleUrlParams(_$w) {
90
91
  if (queryDepartmentVar) {
91
92
  await handleDepartmentParam(_$w,queryDepartmentVar);
92
93
  }
94
+ if (queryLocationVar) {
95
+ await handleLocationParam(_$w,queryLocationVar);
96
+ }
93
97
  }
94
98
 
95
99
  async function handleKeyWordParam(_$w,keyWord) {
@@ -200,6 +204,9 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
200
204
  if(filter.field === 'department'){
201
205
  queryParams.add({ department: encodeURIComponent(filter.value) });
202
206
  }
207
+ if(filter.field === 'cityText'){
208
+ queryParams.add({ location: encodeURIComponent(filter.value) });
209
+ }
203
210
  }
204
211
  if(filter.field === 'remote') {
205
212
  value = filter.value === 'true';
@@ -216,6 +223,9 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
216
223
  if(filter.field === 'department'){
217
224
  queryParams.remove(["department" ]);
218
225
  }
226
+ if(filter.field === 'cityText'){
227
+ queryParams.remove(["location" ]);
228
+ }
219
229
  }
220
230
  }
221
231
  });
@@ -266,7 +276,7 @@ async function handleDepartmentParam(_$w,department) {
266
276
  //+1 because of the "All" option
267
277
 
268
278
  if(dropdownOptions.length!==optionsFromCMS.items.length+1){
269
- fixDropdownOptions(optionsFromCMS, _$w);
279
+ fixDropdownOptions('#dropdownDepartment',optionsFromCMS, _$w);
270
280
  }
271
281
 
272
282
  if (_$w('#dropdownDepartment').options.find(option => option.value === departmentValue))
@@ -284,7 +294,7 @@ async function handleDepartmentParam(_$w,department) {
284
294
 
285
295
  }
286
296
 
287
- function fixDropdownOptions(optionsFromCMS, _$w){
297
+ function fixDropdownOptions(dropdown,optionsFromCMS, _$w){
288
298
  let dropdownOptions = [];
289
299
  dropdownOptions=[{
290
300
  label: "All",
@@ -294,11 +304,34 @@ function fixDropdownOptions(optionsFromCMS, _$w){
294
304
  label: item.title,
295
305
  value: item.title
296
306
  })));
297
- _$w('#dropdownDepartment').options=dropdownOptions;
307
+ _$w(dropdown).options=dropdownOptions;
298
308
  console.warn("something is wrong with the dropdown options, fixing it");
299
309
 
300
310
  }
301
311
 
312
+ async function handleLocationParam(_$w,location) {
313
+ let dropdownOptions = _$w('#dropdownLocation').options;
314
+ console.log("location dropdown options:", dropdownOptions);
315
+ const optionsFromCMS=await wixData.query("Cities").find();
316
+ //+1 because of the "All" option
317
+
318
+ if(dropdownOptions.length!==optionsFromCMS.items.length+1){
319
+ fixDropdownOptions('#dropdownLocation',optionsFromCMS, _$w);
320
+ }
321
+
322
+ if (_$w('#dropdownLocation').options.find(option => option.value === locationValue))
323
+ {
324
+ _$w('#dropdownLocation').value = locationValue;
325
+ await applyFilters(_$w, true); // Skip URL update since we're handling initial URL params
326
+ }
327
+ else{
328
+ console.warn("department value not found in dropdown options");
329
+ queryParams.remove(["department" ]);
330
+
331
+ }
332
+
333
+ }
334
+
302
335
 
303
336
 
304
337
  module.exports = {