sr-npm 1.7.532 → 1.7.534

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.
@@ -0,0 +1,27 @@
1
+ name: Update Sites After Release Main
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: write
11
+ packages: write
12
+
13
+ jobs:
14
+ update-sites:
15
+ uses: psdevteamenterprise/ci-workflows/.github/workflows/publish-and-notify.yml@main
16
+ with:
17
+ sites_to_update: "[{repo: 'psdevteamenterprise/tests-site', secret: 'WIX_PS_API_KEY'},
18
+ {repo: 'psdevteamenterprise/external-template', secret: 'WIX_SR_API_KEY'},
19
+ {repo: 'psdevteamenterprise/internal', secret: 'WIX_SR_API_KEY'}]"
20
+
21
+ secrets:
22
+ GH_TOKEN: ${{ secrets.GH_TOKEN }}
23
+ NPM_TOKEN: ${{ secrets.PS_NPM_TOKEN }}
24
+ GH_APP_ID: ${{ secrets.GH_APP_ID }}
25
+ GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
26
+ WIX_PS_API_KEY: ${{ secrets.WIX_PS_API_KEY }}
27
+ WIX_SR_API_KEY: ${{ secrets.WIX_SR_API_KEY }}
@@ -23,13 +23,21 @@ const JOBS_COLLECTION_FIELDS = {
23
23
  REFER_FRIEND_LINK: 'referFriendLink',
24
24
  BRAND: 'brand',
25
25
  BRAND_REF: 'brandRef',
26
- CUSTOM_FIELDS:'customFields',
26
+ CUSTOM_VALUES: 'customValues',
27
+
27
28
  }
28
29
  const AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION_FIELDS = {
29
30
  TITLE: 'title',
30
31
  COUNT: 'count',
31
32
  IMAGE: 'image',
32
33
  }
34
+ const CUSTOM_VALUES_COLLECTION_FIELDS = {
35
+ TITLE: 'title',
36
+ CUSTOM_FIELD: 'customField',
37
+ }
38
+ const CUSTOM_FIELDS_COLLECTION_FIELDS = {
39
+ TITLE: 'title',
40
+ }
33
41
  const BRANDS_COLLECTION_FIELDS = {
34
42
  TITLE: 'title',
35
43
  COUNT: 'count',
@@ -63,6 +71,7 @@ const COLLECTIONS_FIELDS = {
63
71
  {key:'language', type: 'TEXT'},
64
72
  {key:'remote', type: 'BOOLEAN'},
65
73
  {key:'jobDescription', type: 'OBJECT'},
74
+ {key:'customValues', type: 'MULTI-REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.CUSTOM_VALUES } } },
66
75
  {key:'cityText', type: 'TEXT'},
67
76
  {key:'applyLink', type: 'URL'},
68
77
  {key:'referFriendLink', type: 'URL'},
@@ -70,7 +79,6 @@ const COLLECTIONS_FIELDS = {
70
79
  {key:'departmentref', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT } } },
71
80
  {key:'city', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.CITIES } } },
72
81
  {key:'brandRef', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.BRANDS } } },
73
- { key: 'customFields', type: 'ARRAY' },
74
82
  { key: 'image', type: 'IMAGE' },
75
83
  ],
76
84
  TEMPLATE_TYPE: [
@@ -84,6 +92,13 @@ const COLLECTIONS_FIELDS = {
84
92
  {key:'title', type: 'TEXT'},
85
93
  { key: 'count', type: 'NUMBER' },
86
94
  ],
95
+ CUSTOM_VALUES: [
96
+ {key:'title', type: 'TEXT'},
97
+ {key:'customField', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.CUSTOM_FIELDS } } },
98
+ ],
99
+ CUSTOM_FIELDS: [
100
+ {key:'title', type: 'TEXT'},
101
+ ],
87
102
  };
88
103
 
89
104
 
@@ -97,22 +112,6 @@ const COLLECTIONS_FIELDS = {
97
112
  SMART_TOKEN: 'x-smarttoken',
98
113
  DESIRED_BRAND: 'desiredBrand',
99
114
  }
100
-
101
- const URL_PARAMS = {
102
- DEPARTMENT: "Department",
103
- LOCATION: "Location",
104
- BRAND: "Brand",
105
- }
106
- const DROPDOWN_IDS = {
107
- DEPARTMENT: '#dropdownDepartment',
108
- LOCATION: '#dropdownLocation',
109
- BRAND: '#dropdownBrand',
110
- }
111
- const DROPDOWN_COLLECTIONS = {
112
- DEPARTMENT: 'AmountOfJobsPerDepartment',
113
- LOCATION: 'cities',
114
- BRAND: 'Brands',
115
- }
116
115
 
