sr-npm 1.7.619 → 1.7.621
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 +20 -12
package/package.json
CHANGED
|
@@ -2,14 +2,13 @@ const { COLLECTIONS,CUSTOM_VALUES_COLLECTION_FIELDS,JOBS_COLLECTION_FIELDS } = r
|
|
|
2
2
|
const { items: wixData } = require('@wix/data');
|
|
3
3
|
const {CAREERS_MULTI_BOXES_PAGE_CONSTS} = require('../backend/careersMultiBoxesPageIds');
|
|
4
4
|
|
|
5
|
-
let valuesByFieldIdGlobal = null;
|
|
6
5
|
const selectedByField = new Map(); // fieldId -> array of selected value IDs
|
|
7
|
-
const optionsByFieldId = new Map(); // fieldId -> [{label, value}]
|
|
8
|
-
const countsByFieldId = new Map();
|
|
9
|
-
let alljobs=[]
|
|
10
|
-
let allvaluesobjects=[]
|
|
11
|
-
let valueToJobs={}
|
|
12
|
-
let currentJobs=[]
|
|
6
|
+
const optionsByFieldId = new Map(); // fieldId -> [{label, value}] array of objects with label which is the valueLabel and value which is the valueId
|
|
7
|
+
const countsByFieldId = new Map(); // fieldId -> {valueId: count} map of counts for each valueId
|
|
8
|
+
let alljobs=[] // all jobs in the database
|
|
9
|
+
let allvaluesobjects=[] // all values in the database
|
|
10
|
+
let valueToJobs={} // valueId -> array of jobIdsxw
|
|
11
|
+
let currentJobs=[] // current jobs that are displayed in the jobs repeater
|
|
13
12
|
async function careersMultiBoxesPageOnReady(_$w) {
|
|
14
13
|
if(alljobs.length===0) {
|
|
15
14
|
alljobs=await getAllRecords(COLLECTIONS.JOBS);
|
|
@@ -37,6 +36,7 @@ async function careersMultiBoxesPageOnReady(_$w) {
|
|
|
37
36
|
const updated = existing.filter(v => v !== valueId);
|
|
38
37
|
if (updated.length) {
|
|
39
38
|
selectedByField.set(fieldId, updated);
|
|
39
|
+
console.log("selectedByField: ",selectedByField)
|
|
40
40
|
} else {
|
|
41
41
|
selectedByField.delete(fieldId);
|
|
42
42
|
}
|
|
@@ -53,6 +53,7 @@ async function careersMultiBoxesPageOnReady(_$w) {
|
|
|
53
53
|
await applyJobFilters(_$w,JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES);
|
|
54
54
|
await refreshFacetCounts(_$w);
|
|
55
55
|
await updateSelectedValuesRepeater(_$w);
|
|
56
|
+
updateTotalJobsCountText(_$w);
|
|
56
57
|
});
|
|
57
58
|
});
|
|
58
59
|
await updateSelectedValuesRepeater(_$w);
|
|
@@ -65,7 +66,13 @@ async function loadJobs(_$w) {
|
|
|
65
66
|
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER_ITEM_LOCATION).text=itemData.location.fullLocation
|
|
66
67
|
});
|
|
67
68
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = alljobs;
|
|
68
|
-
|
|
69
|
+
updateTotalJobsCountText(_$w);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function updateTotalJobsCountText(_$w) {
|
|
73
|
+
console.log("updating total jobs count text")
|
|
74
|
+
console.log("currentJobs.length: ",currentJobs.length)
|
|
75
|
+
_$w('#totalJobsCountText').text = `${currentJobs.length} Jobs`;
|
|
69
76
|
}
|
|
70
77
|
|
|
71
78
|
async function loadFilters(_$w) {
|
|
@@ -97,6 +104,7 @@ async function loadJobs(_$w) {
|
|
|
97
104
|
value: v._id
|
|
98
105
|
}));
|
|
99
106
|
optionsByFieldId.set(fieldId, originalOptions);
|
|
107
|
+
console.log("optionsByFieldId: ",optionsByFieldId)
|
|
100
108
|
const counter={}
|
|
101
109
|
|
|
102
110
|
for (const val of allvaluesobjects) {
|
|
@@ -104,11 +112,11 @@ async function loadJobs(_$w) {
|
|
|
104
112
|
}
|
|
105
113
|
|
|
106
114
|
countsByFieldId.set(fieldId, new Map(originalOptions.map(o => [o.value, counter[o.label]])));
|
|
115
|
+
console.log("countsByFieldId: ",countsByFieldId)
|
|
107
116
|
|
|
108
117
|
// Initialize UI
|
|
109
118
|
updateOptionsUI($item, fieldId, ''); // no search query
|
|
110
119
|
|
|
111
|
-
//$item(CHECKBOX_GROUP_ID).options = originalOptions;
|
|
112
120
|
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).selectedIndices = []; // start empty
|
|
113
121
|
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).onChange(async (ev) => {
|
|
114
122
|
const selected = ev.target.value; // array of selected value IDs
|
|
@@ -120,7 +128,7 @@ async function loadJobs(_$w) {
|
|
|
120
128
|
await applyJobFilters(_$w,JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES); // re-query jobs
|
|
121
129
|
await refreshFacetCounts(_$w); // recompute and update counts in all lists
|
|
122
130
|
await updateSelectedValuesRepeater(_$w);
|
|
123
|
-
|
|
131
|
+
updateTotalJobsCountText(_$w);
|
|
124
132
|
});
|
|
125
133
|
|
|
126
134
|
// Input typing -> only filter this list’s visible options (no Jobs query)
|
|
@@ -245,7 +253,6 @@ async function refreshFacetCounts(_$w) {
|
|
|
245
253
|
}
|
|
246
254
|
|
|
247
255
|
function updateSelectedValuesRepeater(_$w) {
|
|
248
|
-
console.log("updating selected values repeater")
|
|
249
256
|
const selectedItems = [];
|
|
250
257
|
for (const [fieldId, valueIds] of selectedByField.entries()) {
|
|
251
258
|
const opts = optionsByFieldId.get(fieldId) || [];
|
|
@@ -253,7 +260,8 @@ async function refreshFacetCounts(_$w) {
|
|
|
253
260
|
for (const id of valueIds) {
|
|
254
261
|
const label = byId.get(id);
|
|
255
262
|
if (label) {
|
|
256
|
-
selectedItems.push({ _id: `${fieldId}:${id}`, label, fieldId, valueId: id });
|
|
263
|
+
//selectedItems.push({ _id: `${fieldId}:${id}`, label, fieldId, valueId: id });
|
|
264
|
+
selectedItems.push({ label, fieldId, _id: id }); //_id is the valueId
|
|
257
265
|
}
|
|
258
266
|
}
|
|
259
267
|
}
|