sr-npm 1.7.619 → 1.7.620
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 +16 -10
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
6
|
const optionsByFieldId = new Map(); // fieldId -> [{label, value}]
|
|
8
7
|
const countsByFieldId = new Map();
|
|
9
|
-
let alljobs=[]
|
|
10
|
-
let allvaluesobjects=[]
|
|
11
|
-
let valueToJobs={}
|
|
12
|
-
let currentJobs=[]
|
|
8
|
+
let alljobs=[] // all jobs in the database
|
|
9
|
+
let allvaluesobjects=[] // all values in the database
|
|
10
|
+
let valueToJobs={} // valueId -> array of jobIds
|
|
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,11 @@ 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
|
+
_$w('#totalJobsCountText').text = `${currentJobs.length} Jobs`;
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
async function loadFilters(_$w) {
|
|
@@ -97,6 +102,7 @@ async function loadJobs(_$w) {
|
|
|
97
102
|
value: v._id
|
|
98
103
|
}));
|
|
99
104
|
optionsByFieldId.set(fieldId, originalOptions);
|
|
105
|
+
console.log("optionsByFieldId: ",optionsByFieldId)
|
|
100
106
|
const counter={}
|
|
101
107
|
|
|
102
108
|
for (const val of allvaluesobjects) {
|
|
@@ -104,11 +110,11 @@ async function loadJobs(_$w) {
|
|
|
104
110
|
}
|
|
105
111
|
|
|
106
112
|
countsByFieldId.set(fieldId, new Map(originalOptions.map(o => [o.value, counter[o.label]])));
|
|
113
|
+
console.log("countsByFieldId: ",countsByFieldId)
|
|
107
114
|
|
|
108
115
|
// Initialize UI
|
|
109
116
|
updateOptionsUI($item, fieldId, ''); // no search query
|
|
110
117
|
|
|
111
|
-
//$item(CHECKBOX_GROUP_ID).options = originalOptions;
|
|
112
118
|
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).selectedIndices = []; // start empty
|
|
113
119
|
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).onChange(async (ev) => {
|
|
114
120
|
const selected = ev.target.value; // array of selected value IDs
|
|
@@ -120,7 +126,7 @@ async function loadJobs(_$w) {
|
|
|
120
126
|
await applyJobFilters(_$w,JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES); // re-query jobs
|
|
121
127
|
await refreshFacetCounts(_$w); // recompute and update counts in all lists
|
|
122
128
|
await updateSelectedValuesRepeater(_$w);
|
|
123
|
-
|
|
129
|
+
updateTotalJobsCountText(_$w);
|
|
124
130
|
});
|
|
125
131
|
|
|
126
132
|
// Input typing -> only filter this list’s visible options (no Jobs query)
|
|
@@ -245,7 +251,6 @@ async function refreshFacetCounts(_$w) {
|
|
|
245
251
|
}
|
|
246
252
|
|
|
247
253
|
function updateSelectedValuesRepeater(_$w) {
|
|
248
|
-
console.log("updating selected values repeater")
|
|
249
254
|
const selectedItems = [];
|
|
250
255
|
for (const [fieldId, valueIds] of selectedByField.entries()) {
|
|
251
256
|
const opts = optionsByFieldId.get(fieldId) || [];
|
|
@@ -253,7 +258,8 @@ async function refreshFacetCounts(_$w) {
|
|
|
253
258
|
for (const id of valueIds) {
|
|
254
259
|
const label = byId.get(id);
|
|
255
260
|
if (label) {
|
|
256
|
-
selectedItems.push({ _id: `${fieldId}:${id}`, label, fieldId, valueId: id });
|
|
261
|
+
//selectedItems.push({ _id: `${fieldId}:${id}`, label, fieldId, valueId: id });
|
|
262
|
+
selectedItems.push({ label, fieldId, valueId: id });
|
|
257
263
|
}
|
|
258
264
|
}
|
|
259
265
|
}
|