117
116
 
118
117
  module.exports = {
@@ -122,9 +121,9 @@ const COLLECTIONS_FIELDS = {
122
121
  AMOUNT_OF_JOBS_PER_DEPARTMENT_COLLECTION_FIELDS,
123
122
  CITIES_COLLECTION_FIELDS,
124
123
  BRANDS_COLLECTION_FIELDS,
124
+ CUSTOM_FIELDS_COLLECTION_FIELDS,
125
+ CUSTOM_VALUES_COLLECTION_FIELDS,
125
126
  TEMPLATE_TYPE,
126
127
  TOKEN_NAME,
127
- URL_PARAMS,
128
- DROPDOWN_IDS,
129
- DROPDOWN_COLLECTIONS,
128
+
130
129
  };
package/backend/data.js CHANGED
@@ -28,6 +28,7 @@ function validatePosition(position) {
28
28
 
29
29
  async function filterBasedOnBrand(positions) {
30
30
  try{
31
+
31
32
  const desiredBrand = await getTokenFromCMS(TOKEN_NAME.DESIRED_BRAND);
32
33
  validateSingleDesiredBrand(desiredBrand);
33
34
  console.log("filtering positions based on brand: ", desiredBrand);
@@ -51,23 +52,21 @@ function validateSingleDesiredBrand(desiredBrand) {
51
52
  throw new Error("Desired brand must be a single brand");
52
53
  }
53
54
  }
54
-
55
- function addCustomFields(basicJob, position) {
55
+ function getCustomFieldsAndValuesFromPosition(position,customFields) {
56
56
  const customFieldsArray = Array.isArray(position?.customField) ? position.customField : [];
57
- const customFields = {};
58
57
  for (const field of customFieldsArray) {
59
58
  if(field.fieldLabel==="Country" || field.fieldLabel==="Department") continue; //country and department are not custom fields, they are already in the job object
60
59
  const label = field.fieldLabel==="Brands" ? "brand" : field.fieldLabel
61
60
  const key = normalizeString(label);
62
61
  const value = field.valueLabel
63
- customFields[key] = value;
62
+ customFields[key] ? customFields[key].add(value) : customFields[key]=new Set([value])
64
63
  }
65
- return { ...basicJob, ...customFields,customFieldsNames:Object.keys(customFields) };
64
+
66
65
  }
67
-
68
66
  async function saveJobsDataToCMS() {
69
67
  const positions = await fetchPositionsFromSRAPI();
70
68
  const sourcePositions = await filterBasedOnBrand(positions);
69
+ const customFields = {}
71
70
  // bulk insert to jobs collection without descriptions first
72
71
  const jobsData = sourcePositions.map(position => {
73
72
  const basicJob = {
@@ -90,13 +89,13 @@ async function saveJobsDataToCMS() {
90
89
  country: position.location?.country || '',
91
90
  remote: position.location?.remote || false,
92
91
  language: position.language?.label || '',
93
- // brand: getBrand(position.customField),
92
+ brand: getBrand(position.customField),
94
93
  jobDescription: null, // Will be filled later
95
94
  };
96
-
97
- return addCustomFields(basicJob,position)
95
+ getCustomFieldsAndValuesFromPosition(position,customFields);
96
+ return basicJob;
98
97
  });
99
-
98
+ console.log("customFields: ", customFields);
100
99
  // Sort jobs by title (ascending, case-insensitive, numeric-aware)
101
100
  jobsData.sort((a, b) => {
102
101
  const titleA = a.title || '';
@@ -341,7 +340,9 @@ async function createCollections() {
341
340
  createCollectionIfMissing(COLLECTIONS.CITIES, COLLECTIONS_FIELDS.CITIES),
342
341
  createCollectionIfMissing(COLLECTIONS.AMOUNT_OF_JOBS_PER_DEPARTMENT, COLLECTIONS_FIELDS.AMOUNT_OF_JOBS_PER_DEPARTMENT),
343
342
  createCollectionIfMissing(COLLECTIONS.SECRET_MANAGER_MIRROR, COLLECTIONS_FIELDS.SECRET_MANAGER_MIRROR),
344
- createCollectionIfMissing(COLLECTIONS.BRANDS, COLLECTIONS_FIELDS.BRANDS)
343
+ createCollectionIfMissing(COLLECTIONS.BRANDS, COLLECTIONS_FIELDS.BRANDS),
344
+ createCollectionIfMissing(COLLECTIONS.CUSTOM_VALUES, CUSTOM_VALUES_COLLECTION_FIELDS.CUSTOM_VALUES),
345
+ createCollectionIfMissing(COLLECTIONS.CUSTOM_FIELDS, CUSTOM_FIELDS_COLLECTION_FIELDS.CUSTOM_FIELDS)
345
346
  ]);
346
347
  console.log("finished creating Collections");
347
348
  }
@@ -353,7 +354,6 @@ async function aggregateJobs() {
353
354
  aggregateJobsByFieldToCMS({ field: JOBS_COLLECTION_FIELDS.CITY_TEXT, collection: COLLECTIONS.CITIES }),
354
355
  aggregateJobsByFieldToCMS({ field: JOBS_COLLECTION_FIELDS.BRAND, collection: COLLECTIONS.BRANDS })
355
356
  ]);
356
-
357
357
  console.log("finished aggregating jobs");
358
358
  }
359
359
 
@@ -367,16 +367,16 @@ async function referenceJobs() {
367
367
 
368
368
  async function syncJobsFast() {
369
369
  console.log("Syncing jobs fast");
370
- // await createCollections();
370
+ await createCollections();
371
371
  // await clearCollections();
372
372
  // await fillSecretManagerMirror();
373
373
  console.log("saving jobs data to CMS");
374
374
  await saveJobsDataToCMS();
375
- console.log("saved jobs data to CMS successfully");
375
+ // console.log("saved jobs data to CMS successfully");
376
376
  // console.log("saving jobs descriptions and location apply url to CMS");
377
377
  // await saveJobsDescriptionsAndLocationApplyUrlToCMS();
378
378
  // console.log("saved jobs descriptions and location apply url to CMS successfully");
379
- // await aggregateJobs();
379
+ // await aggregateJobs();
380
380
  // await referenceJobs();
381
381
  // console.log("syncing jobs fast finished successfully");
382
382
  }
@@ -18,16 +18,7 @@ async function getPositionsByField(field, value) {
18
18
  .then(result => result.items);
19
19
  }
20
20
 
21
- async function getCustomFieldKeys() {
22
- return wixData
23
- .query(COLLECTIONS.JOBS)
24
- .eq("title", "bayan - custom field 3")
25
- .find()
26
- .then(result => result.items[0].customFieldsNames);
27
- }
28
-
29
21
  module.exports = {
30
22
  getAllPositions,
31
23
  getPositionsByField,
32
- getCustomFieldKeys
33
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.532",
3
+ "version": "1.7.534",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,9 +1,9 @@
1
- const { getAllPositions,getCustomFieldKeys } = require('../backend/queries');
1
+ const { getAllPositions } = require('../backend/queries');
2
2
  const {wixData} = require('wix-data');
3
3
  const { window } = require('@wix/site-window');
4
4
  const { query,queryParams,onChange} = require("wix-location-frontend");
5
5
  const { location } = require("@wix/site-location");
6
- const { COLLECTIONS, URL_PARAMS, DROPDOWN_IDS, DROPDOWN_COLLECTIONS } = require('../backend/collectionConsts');
6
+ const { COLLECTIONS } = require('../backend/collectionConsts');
7
7
 
8
8
  const {
9
9
  debounce,
@@ -22,43 +22,29 @@ const {
22
22
  let queryLocationVar;
23
23
  let queryJobTypeVar;
24
24
  let queryBrandVar;
25
- let queryCustomFields={};
26
25
  let searchInputBlurredFirstTime=true;
27
26
  let deletedParam=false;
28
- async function careersPageOnReady(_$w,thisObject,queryParams,customFieldsDropdownObject=null) {
27
+ async function careersPageOnReady(_$w,thisObject,queryParams) {
29
28
  console.log("queryParams: ", queryParams);
30
- console.log("customFieldsDropdownObject: ", customFieldsDropdownObject)
31
- await retrieveQueryParams(queryParams,customFieldsDropdownObject);
29
+ const { page, keyWord, department, location,jobType,brand } = queryParams;
30
+ queryPageVar=page;
31
+ queryKeyWordVar=keyWord;
32
+ queryDepartmentVar=department;
33
+ queryLocationVar=location;
34
+ queryJobTypeVar=jobType;
35
+ queryBrandVar=brand;
32
36
  thisObjectVar=thisObject;
33
37
  allJobs=await getAllPositions();
34
38
  await activateAutoLoad(_$w);
35
39
  await bind(_$w);
36
- await init(_$w,customFieldsDropdownObject);
40
+ await init(_$w);
37
41
  await handleBrandDropdown(_$w);
38
42
  await handleUrlParams(_$w);
39
43
 
40
44
 
41
45
  }
42
46
 
43
- async function retrieveQueryParams(queryParams,customFieldsDropdownObject=null){
44
- const { page, keyWord, department, location,jobType,brand } = queryParams;
45
- queryPageVar=page;
46
- queryKeyWordVar=keyWord;
47
- queryDepartmentVar=department;
48
- queryLocationVar=location;
49
- queryJobTypeVar=jobType;
50
- queryBrandVar=brand;
51
- if(customFieldsDropdownObject){
52
- const customFieldKeys=Object.keys(customFieldsDropdownObject);
53
- console.log("customFieldKeys: ", customFieldKeys)
54
- for(const customFieldKey of customFieldKeys)
55
- {
56
- queryCustomFields[customFieldKey]={elementId:customFieldsDropdownObject[customFieldKey], field:customFieldKey, queryParamValue:queryParams[customFieldKey],queryParamKey:customFieldKey}
57
- }
58
- console.log("queryCustomFields",queryCustomFields)
59
- }
60
- }
61
-
47
+
62
48
  function activateAutoLoad(_$w)
63
49
  {
64
50
  _$w("#jobsDataset").onReady(() => {
@@ -114,24 +100,16 @@ async function handleUrlParams(_$w) {
114
100
  await handlePageParam(_$w);
115
101
  }
116
102
  if (queryDepartmentVar) {
117
- await handleGivenURLParam(_$w,URL_PARAMS.DEPARTMENT,queryDepartmentVar);
118
- //await handleDepartmentParam(_$w,queryDepartmentVar);
103
+ await handleDepartmentParam(_$w,queryDepartmentVar);
119
104
  }
120
105
  if (queryLocationVar) {
121
- // await handleLocationParam(_$w,queryLocationVar);
122
- await handleGivenURLParam(_$w,URL_PARAMS.LOCATION,queryLocationVar);
106
+ await handleLocationParam(_$w,queryLocationVar);
123
107
  }
124
108
  if (queryJobTypeVar) {
125
109
  await handleJobTypeParam(_$w,queryJobTypeVar);
126
110
  }
127
111
  if (queryBrandVar && _$w('#dropdownBrand').isVisible) { //if it is not visible, ignore it
128
- //await handleBrandParam(_$w,queryBrandVar);
129
- await handleGivenURLParam(_$w,URL_PARAMS.BRAND,queryBrandVar);
130
- }
131
- if (queryCustomFields) {
132
- for(const customFieldKey of Object.keys(queryCustomFields)){
133
- await handleGivenURLParam(_$w,customFieldKey,queryCustomFields[customFieldKey].queryParamValue);
134
- }
112
+ await handleBrandParam(_$w,queryBrandVar);
135
113
  }
136
114
  await applyFilters(_$w, true); // Skip URL update since we're handling initial URL params
137
115
  }
@@ -191,7 +169,7 @@ async function bind(_$w) {
191
169
 
192
170
  }
193
171
 
194
- function init(_$w,customFieldsDropdownObject=null) {
172
+ function init(_$w) {
195
173
  const debouncedSearch = debounce(()=>applyFilters(_$w), 400,thisObjectVar);
196
174
  _$w('#searchInput').onInput(debouncedSearch);
197
175
  _$w('#searchInput').onBlur(()=>{
@@ -205,14 +183,6 @@ function init(_$w,customFieldsDropdownObject=null) {
205
183
  console.log("dropdown onChange is triggered");
206
184
  applyFilters(_$w);
207
185
  });
208
- if (customFieldsDropdownObject){
209
- for(const customFieldKey of Object.keys(customFieldsDropdownObject)){
210
- _$w(customFieldsDropdownObject[customFieldKey]).onChange(()=>{
211
- console.log("custom field onChange is triggered");
212
- applyFilters(_$w);
213
- });
214
- }
215
- }
216
186
  _$w('#resetFiltersButton, #clearSearch').onClick(()=>resetFilters(_$w));
217
187
 
218
188
  _$w('#openFiltersButton').onClick(()=>{
@@ -279,27 +249,17 @@ async function handleBackAndForth(_$w){
279
249
 
280
250
  }
281
251
 
282
- async function applyCustomFieldFilters(filters) {
283
- for(const customFieldKey of Object.keys(queryCustomFields)){
284
- filters.push({ field: customFieldKey, searchTerm: queryCustomFields[customFieldKey] });
285
- }
286
- }
287
-
288
252
  async function applyFilters(_$w, skipUrlUpdate = false) {
289
253
  console.log("applying filters");
290
254
  const dropdownFiltersMapping = [
291
- { elementId: '#dropdownDepartment', field: 'department', value: _$w('#dropdownDepartment').value,queryParamKey:"department" },
292
- { elementId: '#dropdownLocation', field: 'cityText', value: _$w('#dropdownLocation').value,queryParamKey:"location" },
293
- { elementId: '#dropdownJobType', field: 'remote', value: _$w('#dropdownJobType').value,queryParamKey:"jobType" },
294
- { elementId: '#dropdownBrand', field: 'brand', value: _$w('#dropdownBrand').value,queryParamKey:"brand" },
295
- { elementId: '#searchInput', field: 'title', value: _$w('#searchInput').value,queryParamKey:"keyWord" }
255
+ { elementId: '#dropdownDepartment', field: 'department', value: _$w('#dropdownDepartment').value },
256
+ { elementId: '#dropdownLocation', field: 'cityText', value: _$w('#dropdownLocation').value },
257
+ { elementId: '#dropdownJobType', field: 'remote', value: _$w('#dropdownJobType').value},
258
+ { elementId: '#dropdownBrand', field: 'brand', value: _$w('#dropdownBrand').value},
259
+ { elementId: '#searchInput', field: 'title', value: _$w('#searchInput').value }
296
260
  ];
297
- //adding custom field filters to the dropdownFiltersMapping
298
- for(const customFieldKey of Object.keys(queryCustomFields)){
299
- dropdownFiltersMapping.push({ elementId: queryCustomFields[customFieldKey].elementId, field: queryCustomFields[customFieldKey].field, value: _$w(queryCustomFields[customFieldKey].elementId).value,queryParamKey:queryCustomFields[customFieldKey].queryParamKey });
300
- }
301
261
  console.log("dropdownFiltersMapping: ", dropdownFiltersMapping);
302
-
262
+
303
263
 
304
264
 
305
265
  let filters = [];
@@ -318,29 +278,23 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
318
278
  if(filter.field === 'title'){
319
279
  queryParams.add({ keyWord: filter.value });
320
280
  }
321
- else{
322
- if(filter.field === 'remote'){
323
- if(filter.value === 'true'){
324
- queryParams.add({ jobType: encodeURIComponent("remote") });
325
- }
326
- else{
327
- queryParams.add({ jobType: encodeURIComponent("onsite") });
328
- }
281
+ if(filter.field === 'department'){
282
+ queryParams.add({ department: encodeURIComponent(filter.value) });
283
+ }
284
+ if(filter.field === 'cityText'){
285
+ queryParams.add({ location: encodeURIComponent(filter.value) });
286
+ }
287
+ if(filter.field === 'remote'){
288
+ if(filter.value === 'true'){
289
+ queryParams.add({ jobType: encodeURIComponent("remote") });
329
290
  }
330
291
  else{
331
- queryParams.add({ [filter.queryParamKey] : encodeURIComponent(filter.value) });
292
+ queryParams.add({ jobType: encodeURIComponent("onsite") });
332
293
  }
333
294
  }
334
- // if(filter.field === 'department'){
335
- // queryParams.add({ department: encodeURIComponent(filter.value) });
336
- // }
337
- // if(filter.field === 'cityText'){
338
- // queryParams.add({ location: encodeURIComponent(filter.value) });
339
- // }
340
-
341
- // if(filter.field === 'brand'){
342
- // queryParams.add({ brand: encodeURIComponent(filter.value) });
343
- // }
295
+ if(filter.field === 'brand'){
296
+ queryParams.add({ brand: encodeURIComponent(filter.value) });
297
+ }
344
298
  }
345
299
  if(filter.field === 'remote') {
346
300
  value = filter.value === 'true';
@@ -351,32 +305,28 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
351
305
  }
352
306
  else{
353
307
  if (!skipUrlUpdate) {
354
- queryParams.remove([filter.queryParamKey]);
355
- // if(filter.field === 'title'){
356
- // queryParams.remove(["keyWord" ]);
357
- // }
358
- // if(filter.field === 'department'){
359
- // console.log("removing department from url")
360
- // queryParams.remove(["department" ]);
361
- // }
362
- // if(filter.field === 'cityText'){
363
- // console.log("removing location from url")
364
- // queryParams.remove(["location" ]);
365
- // }
366
- // if(filter.field === 'remote'){
367
- // console.log("removing jobType from url")
368
- // queryParams.remove(["jobType" ]);
369
- // }
370
- // if(filter.field === 'brand'){
371
- // console.log("removing brand from url")
372
- // queryParams.remove(["brand" ]);
373
- // }
308
+ if(filter.field === 'title'){
309
+ queryParams.remove(["keyWord" ]);
310
+ }
311
+ if(filter.field === 'department'){
312
+ console.log("removing department from url")
313
+ queryParams.remove(["department" ]);
314
+ }
315
+ if(filter.field === 'cityText'){
316
+ console.log("removing location from url")
317
+ queryParams.remove(["location" ]);
318
+ }
319
+ if(filter.field === 'remote'){
320
+ console.log("removing jobType from url")
321
+ queryParams.remove(["jobType" ]);
322
+ }
323
+ if(filter.field === 'brand'){
324
+ console.log("removing brand from url")
325
+ queryParams.remove(["brand" ]);
326
+ }
374
327
  }
375
328
  }
376
329
  });
377
-
378
- //applyCustomFieldFilters(filters);
379
- console.log("dropdownFiltersMapping after applying filters: ", dropdownFiltersMapping);
380
330
 
381
331
  const filter = await getFilter(filters, 'and');
382
332
  await _$w('#jobsDataset').setFilter(filter);
@@ -398,9 +348,6 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
398
348
 
399
349
  async function resetFilters(_$w) {
400
350
  _$w('#searchInput, #dropdownDepartment, #dropdownLocation, #dropdownJobType, #dropdownBrand').value = '';
401
- for(const customFieldKey of Object.keys(queryCustomFields)){
402
- _$w(queryCustomFields[customFieldKey].elementId).value = '';
403
- }
404
351
 
405
352
  await _$w('#jobsDataset').setFilter(wixData.filter());
406
353
  await _$w('#jobsDataset').refresh();
@@ -410,9 +357,7 @@ async function resetFilters(_$w) {
410
357
  _$w('#resetFiltersButton').disable();
411
358
 
412
359
  queryParams.remove(["keyWord", "department","page","location","jobType","brand"]);
413
- for(const customFieldKey of Object.keys(queryCustomFields)){
414
- queryParams.remove([queryCustomFields[customFieldKey].queryParamKey]);
415
- }
360
+
416
361
 
417
362
  await updateCount(_$w);
418
363
  console.log("reseting map markers");
@@ -427,33 +372,16 @@ async function updateCount(_$w) {
427
372
  return count;
428
373
  }
429
374
 
430
- async function handleGivenURLParam(_$w,param,value,isCustomField=false) {
431
- const paramValue = decodeURIComponent(value);
432
- let dropdownOptions = _$w(DROPDOWN_IDS[param]).options;
433
- console.log("dropdown options:", dropdownOptions);
434
- let optionsFromCMS;
435
- if(!isCustomField){
436
- optionsFromCMS=await wixData.query(DROPDOWN_COLLECTIONS[param]).find();
437
- if(dropdownOptions.length!==optionsFromCMS.items.length+1){
438
- fixDropdownOptions(DROPDOWN_IDS[param],optionsFromCMS, _$w);
439
- }
440
- }
441
- const option=_$w(DROPDOWN_IDS[param]).options.find(option => option.value.toLowerCase() === paramValue.toLowerCase())
442
- if(option){
443
- _$w(DROPDOWN_IDS[param]).value = option.value;
444
- }
445
- else{
446
- console.warn("param value not found in dropdown options");
447
- queryParams.remove([param]);
448
- }
449
- }
450
-
451
375
  async function handleDepartmentParam(_$w,department) {
452
376
  const departmentValue = decodeURIComponent(department);
377
+
378
+
379
+
453
380
  let dropdownOptions = _$w('#dropdownDepartment').options;
454
381
  console.log("dropdown options:", dropdownOptions);
455
382
  const optionsFromCMS=await wixData.query("AmountOfJobsPerDepartment").find();
456
383
  //+1 because of the "All" option
384
+
457
385
  if(dropdownOptions.length!==optionsFromCMS.items.length+1){
458
386
  fixDropdownOptions('#dropdownDepartment',optionsFromCMS, _$w);
459
387
  }