sr-npm 1.7.533 → 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.533",
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,26 +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
- if(queryCustomFields[customFieldKey].queryParamValue){
134
- await handleGivenURLParam(_$w,customFieldKey,queryCustomFields[customFieldKey].queryParamValue,true);
135
- }
136
- }
112
+ await handleBrandParam(_$w,queryBrandVar);
137
113
  }
138
114
  await applyFilters(_$w, true); // Skip URL update since we're handling initial URL params
139
115
  }
@@ -193,7 +169,7 @@ async function bind(_$w) {
193
169
 
194
170
  }
195
171
 
196
- function init(_$w,customFieldsDropdownObject=null) {
172
+ function init(_$w) {
197
173
  const debouncedSearch = debounce(()=>applyFilters(_$w), 400,thisObjectVar);
198
174
  _$w('#searchInput').onInput(debouncedSearch);
199
175
  _$w('#searchInput').onBlur(()=>{
@@ -207,14 +183,6 @@ function init(_$w,customFieldsDropdownObject=null) {
207
183
  console.log("dropdown onChange is triggered");
208
184
  applyFilters(_$w);
209
185
  });
210
- if (customFieldsDropdownObject){
211
- for(const customFieldKey of Object.keys(customFieldsDropdownObject)){
212
- _$w(customFieldsDropdownObject[customFieldKey]).onChange(()=>{
213
- console.log("custom field onChange is triggered");
214
- applyFilters(_$w);
215
- });
216
- }
217
- }
218
186
  _$w('#resetFiltersButton, #clearSearch').onClick(()=>resetFilters(_$w));
219
187
 
220
188
  _$w('#openFiltersButton').onClick(()=>{
@@ -281,27 +249,17 @@ async function handleBackAndForth(_$w){
281
249
 
282
250
  }
283
251
 
284
- async function applyCustomFieldFilters(filters) {
285
- for(const customFieldKey of Object.keys(queryCustomFields)){
286
- filters.push({ field: customFieldKey, searchTerm: queryCustomFields[customFieldKey] });
287
- }
288
- }
289
-
290
252
  async function applyFilters(_$w, skipUrlUpdate = false) {
291
253
  console.log("applying filters");
292
254
  const dropdownFiltersMapping = [
293
- { elementId: '#dropdownDepartment', field: 'department', value: _$w('#dropdownDepartment').value,queryParamKey:"department" },
294
- { elementId: '#dropdownLocation', field: 'cityText', value: _$w('#dropdownLocation').value,queryParamKey:"location" },
295
- { elementId: '#dropdownJobType', field: 'remote', value: _$w('#dropdownJobType').value,queryParamKey:"jobType" },
296
- { elementId: '#dropdownBrand', field: 'brand', value: _$w('#dropdownBrand').value,queryParamKey:"brand" },
297
- { 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 }
298
260
  ];
299
- //adding custom field filters to the dropdownFiltersMapping
300
- for(const customFieldKey of Object.keys(queryCustomFields)){
301
- dropdownFiltersMapping.push({ elementId: queryCustomFields[customFieldKey].elementId, field: queryCustomFields[customFieldKey].field, value: _$w(queryCustomFields[customFieldKey].elementId).value,queryParamKey:queryCustomFields[customFieldKey].queryParamKey });
302
- }
303
261
  console.log("dropdownFiltersMapping: ", dropdownFiltersMapping);
304
-
262
+
305
263
 
306
264
 
307
265
  let filters = [];
@@ -320,29 +278,23 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
320
278
  if(filter.field === 'title'){
321
279
  queryParams.add({ keyWord: filter.value });
322
280
  }
323
- else{
324
- if(filter.field === 'remote'){
325
- if(filter.value === 'true'){
326
- queryParams.add({ jobType: encodeURIComponent("remote") });
327
- }
328
- else{
329
- queryParams.add({ jobType: encodeURIComponent("onsite") });
330
- }
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") });
331
290
  }
332
291
  else{
333
- queryParams.add({ [filter.queryParamKey] : encodeURIComponent(filter.value) });
292
+ queryParams.add({ jobType: encodeURIComponent("onsite") });
334
293
  }
335
294
  }
336
- // if(filter.field === 'department'){
337
- // queryParams.add({ department: encodeURIComponent(filter.value) });
338
- // }
339
- // if(filter.field === 'cityText'){
340
- // queryParams.add({ location: encodeURIComponent(filter.value) });
341
- // }
342
-
343
- // if(filter.field === 'brand'){
344
- // queryParams.add({ brand: encodeURIComponent(filter.value) });
345
- // }
295
+ if(filter.field === 'brand'){
296
+ queryParams.add({ brand: encodeURIComponent(filter.value) });
297
+ }
346
298
  }
347
299
  if(filter.field === 'remote') {
348
300
  value = filter.value === 'true';
@@ -353,32 +305,28 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
353
305
  }
354
306
  else{
355
307
  if (!skipUrlUpdate) {
356
- queryParams.remove([filter.queryParamKey]);
357
- // if(filter.field === 'title'){
358
- // queryParams.remove(["keyWord" ]);
359
- // }
360
- // if(filter.field === 'department'){
361
- // console.log("removing department from url")
362
- // queryParams.remove(["department" ]);
363
- // }
364
- // if(filter.field === 'cityText'){
365
- // console.log("removing location from url")
366
- // queryParams.remove(["location" ]);
367
- // }
368
- // if(filter.field === 'remote'){
369
- // console.log("removing jobType from url")
370
- // queryParams.remove(["jobType" ]);
371
- // }
372
- // if(filter.field === 'brand'){
373
- // console.log("removing brand from url")
374
- // queryParams.remove(["brand" ]);
375
- // }
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
+ }
376
327
  }
377
328
  }
378
329
  });
379
-
380
- //applyCustomFieldFilters(filters);
381
- console.log("dropdownFiltersMapping after applying filters: ", dropdownFiltersMapping);
382
330
 
383
331
  const filter = await getFilter(filters, 'and');
384
332
  await _$w('#jobsDataset').setFilter(filter);
@@ -400,9 +348,6 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
400
348
 
401
349
  async function resetFilters(_$w) {
402
350
  _$w('#searchInput, #dropdownDepartment, #dropdownLocation, #dropdownJobType, #dropdownBrand').value = '';
403
- for(const customFieldKey of Object.keys(queryCustomFields)){
404
- _$w(queryCustomFields[customFieldKey].elementId).value = '';
405
- }
406
351
 
407
352
  await _$w('#jobsDataset').setFilter(wixData.filter());
408
353
  await _$w('#jobsDataset').refresh();
@@ -412,9 +357,7 @@ async function resetFilters(_$w) {
412
357
  _$w('#resetFiltersButton').disable();
413
358
 
414
359
  queryParams.remove(["keyWord", "department","page","location","jobType","brand"]);
415
- for(const customFieldKey of Object.keys(queryCustomFields)){
416
- queryParams.remove([queryCustomFields[customFieldKey].queryParamKey]);
417
- }
360
+
418
361
 
419
362
  await updateCount(_$w);
420
363
  console.log("reseting map markers");
@@ -429,33 +372,16 @@ async function updateCount(_$w) {
429
372
  return count;
430
373
  }
431
374
 
432
- async function handleGivenURLParam(_$w,param,value,isCustomField=false) {
433
- const paramValue = decodeURIComponent(value);
434
- let dropdownOptions = _$w(DROPDOWN_IDS[param]).options;
435
- console.log("dropdown options:", dropdownOptions);
436
- let optionsFromCMS;
437
- if(!isCustomField){
438
- optionsFromCMS=await wixData.query(DROPDOWN_COLLECTIONS[param]).find();
439
- if(dropdownOptions.length!==optionsFromCMS.items.length+1){
440
- fixDropdownOptions(DROPDOWN_IDS[param],optionsFromCMS, _$w);
441
- }
442
- }
443
- const option=_$w(DROPDOWN_IDS[param]).options.find(option => option.value.toLowerCase() === paramValue.toLowerCase())
444
- if(option){
445
- _$w(DROPDOWN_IDS[param]).value = option.value;
446
- }
447
- else{
448
- console.warn("param value not found in dropdown options");
449
- queryParams.remove([param]);
450
- }
451
- }
452
-
453
375
  async function handleDepartmentParam(_$w,department) {
454
376
  const departmentValue = decodeURIComponent(department);
377
+
378
+
379
+
455
380
  let dropdownOptions = _$w('#dropdownDepartment').options;
456
381
  console.log("dropdown options:", dropdownOptions);
457
382
  const optionsFromCMS=await wixData.query("AmountOfJobsPerDepartment").find();
458
383
  //+1 because of the "All" option
384
+
459
385
  if(dropdownOptions.length!==optionsFromCMS.items.length+1){
460
386
  fixDropdownOptions('#dropdownDepartment',optionsFromCMS, _$w);
461
387
  }