sr-npm 1.2.24 → 1.2.26

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.2.24",
3
+ "version": "1.2.26",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -176,17 +176,15 @@ async function handleParams(_$w,param,values) {
176
176
  for(const value of valuesAsArray) {
177
177
 
178
178
  const decodedValue = decodeURIComponent(value);
179
-
180
- const options=optionsByFieldId.get(field._id);
181
-
182
- const option=getCorrectOption(decodedValue,options,param);
179
+ const options = optionsByFieldId.get(field._id);
180
+ const option = getCorrectOption(decodedValue, options, param);
183
181
 
184
182
  if(option) {
185
- const optionIndex=getOptionIndexFromCheckBox(_$w(`#${FiltersIds[field.title]}CheckBox`).options,option.value);
186
- selectedIndices.push(optionIndex);
187
- existing.push(option.value);
188
- applyFiltering=true;
189
- dontUpdateThisCheckBox=field._id;
183
+ const optionIndex = getOptionIndexFromCheckBox(_$w(`#${FiltersIds[field.title]}CheckBox`).options,option.value);
184
+ selectedIndices.push(optionIndex);
185
+ existing.push(option.value);
186
+ applyFiltering = true;
187
+ dontUpdateThisCheckBox = field._id;
190
188
  }
191
189
  else {
192
190
  console.warn(`${param} value not found in dropdown options`);
@@ -308,9 +306,9 @@ async function loadJobsRepeater(_$w) {
308
306
  async function loadFilters(_$w) {
309
307
  try {
310
308
  // 1) Load all categories (fields)
311
- const cities=await getAllRecords(COLLECTIONS.CITIES);
309
+ const cities = await getAllRecords(COLLECTIONS.CITIES);
312
310
  for(const city of cities) {
313
- valueToJobs[city._id]=city.jobIds;
311
+ valueToJobs[city._id] = city.jobIds;
314
312
  }
315
313
  // 2) Load all values once and group them by referenced field
316
314
  let valuesByFieldId = groupValuesByField(allvaluesobjects, CUSTOM_VALUES_COLLECTION_FIELDS.CUSTOM_FIELD);
@@ -321,50 +319,54 @@ async function loadJobsRepeater(_$w) {
321
319
  for(const city of cities) {
322
320
  counter[city.city]=city.count
323
321
  }
322
+
324
323
  for(const [key, value] of valuesByFieldId) {
325
324
  const field = getFieldById(key,allfields);
326
325
  let originalOptions=[];
327
326
  if(key === "Location") {
328
327
  originalOptions = value.map(city=>({
329
328
  label: city.city,
330
- value: city.valueId
329
+ value: city._id
331
330
  }));
332
331
  }
333
332
  else{
334
333
  originalOptions = value
335
334
  }
335
+
336
336
  optionsByFieldId.set(key, originalOptions);
337
+
337
338
  for (const val of allvaluesobjects) {
338
339
  counter[val.title]=val.count
339
340
  }
340
341
  countsByFieldId.set(key, new Map(originalOptions.map(o => [o.value, counter[o.label]])));
341
- updateOptionsUI(_$w,field.title, field._id, ''); // no search query
342
+ updateOptionsUI(_$w, field.title, field._id, ''); // no search query
343
+
342
344
  _$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = []; // start empty
343
345
  _$w(`#${FiltersIds[field.title]}CheckBox`).onChange(async (ev) => {
344
- dontUpdateThisCheckBox=field._id;
345
- const selected = ev.target.value; // array of selected value IDs
346
- let fieldTitle=field.title.toLowerCase().replace(' ', '');
347
- fieldTitle==="brands"? fieldTitle="brand":fieldTitle;
348
-
349
- if (selected && selected.length) {
350
- selectedByField.set(field._id, selected);
351
- if(fieldTitle==="brand" || fieldTitle==="storename") {
352
- //in this case we need the label not valueid
353
- const valueLabels = getValueFromValueId(selected, value);
354
- queryParams.add({ [fieldTitle] : valueLabels.map(val=>encodeURIComponent(val)).join(',') });
355
- }
356
- else{
357
- queryParams.add({ [fieldTitle] : selected.map(val=>encodeURIComponent(val)).join(',') });
358
- }
346
+ dontUpdateThisCheckBox = field._id;
347
+ const selected = ev.target.value; // array of selected value IDs
348
+ let fieldTitle=field.title.toLowerCase().replace(' ', '');
349
+ fieldTitle === "brands"? fieldTitle = "brand" : fieldTitle;
350
+
351
+ if (selected && selected.length) {
352
+ selectedByField.set(field._id, selected);
353
+ if(fieldTitle==="brand" || fieldTitle==="storename") {
354
+ //in this case we need the label not valueid
355
+ const valueLabels = getValueFromValueId(selected, value);
356
+ queryParams.add({ [fieldTitle] : valueLabels.map(val=>encodeURIComponent(val)).join(',') });
357
+ }
358
+ else{
359
+ queryParams.add({ [fieldTitle] : selected.map(val=>encodeURIComponent(val)).join(',') });
360
+ }
359
361
 
360
- } else {
361
- selectedByField.delete(field._id);
362
- queryParams.remove([fieldTitle ]);
363
- }
362
+ } else {
363
+ selectedByField.delete(field._id);
364
+ queryParams.remove([fieldTitle ]);
365
+ }
364
366
 
365
367
  await updateJobsAndNumbersAndFilters(_$w);
366
368
  });
367
-
369
+
368
370
  const runFilter = debounce(() => {
369
371
  const query = (_$w(`#${FiltersIds[field.title]}input`).value || '').toLowerCase().trim();
370
372
  updateOptionsUI(_$w, field.title, field._id, query);
@@ -543,7 +545,7 @@ async function refreshFacetCounts(_$w,clearAll=false) {
543
545
  const currentJobsIds=jobs.map(job=>job._id);
544
546
 
545
547
  for (const fieldId of fieldIds) {
546
- let currentoptions=optionsByFieldId.get(fieldId)
548
+ let currentoptions = optionsByFieldId.get(fieldId)
547
549
  let counter=new Map();
548
550
  for(const option of currentoptions) {
549
551
  for (const jobId of currentJobsIds) {
@@ -11,7 +11,7 @@ function groupValuesByField(values, refKey) {
11
11
  if (!map.has(ref)) map.set(ref, []);
12
12
  map.get(ref).push({
13
13
  label: v.title ,
14
- value: v._id
14
+ value: v.valueId
15
15
  });
16
16
  }
17
17
  return map;
@@ -184,9 +184,10 @@ function loadPrimarySearchRepeater(_$w) {
184
184
 
185
185
  async function loadCategoriesListPrimarySearch(_$w, allvaluesobjects) {
186
186
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("categoryResults");
187
+
187
188
  let categoryValues=[]
188
189
  for(const value of allvaluesobjects) {
189
- if(value.customField===CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
190
+ if(value.customField === CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
190
191
  categoryValues.push({title: value.title+` (${value.count})` , _id: value.valueId});
191
192
  }
192
193
  }