sr-npm 1.7.681 → 1.7.683

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.681",
3
+ "version": "1.7.683",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -7,6 +7,7 @@ let dontUpdateThisCheckBox;
7
7
  const selectedByField = new Map(); // fieldId -> array of selected value IDs
8
8
  const optionsByFieldId = new Map(); // fieldId -> [{label, value}] array of objects with label which is the valueLabel and value which is the valueId
9
9
  const countsByFieldId = new Map(); // fieldId -> {valueId: count} map of counts for each valueId
10
+ let allfields=[] // all fields in the database
10
11
  let alljobs=[] // all jobs in the database
11
12
  let allvaluesobjects=[] // all values in the database
12
13
  let valueToJobs={} // valueId -> array of jobIds
@@ -23,7 +24,10 @@ async function careersMultiBoxesPageOnReady(_$w) {
23
24
  valueToJobs[value._id]= value.jobIds;
24
25
  }
25
26
  }
26
-
27
+ if(allfields.length===0) {
28
+ allfields=await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
29
+ allfields.push({_id:"Location",title:"Location"});
30
+ }
27
31
  await loadJobs(_$w);
28
32
  await loadFilters(_$w);
29
33
  //selected values repeater on item ready
@@ -122,9 +126,10 @@ async function loadJobs(_$w) {
122
126
  async function loadFilters(_$w) {
123
127
  try {
124
128
  // 1) Load all categories (fields)
125
- let fields = await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
129
+ // let fields = await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
126
130
 
127
- fields.push({_id:"Location",title:"Location"});
131
+ // fields.push({_id:"Location",title:"Location"});
132
+ console.log("allfields: ",allfields)
128
133
  const cities=await getAllRecords(COLLECTIONS.CITIES);
129
134
  for(const city of cities) {
130
135
  valueToJobs[city._id]=city.jobIds;
@@ -141,9 +146,9 @@ async function loadJobs(_$w) {
141
146
  counter[city.city]=city.count
142
147
  }
143
148
  console.log("valuesByFieldId: ",valuesByFieldId)
144
- console.log("fields: ",fields)
149
+ console.log("fields: ",allfields)
145
150
  for(const [key, value] of valuesByFieldId) {
146
- for(const field of fields) {
151
+ for(const field of allfields) {
147
152
  if(field._id===key) {
148
153
  let originalOptions=[];
149
154
  if(key==="Location") {
@@ -166,6 +171,8 @@ async function loadJobs(_$w) {
166
171
  _$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = []; // start empty
167
172
  //_$w("#CategoryCheckBox").options = valuesByFieldId.get(elemenet);
168
173
  _$w(`#${FiltersIds[field.title]}CheckBox`).onChange(async (ev) => {
174
+ console.log("valuesByFieldId: ",valuesByFieldId)
175
+ console.log("fields: ",allfields)
169
176
  dontUpdateThisCheckBox=field._id;
170
177
  console.log("dontUpdateThisCheckBox ",dontUpdateThisCheckBox)
171
178
  const selected = ev.target.value; // array of selected value IDs
@@ -175,6 +182,7 @@ async function loadJobs(_$w) {
175
182
  } else {
176
183
  selectedByField.delete(field._id);
177
184
  }
185
+ console.log("selectedByField: ",selectedByField)
178
186
  await applyJobFilters(_$w,field._id); // re-query jobs
179
187
  await refreshFacetCounts(_$w,field.title); // recompute and update counts in all lists
180
188
  // await updateSelectedValuesRepeater(_$w);
@@ -390,7 +398,8 @@ async function loadJobs(_$w) {
390
398
  }
391
399
 
392
400
 
393
- async function refreshFacetCounts(_$w,fieldTitle) {
401
+ async function refreshFacetCounts(_$w,fieldTitle) {
402
+ console.log("refreshFacetCounts now inisde refreshFacetCounts: ",fieldTitle)
394
403
  const fieldIds = Array.from(optionsByFieldId.keys());
395
404
  const currentJobsIds=currentJobs.map(job=>job._id);
396
405
  for (const fieldId of fieldIds) {
@@ -410,9 +419,9 @@ async function refreshFacetCounts(_$w,fieldTitle) {
410
419
  // const query = ($item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).value || '').toLowerCase().trim();
411
420
  // updateOptionsUI($item, itemData._id, query);
412
421
  // });
413
- for(const fieldId of fieldIds) {
414
- const query = (_$w(`#${fieldTitle}input`).value || '').toLowerCase().trim();
415
- updateOptionsUI(_$w,fieldTitle, fieldId, query); // no search query
422
+ for(const field of allfields) {
423
+ const query = (_$w(`#${FiltersIds[field.title]}input`).value || '').toLowerCase().trim();
424
+ updateOptionsUI(_$w,fieldTitle, field._id, query); // no search query
416
425
  }
417
426
  }
418
427