sr-npm 1.7.140 → 1.7.142

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.140",
3
+ "version": "1.7.142",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -95,9 +95,8 @@ async function handleUrlParams(_$w) {
95
95
 
96
96
  async function handleKeyWordParam(_$w,keyWord) {
97
97
  _$w('#searchInput').value = keyWord;
98
- //const filter = await wixData.query("Jobs").contains("title", keyWord);
99
- await $w("#jobsDataset").setFilter(wixData.filter().contains("title", keyWord));
100
- await _$w("#jobsDataset").refresh();
98
+ // Use applyFilters to maintain consistency instead of directly setting filter
99
+ await applyFilters(_$w, true); // Skip URL update since we're handling initial URL params
101
100
  }
102
101
 
103
102
  async function handlePageParam(_$w) {
@@ -158,7 +157,7 @@ function init(_$w) {
158
157
  const debouncedSearch = debounce(()=>applyFilters(_$w), 400,thisObjectVar);
159
158
 
160
159
  _$w('#searchInput').onInput(debouncedSearch);
161
- // _$w('#dropdownDepartment, #dropdownLocation, #dropdownJobType').onChange(()=>applyFilters(_$w));
160
+ _$w('#dropdownDepartment, #dropdownLocation, #dropdownJobType').onChange(()=>applyFilters(_$w));
162
161
  _$w('#resetFiltersButton, #clearSearch').onClick(()=>resetFilters(_$w));
163
162
 
164
163
  _$w('#openFiltersButton').onClick(()=>{
@@ -170,7 +169,7 @@ function init(_$w) {
170
169
  });
171
170
  }
172
171
 
173
- async function applyFilters(_$w) {
172
+ async function applyFilters(_$w, skipUrlUpdate = false) {
174
173
  console.log("applyFilters");
175
174
  console.log("after applyFilters_$w('#dropdownDepartment').value", _$w('#dropdownDepartment').value);
176
175
  const dropdownFiltersMapping = [
@@ -190,17 +189,21 @@ async function applyFilters(_$w) {
190
189
  if (filter.value === RESET_ALL) {
191
190
  _$w(filter.elementId).value = '';
192
191
  filter.value = '';
193
- queryParams.remove(["keyWord", "department","page"]);
192
+ if (!skipUrlUpdate) {
193
+ queryParams.remove(["keyWord", "department","page"]);
194
+ }
194
195
  }
195
196
 
196
197
  // build filters
197
198
  if (filter.value && filter.value.trim() !== '') {
198
- if(filter.field === 'title'){
199
- queryParams.add({ keyWord: filter.value });
200
- }
201
- if(filter.field === 'department'){
202
- queryParams.add({ department: filter.value });
203
- }
199
+ if (!skipUrlUpdate) {
200
+ if(filter.field === 'title'){
201
+ queryParams.add({ keyWord: filter.value });
202
+ }
203
+ if(filter.field === 'department'){
204
+ queryParams.add({ department: filter.value });
205
+ }
206
+ }
204
207
  if(filter.field === 'remote') {
205
208
  value = filter.value === 'true';
206
209
  } else {
@@ -209,11 +212,13 @@ async function applyFilters(_$w) {
209
212
  filters.push({ field: filter.field, searchTerm: value });
210
213
  }
211
214
  else{
212
- if(filter.field === 'title'){
213
- queryParams.remove(["keyWord" ]);
214
- }
215
- if(filter.field === 'department'){
216
- queryParams.remove(["department" ]);
215
+ if (!skipUrlUpdate) {
216
+ if(filter.field === 'title'){
217
+ queryParams.remove(["keyWord" ]);
218
+ }
219
+ if(filter.field === 'department'){
220
+ queryParams.remove(["department" ]);
221
+ }
217
222
  }
218
223
  }
219
224
  });
@@ -255,11 +260,36 @@ async function updateCount(_$w) {
255
260
  }
256
261
 
257
262
  async function handleDepartmentParam(_$w,department) {
258
- console.log("department inside handleDepartmentParam", department.replace('-', ' '));
259
- _$w('#dropdownDepartment').value = department.replace('-', ' ');
263
+ const departmentValue = department.replace('-', ' ');
264
+ console.log("department inside handleDepartmentParam", departmentValue);
265
+
266
+ // Debug: Check dropdown options
267
+ const dropdownOptions = _$w('#dropdownDepartment').options;
268
+ console.log("dropdown options:", dropdownOptions);
269
+
270
+ // Try setting the value
271
+ _$w('#dropdownDepartment').value = departmentValue;
272
+ console.log("after setting, dropdown value:", _$w('#dropdownDepartment').value);
273
+
274
+ // If value didn't set, try finding exact match
275
+ if (!_$w('#dropdownDepartment').value) {
276
+ const matchingOption = dropdownOptions.find(option =>
277
+ option.label.toLowerCase() === departmentValue.toLowerCase() ||
278
+ option.value.toLowerCase() === departmentValue.toLowerCase()
279
+ );
280
+
281
+ if (matchingOption) {
282
+ console.log("found matching option:", matchingOption);
283
+ _$w('#dropdownDepartment').value = matchingOption.value;
284
+ console.log("after setting matching option, dropdown value:", _$w('#dropdownDepartment').value);
285
+ } else {
286
+ console.log("no matching option found for:", departmentValue);
287
+ }
288
+ }
289
+
260
290
  console.log("before applyFilters_$w('#dropdownDepartment').value", _$w('#dropdownDepartment').value);
261
291
 
262
- await applyFilters(_$w);
292
+ await applyFilters(_$w, true); // Skip URL update since we're handling initial URL params
263
293
  }
264
294
 
265
295