sr-npm 1.7.650 → 1.7.651

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.650",
3
+ "version": "1.7.651",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -10,12 +10,10 @@ const countsByFieldId = new Map(); // fieldId -> {valueId: count} map of counts
10
10
  let alljobs=[] // all jobs in the database
11
11
  let allvaluesobjects=[] // all values in the database
12
12
  let valueToJobs={} // valueId -> array of jobIds
13
- //let currentJobsIds=[] // current jobs that are displayed in the jobs repeater
14
13
  let currentJobs=[] // current jobs that are displayed in the jobs repeater
15
14
  async function careersMultiBoxesPageOnReady(_$w) {
16
15
  if(alljobs.length===0) {
17
16
  alljobs=await getAllRecords(COLLECTIONS.JOBS);
18
- // currentJobsIds=alljobs.map(job=>job._id);
19
17
  currentJobs=alljobs;
20
18
  console.log("alljobs: ",alljobs)
21
19
  }
@@ -58,7 +56,7 @@ async function careersMultiBoxesPageOnReady(_$w) {
58
56
  }
59
57
  });
60
58
 
61
- await applyJobFilters(_$w,JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES);
59
+ await applyJobFilters(_$w,fieldId);
62
60
  await refreshFacetCounts(_$w);
63
61
  await updateSelectedValuesRepeater(_$w);
64
62
  updateTotalJobsCountText(_$w);
@@ -107,12 +105,12 @@ async function loadJobs(_$w) {
107
105
  // Set the filter label (category name)
108
106
  $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).placeholder = itemData.title
109
107
 
110
- // if(fieldId==="Location") {
111
- // $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).options = cities.map(city=>({
112
- // label: city.title,
113
- // value: city._id
114
- // }));
115
- // }
108
+ if(fieldId==="Location") {
109
+ $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).options = cities.map(city=>({
110
+ label: city.city,
111
+ value: city._id
112
+ }));
113
+ }
116
114
 
117
115
  // Build CheckboxGroup options for this field
118
116
  const fieldValues = valuesByFieldId.get(fieldId) || [];
@@ -141,7 +139,7 @@ async function loadJobs(_$w) {
141
139
  } else {
142
140
  selectedByField.delete(fieldId);
143
141
  }
144
- await applyJobFilters(_$w,JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES); // re-query jobs
142
+ await applyJobFilters(_$w,fieldId); // re-query jobs
145
143
  await refreshFacetCounts(_$w); // recompute and update counts in all lists
146
144
  await updateSelectedValuesRepeater(_$w);
147
145
  updateTotalJobsCountText(_$w);
@@ -232,49 +230,31 @@ async function loadJobs(_$w) {
232
230
  }
233
231
 
234
232
  async function applyJobFilters(_$w,filterByField) {
235
- //let q = wixData.query(COLLECTIONS.JOBS)
236
- console.log(alljobs)
237
- let newFilteredJobs=[];
238
- let currentAllJobs=alljobs;
233
+ let tempFilteredJobs=[];
234
+ let finalFilteredJobs=alljobs;
239
235
  let addedJobsIds=[]
240
- console.log("selectedByField: ",selectedByField)
236
+ if(filterByField!="Location") {
237
+ filterByField=JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES;
238
+ }
241
239
 
242
240
  // AND across categories, OR within each category
243
241
  for (const [, values] of selectedByField.entries()) {
244
- // console.log("values: ",values)
245
- for(job of currentAllJobs) {
246
- //console.log("job: ",job)
247
- console.log("job[filterByField]: ",job[filterByField])
248
- // console.log("job[filterByField].some(value=>values.includes(value))) ",job[filterByField].some(value=>values.includes(value._id)))
242
+ for(job of finalFilteredJobs) {
249
243
  if(job[filterByField].some(value=>values.includes(value._id))) {
250
- // console.log("!alreadyAddedJobs.includes(job._id) ",!alreadyAddedJobs.includes(job._id))
251
244
  if(!addedJobsIds.includes(job._id)) {
252
- newFilteredJobs.push(job);
245
+ tempFilteredJobs.push(job);
253
246
  addedJobsIds.push(job._id);
254
247
  }
255
248
  }
256
249
  }
257
250
  addedJobsIds=[]
258
- currentAllJobs=newFilteredJobs;
259
- newFilteredJobs=[];
260
- // if (values && values.length) {
261
-
262
- // q = q.hasSome(filterByField, values);
263
-
264
- // }
251
+ finalFilteredJobs=tempFilteredJobs;
252
+ tempFilteredJobs=[];
265
253
  }
266
- //console.log("alreadyAddedJobs: ",alreadyAddedJobs)
267
- console.log("newFilteredJobs: ",currentAllJobs)
268
- console.log("newFilteredJobs length: ",currentAllJobs.length)
269
- currentJobs=currentAllJobs;
270
- // currentJobsIds=addedJobsIds;
271
- _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = currentAllJobs;
254
+
255
+ currentJobs=finalFilteredJobs;
256
+ _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = currentJobs;
272
257
 
273
- // await q.find()
274
- // .then(async (res) => { _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = res.items;
275
- // await updateCurrentJobs(res);
276
- // })
277
- // .catch((err) => { console.error('Failed to filter jobs:', err); });
278
258
  }
279
259
 
280
260
 
@@ -324,16 +304,6 @@ async function refreshFacetCounts(_$w) {
324
304
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).data = selectedItems;
325
305
  }
326
306
 
327
- async function updateCurrentJobs(res) {
328
- let newcurrentJobs = [];
329
- newcurrentJobs.push(...res.items.map(job=>job._id));
330
- while (res.hasNext()) {
331
- res = await res.next();
332
- newcurrentJobs.push(...res.items.map(job=>job._id));
333
- }
334
- currentJobs = newcurrentJobs;
335
- }
336
-
337
307
  module.exports = {
338
308
  careersMultiBoxesPageOnReady
339
309
  };