sr-npm 1.7.350 → 1.7.352

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.350",
3
+ "version": "1.7.352",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -19,15 +19,17 @@ const {
19
19
  let queryKeyWordVar;
20
20
  let queryDepartmentVar;
21
21
  let queryLocationVar;
22
+ let queryJobTypeVar;
22
23
  let searchInputBlurredFirstTime=true;
23
24
  let deletedParam=false;
24
25
  async function careersPageOnReady(_$w,thisObject,queryParams) {
25
26
  console.log("queryParams: ", queryParams);
26
- const { page, keyWord, department, location } = queryParams;
27
+ const { page, keyWord, department, location,jobType } = queryParams;
27
28
  queryPageVar=page;
28
29
  queryKeyWordVar=keyWord;
29
30
  queryDepartmentVar=department;
30
31
  queryLocationVar=location;
32
+ queryJobTypeVar=jobType;
31
33
  thisObjectVar=thisObject;
32
34
  allJobs=await getAllPositions();
33
35
  await activateAutoLoad(_$w);
@@ -102,7 +104,9 @@ async function handleUrlParams(_$w) {
102
104
  if (queryLocationVar) {
103
105
  await handleLocationParam(_$w,queryLocationVar);
104
106
  }
105
-
107
+ if (queryJobTypeVar) {
108
+ await handleJobTypeParam(_$w,queryJobTypeVar);
109
+ }
106
110
  await applyFilters(_$w, true); // Skip URL update since we're handling initial URL params
107
111
  }
108
112
 
@@ -188,31 +192,9 @@ function init(_$w) {
188
192
 
189
193
  //URL onChange
190
194
  onChange(async ()=>{
191
- let deletedParam=false
192
- const newQueryParams=await location.query();
193
- console.log("onChange triggering on ready");
194
- console.log("newQueryParams: ", newQueryParams);
195
- if(newQueryParams.department){
196
- queryDepartmentVar=newQueryParams.department;
197
- }
198
- else{
199
- queryDepartmentVar=undefined;
200
- deletedParam=true;
201
- _$w('#dropdownDepartment').value = '';
202
- }
203
- if(newQueryParams.location){
204
- queryLocationVar=newQueryParams.location;
205
- }
206
- else{
207
- queryLocationVar=undefined;
208
- deletedParam=true
209
- _$w('#dropdownLocation').value = '';
210
- }
211
- await handleUrlParams(_$w);
212
- // if(deletedParam){
213
- // await applyFilters(_$w,true);
214
- // }
215
-
195
+ await handleBackAndForth(_$w);
196
+
197
+
216
198
 
217
199
 
218
200
 
@@ -272,6 +254,48 @@ function init(_$w) {
272
254
  }
273
255
 
274
256
 
257
+ async function handleBackAndForth(_$w){
258
+ const newQueryParams=await location.query();
259
+ console.log("newQueryParams: ", newQueryParams);
260
+ if(newQueryParams.department){
261
+ queryDepartmentVar=newQueryParams.department;
262
+ }
263
+ else{
264
+ queryDepartmentVar=undefined;
265
+ deletedParam=true;
266
+ _$w('#dropdownDepartment').value = '';
267
+ }
268
+ if(newQueryParams.location){
269
+ queryLocationVar=newQueryParams.location;
270
+ }
271
+ else{
272
+ queryLocationVar=undefined;
273
+ deletedParam=true
274
+ _$w('#dropdownLocation').value = '';
275
+ }
276
+ if(newQueryParams.keyWord){
277
+ queryKeyWordVar=newQueryParams.keyWord;
278
+ }
279
+ else{
280
+ queryKeyWordVar=undefined;
281
+ deletedParam=true;
282
+ _$w('#searchInput').value = '';
283
+ }
284
+ if(newQueryParams.jobType){
285
+ queryJobTypeVar=newQueryParams.jobType;
286
+ }
287
+ else{
288
+ queryJobTypeVar=undefined;
289
+ deletedParam=true;
290
+ _$w('#dropdownJobType').value = '';
291
+ }
292
+ await handleUrlParams(_$w);
293
+ // if(deletedParam){
294
+ // await applyFilters(_$w,true);
295
+ // }
296
+
297
+ }
298
+
275
299
  async function applyFilters(_$w, skipUrlUpdate = false) {
276
300
  console.log("applying filters");
277
301
  const dropdownFiltersMapping = [
@@ -292,12 +316,6 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
292
316
  if (filter.value === RESET_ALL) {
293
317
  _$w(filter.elementId).value = '';
294
318
  filter.value = '';
295
- if (!skipUrlUpdate) {
296
- //queryParams.remove(["keyWord", "department","page","location"]);
297
- // queryKeyWordVar=undefined;
298
- // queryDepartmentVar=undefined;
299
- // queryLocationVar=undefined;
300
- }
301
319
  }
302
320
 
303
321
  // build filters
@@ -315,6 +333,10 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
315
333
  queryParams.add({ location: encodeURIComponent(filter.value) });
316
334
  //queryLocationVar=filter.value;
317
335
  }
336
+ if(filter.field === 'remote'){
337
+ queryParams.add({ jobType: encodeURIComponent(filter.value) });
338
+ //queryJobTypeVar=filter.value;
339
+ }
318
340
  }
319
341
  if(filter.field === 'remote') {
320
342
  value = filter.value === 'true';
@@ -339,6 +361,11 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
339
361
  queryParams.remove(["location" ]);
340
362
  // queryLocationVar=undefined;
341
363
  }
364
+ if(filter.field === 'remote'){
365
+ console.log("removing jobType from url")
366
+ queryParams.remove(["jobType" ]);
367
+ // queryJobTypeVar=undefined;
368
+ }
342
369
  }
343
370
  }
344
371
  });
@@ -455,6 +482,20 @@ async function handleLocationParam(_$w,location) {
455
482
 
456
483
  }
457
484
 
485
+ async function handleJobTypeParam(_$w,jobType) {
486
+ const jobTypeValue = decodeURIComponent(jobType);
487
+ let dropdownOptions = _$w('#dropdownJobType').options;
488
+ console.log("jobType dropdown options:", dropdownOptions);
489
+ const option=_$w('#dropdownJobType').options.find(option => option.value.toLowerCase() === jobTypeValue.toLowerCase())
490
+ if(option){
491
+ _$w('#dropdownJobType').value = option.value;
492
+ }
493
+ else{
494
+ console.warn("jobType value not found in dropdown options");
495
+ queryParams.remove(["jobType"]);
496
+ }
497
+ }
498
+
458
499
  async function updateMapMarkers(_$w){
459
500
  const numOfItems = await _$w('#jobsDataset').getTotalCount();
460
501
  const items = await _$w('#jobsDataset').getItems(0, numOfItems);