sr-npm 1.7.640 → 1.7.642

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.640",
3
+ "version": "1.7.642",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,16 +9,19 @@ const optionsByFieldId = new Map(); // fieldId -> [{label, value}] array of obje
9
9
  const countsByFieldId = new Map(); // fieldId -> {valueId: count} map of counts for each valueId
10
10
  let alljobs=[] // all jobs in the database
11
11
  let allvaluesobjects=[] // all values in the database
12
- let valueToJobs={} // valueId -> array of jobIdsxw
12
+ let valueToJobs={} // valueId -> array of jobIds
13
+ let currentJobsIds=[] // current jobs that are displayed in the jobs repeater
13
14
  let currentJobs=[] // current jobs that are displayed in the jobs repeater
14
15
  async function careersMultiBoxesPageOnReady(_$w) {
15
16
  if(alljobs.length===0) {
16
17
  alljobs=await getAllRecords(COLLECTIONS.JOBS);
17
- currentJobs=alljobs.map(job=>job._id);
18
+ currentJobsIds=alljobs.map(job=>job._id);
19
+ currentJobs=alljobs;
20
+ console.log("alljobs: ",alljobs)
18
21
  }
19
22
  if(Object.keys(valueToJobs).length === 0){
20
23
  allvaluesobjects=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
21
-
24
+
22
25
  for (const value of allvaluesobjects) {
23
26
  valueToJobs[value._id]= value.jobIds;
24
27
  }
@@ -75,7 +78,7 @@ async function loadJobs(_$w) {
75
78
  }
76
79
 
77
80
  function updateTotalJobsCountText(_$w) {
78
- _$w('#totalJobsCountText').text = `${currentJobs.length} Jobs`;
81
+ _$w('#totalJobsCountText').text = `${currentJobsIds.length} Jobs`;
79
82
 
80
83
  }
81
84
 
@@ -160,7 +163,7 @@ async function loadJobs(_$w) {
160
163
 
161
164
 
162
165
  async function getAllRecords(collectionId) {
163
- let q = wixData.query(collectionId);
166
+ let q = wixData.query(collectionId).include(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES)
164
167
 
165
168
 
166
169
  const items = [];
@@ -223,13 +226,31 @@ async function loadJobs(_$w) {
223
226
 
224
227
  async function applyJobFilters(_$w,filterByField) {
225
228
  let q = wixData.query(COLLECTIONS.JOBS)
229
+ console.log(currentJobs)
230
+ let newFilteredJobs=[]
231
+ let alreadyAddedJobs=[]
232
+ console.log(selectedByField)
226
233
 
227
234
  // AND across categories, OR within each category
228
235
  for (const [, values] of selectedByField.entries()) {
236
+ console.log(values)
237
+ for(job of currentJobs) {
238
+ if(job[filterByField].some(value=>values.includes(value))) {
239
+
240
+ if(!alreadyAddedJobs.includes(job._id)) {
241
+ newFilteredJobs.push(job);
242
+ alreadyAddedJobs.push(job._id);
243
+ }
244
+ }
245
+ }
246
+
229
247
  if (values && values.length) {
248
+
230
249
  q = q.hasSome(filterByField, values);
250
+
231
251
  }
232
252
  }
253
+ console.log(newFilteredJobs)
233
254
 
234
255
  await q.find()
235
256
  .then(async (res) => { _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = res.items;
@@ -245,7 +266,7 @@ async function refreshFacetCounts(_$w) {
245
266
  let currentoptions=optionsByFieldId.get(fieldId)
246
267
  let counter=new Map();
247
268
  for(const option of currentoptions) {
248
- for (const jobId of currentJobs) {
269
+ for (const jobId of currentJobsIds) {
249
270
  if (valueToJobs[option.value].includes(jobId)) {
250
271
  counter.set(option.value, (counter.get(option.value) || 0) + 1);
251
272
  }
@@ -291,7 +312,7 @@ async function refreshFacetCounts(_$w) {
291
312
  res = await res.next();
292
313
  newcurrentJobs.push(...res.items.map(job=>job._id));
293
314
  }
294
- currentJobs = newcurrentJobs;
315
+ currentJobsIds = newcurrentJobs;
295
316
  }
296
317
 
297
318
  module.exports = {