sr-npm 1.7.675 → 1.7.677

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.
@@ -13,6 +13,17 @@ const CAREERS_MULTI_BOXES_PAGE_CONSTS={
13
13
  DESELECT_BUTTON_ID: '#deselectFilterValueButton',
14
14
  }
15
15
 
16
+ const FiltersIds={
17
+ Category: 'Category',
18
+ "Company Segment": 'CompanySegment',
19
+ Location: 'Location',
20
+ "Store Name": 'StoreName',
21
+ "Employment Type": 'employmentType',
22
+ "Contract Type": 'contractType',
23
+ Brands: 'Brands',
24
+ }
25
+
16
26
  module.exports = {
17
27
  CAREERS_MULTI_BOXES_PAGE_CONSTS,
28
+ FiltersIds,
18
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.675",
3
+ "version": "1.7.677",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  const { COLLECTIONS,CUSTOM_VALUES_COLLECTION_FIELDS,JOBS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
2
2
  const { items: wixData } = require('@wix/data');
3
- const {CAREERS_MULTI_BOXES_PAGE_CONSTS} = require('../backend/careersMultiBoxesPageIds');
3
+ const {CAREERS_MULTI_BOXES_PAGE_CONSTS,FiltersIds} = require('../backend/careersMultiBoxesPageIds');
4
4
 
5
5
  let valuesByFieldIdGlobal = null;
6
6
  let dontUpdateThisCheckBox;
@@ -126,27 +126,26 @@ async function loadJobs(_$w) {
126
126
  let fields = await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
127
127
 
128
128
  fields.push({_id:"Location",title:"Location"});
129
- console.log("fields: ",fields)
130
129
  // _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).data = fields;
131
130
  const cities=await getAllRecords(COLLECTIONS.CITIES);
132
131
  for(const city of cities) {
133
132
  valueToJobs[city._id]=city.jobIds;
134
133
  }
135
134
  // 2) Load all values once and group them by referenced field
136
- let found=false;
137
135
  let valuesByFieldId = groupValuesByField(allvaluesobjects, CUSTOM_VALUES_COLLECTION_FIELDS.CUSTOM_FIELD);
138
136
  valuesByFieldId.set("Location",cities)
139
137
  valuesByFieldIdGlobal = valuesByFieldId; // store globally
140
- console.log("valuesByFieldId: @$##@$@##$ ",valuesByFieldId)
141
138
 
142
139
  // Build CheckboxGroup options for this field
143
140
 
144
141
  const counter={}
142
+ for(const city of cities) {
143
+ counter[city.city]=city.count
144
+ }
145
145
  for(const [key, value] of valuesByFieldId) {
146
- console.log("elemenet: ",key)
147
146
  for(const field of fields) {
148
- if(field._id===key && field.title==="Category") {
149
- let originalOptions=[];
147
+ if(field._id===key) {
148
+ let originalOptions=[];
150
149
  if(key==="Location") {
151
150
  originalOptions=value.map(city=>({
152
151
  label: city.city,
@@ -166,11 +165,8 @@ async function loadJobs(_$w) {
166
165
 
167
166
  countsByFieldId.set(key, new Map(originalOptions.map(o => [o.value, counter[o.label]])));
168
167
  updateOptionsUI(_$w,field.title, field._id, ''); // no search query
169
- console.log("field: ",field)
170
- console.log("elemenet: ",key)
171
- console.log("valuesByFieldId.get(elemenet): ",valuesByFieldId.get(key))
172
168
  //_$w("#CategoryCheckBox").options = valuesByFieldId.get(elemenet);
173
- _$w(`#${field.title}CheckBox`).onChange(async (ev) => {
169
+ _$w(`#${FiltersIds[field.title]}CheckBox`).onChange(async (ev) => {
174
170
  dontUpdateThisCheckBox=field._id;
175
171
  const selected = ev.target.value; // array of selected value IDs
176
172
  if (selected && selected.length) {
@@ -185,17 +181,14 @@ async function loadJobs(_$w) {
185
181
  });
186
182
 
187
183
  const runFilter = debounce(() => {
188
- const query = (_$w(`#${field.title}input`).value || '').toLowerCase().trim();
184
+ const query = (_$w(`#${FiltersIds[field.title]}input`).value || '').toLowerCase().trim();
189
185
  updateOptionsUI(_$w, field.title, field._id, query);
190
186
  }, 150);
191
- _$w(`#${field.title}input`).onInput(runFilter);
192
- found=true;
193
- break;
187
+ _$w(`#${FiltersIds[field.title]}input`).onInput(runFilter);
188
+
189
+
194
190
  }
195
191
  }
196
- if(found) {
197
- break;
198
- }
199
192
  }
200
193
 
201
194
  await refreshFacetCounts(_$w);
@@ -281,9 +274,7 @@ async function loadJobs(_$w) {
281
274
 
282
275
 
283
276
  // });
284
- for(const city of cities) {
285
- counter[city.city]=city.count
286
- }
277
+
287
278
  } catch (err) {
288
279
  console.error('Failed to load filters:', err);
289
280
  }
@@ -345,15 +336,15 @@ async function loadJobs(_$w) {
345
336
 
346
337
  // Preserve currently selected values that are still visible
347
338
  // const prevSelected = $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).value || [];
348
- const prevSelected = _$w(`#${fieldTitle}CheckBox`).value || [];
339
+ const prevSelected = _$w(`#${FiltersIds[fieldTitle]}CheckBox`).value || [];
349
340
  const visibleSet = new Set(filtered.map(o => o.value));
350
341
  const preserved = prevSelected.filter(v => visibleSet.has(v));
351
342
  console.log("preserved: ",preserved)
352
343
  console.log("filtered: ",filtered)
353
344
  console.log("fieldTitle: ",fieldTitle)
354
345
 
355
- _$w(`#${fieldTitle}CheckBox`).options = filtered;
356
- _$w(`#${fieldTitle}CheckBox`).value = preserved;
346
+ _$w(`#${FiltersIds[fieldTitle]}CheckBox`).options = filtered;
347
+ _$w(`#${FiltersIds[fieldTitle]}CheckBox`).value = preserved;
357
348
 
358
349
  }
359
350
 
@@ -363,7 +354,7 @@ async function loadJobs(_$w) {
363
354
  let addedJobsIds=[]
364
355
  // AND across categories, OR within each category
365
356
  for (const [key, values] of selectedByField.entries()) {
366
- for(job of finalFilteredJobs) {
357
+ for(const job of finalFilteredJobs) {
367
358
  if(key==="Location"){
368
359
  //if it is location then we check if selecred values (which is an array) have job city text
369
360
  if(values.includes(job[JOBS_COLLECTION_FIELDS.CITY_TEXT])) {