sr-npm 1.7.682 → 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 +1 -1
- package/pages/careersMultiBoxesPage.js +17 -10
package/package.json
CHANGED
|
@@ -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
|
-
|
|
129
|
+
// let fields = await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
|
|
126
130
|
|
|
127
|
-
|
|
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: ",
|
|
149
|
+
console.log("fields: ",allfields)
|
|
145
150
|
for(const [key, value] of valuesByFieldId) {
|
|
146
|
-
for(const field of
|
|
151
|
+
for(const field of allfields) {
|
|
147
152
|
if(field._id===key) {
|
|
148
153
|
let originalOptions=[];
|
|
149
154
|
if(key==="Location") {
|
|
@@ -167,7 +172,7 @@ async function loadJobs(_$w) {
|
|
|
167
172
|
//_$w("#CategoryCheckBox").options = valuesByFieldId.get(elemenet);
|
|
168
173
|
_$w(`#${FiltersIds[field.title]}CheckBox`).onChange(async (ev) => {
|
|
169
174
|
console.log("valuesByFieldId: ",valuesByFieldId)
|
|
170
|
-
console.log("fields: ",
|
|
175
|
+
console.log("fields: ",allfields)
|
|
171
176
|
dontUpdateThisCheckBox=field._id;
|
|
172
177
|
console.log("dontUpdateThisCheckBox ",dontUpdateThisCheckBox)
|
|
173
178
|
const selected = ev.target.value; // array of selected value IDs
|
|
@@ -177,6 +182,7 @@ async function loadJobs(_$w) {
|
|
|
177
182
|
} else {
|
|
178
183
|
selectedByField.delete(field._id);
|
|
179
184
|
}
|
|
185
|
+
console.log("selectedByField: ",selectedByField)
|
|
180
186
|
await applyJobFilters(_$w,field._id); // re-query jobs
|
|
181
187
|
await refreshFacetCounts(_$w,field.title); // recompute and update counts in all lists
|
|
182
188
|
// await updateSelectedValuesRepeater(_$w);
|
|
@@ -392,7 +398,8 @@ async function loadJobs(_$w) {
|
|
|
392
398
|
}
|
|
393
399
|
|
|
394
400
|
|
|
395
|
-
async function refreshFacetCounts(_$w,fieldTitle) {
|
|
401
|
+
async function refreshFacetCounts(_$w,fieldTitle) {
|
|
402
|
+
console.log("refreshFacetCounts now inisde refreshFacetCounts: ",fieldTitle)
|
|
396
403
|
const fieldIds = Array.from(optionsByFieldId.keys());
|
|
397
404
|
const currentJobsIds=currentJobs.map(job=>job._id);
|
|
398
405
|
for (const fieldId of fieldIds) {
|
|
@@ -412,9 +419,9 @@ async function refreshFacetCounts(_$w,fieldTitle) {
|
|
|
412
419
|
// const query = ($item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).value || '').toLowerCase().trim();
|
|
413
420
|
// updateOptionsUI($item, itemData._id, query);
|
|
414
421
|
// });
|
|
415
|
-
for(const
|
|
416
|
-
const query = (_$w(`#${
|
|
417
|
-
updateOptionsUI(_$w,fieldTitle,
|
|
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
|
|
418
425
|
}
|
|
419
426
|
}
|
|
420
427
|
|