sr-npm 1.7.696 → 1.7.698
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 +8 -31
- package/pages/pagesUtils.js +28 -0
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
const { COLLECTIONS,CUSTOM_VALUES_COLLECTION_FIELDS,JOBS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
|
|
2
|
-
const { items: wixData } = require('@wix/data');
|
|
3
2
|
const {CAREERS_MULTI_BOXES_PAGE_CONSTS,FiltersIds} = require('../backend/careersMultiBoxesPageIds');
|
|
4
|
-
const { groupValuesByField } = require('./pagesUtils');
|
|
5
|
-
|
|
3
|
+
const { groupValuesByField, debounce, getAllRecords } = require('./pagesUtils');
|
|
4
|
+
|
|
6
5
|
let dontUpdateThisCheckBox;
|
|
7
6
|
const selectedByField = new Map(); // fieldId -> array of selected value IDs
|
|
8
7
|
const optionsByFieldId = new Map(); // fieldId -> [{label, value}] array of objects with label which is the valueLabel and value which is the valueId
|
|
@@ -22,11 +21,13 @@ async function careersMultiBoxesPageOnReady(_$w) {
|
|
|
22
21
|
await loadFilters(_$w);
|
|
23
22
|
await loadSelectedValuesRepeater(_$w);
|
|
24
23
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CLEAR_ALL_BUTTON_ID).onClick(async () => {
|
|
24
|
+
if(selectedByField.size>0) {
|
|
25
25
|
selectedByField.clear();
|
|
26
26
|
await applyJobFilters(_$w);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
await refreshFacetCounts(_$w,true);
|
|
28
|
+
await updateSelectedValuesRepeater(_$w);
|
|
29
|
+
updateTotalJobsCountText(_$w);
|
|
30
|
+
}
|
|
30
31
|
});
|
|
31
32
|
await loadPaginationButtons(_$w);
|
|
32
33
|
}
|
|
@@ -86,7 +87,6 @@ async function loadSelectedValuesRepeater(_$w) {
|
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
async function loadData(_$w) {
|
|
89
|
-
|
|
90
90
|
if(alljobs.length===0) {
|
|
91
91
|
alljobs=await getAllRecords(COLLECTIONS.JOBS);
|
|
92
92
|
currentJobs=alljobs;
|
|
@@ -131,7 +131,6 @@ async function loadJobsRepeater(_$w) {
|
|
|
131
131
|
// 2) Load all values once and group them by referenced field
|
|
132
132
|
let valuesByFieldId = groupValuesByField(allvaluesobjects, CUSTOM_VALUES_COLLECTION_FIELDS.CUSTOM_FIELD);
|
|
133
133
|
valuesByFieldId.set("Location",cities)
|
|
134
|
-
valuesByFieldIdGlobal = valuesByFieldId; // store globally
|
|
135
134
|
|
|
136
135
|
// Build CheckboxGroup options for this field
|
|
137
136
|
|
|
@@ -179,6 +178,7 @@ async function loadJobsRepeater(_$w) {
|
|
|
179
178
|
const query = (_$w(`#${FiltersIds[field.title]}input`).value || '').toLowerCase().trim();
|
|
180
179
|
updateOptionsUI(_$w, field.title, field._id, query);
|
|
181
180
|
}, 150);
|
|
181
|
+
|
|
182
182
|
_$w(`#${FiltersIds[field.title]}input`).onInput(runFilter);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
@@ -191,29 +191,6 @@ async function loadJobsRepeater(_$w) {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
|
|
194
|
-
async function getAllRecords(collectionId) {
|
|
195
|
-
let q = wixData.query(collectionId).include(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES)
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const items = [];
|
|
199
|
-
let res = await q.limit(1000).find();
|
|
200
|
-
items.push(...res.items);
|
|
201
|
-
|
|
202
|
-
while (res.hasNext()) {
|
|
203
|
-
res = await res.next();
|
|
204
|
-
items.push(...res.items);
|
|
205
|
-
}
|
|
206
|
-
return items;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const debounce = (fn, ms = 150) => {
|
|
210
|
-
let t;
|
|
211
|
-
return (...args) => {
|
|
212
|
-
clearTimeout(t);
|
|
213
|
-
t = setTimeout(() => fn(...args), ms);
|
|
214
|
-
};
|
|
215
|
-
};
|
|
216
|
-
|
|
217
194
|
function updateOptionsUI(_$w,fieldTitle, fieldId, searchQuery,clearAll=false) {
|
|
218
195
|
let base = optionsByFieldId.get(fieldId) || [];
|
|
219
196
|
const countsMap = countsByFieldId.get(fieldId) || new Map();
|
package/pages/pagesUtils.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
const { items: wixData } = require('@wix/data');
|
|
2
|
+
const { JOBS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
|
|
3
|
+
|
|
1
4
|
function groupValuesByField(values, refKey) {
|
|
2
5
|
const map = new Map();
|
|
3
6
|
for (const v of values) {
|
|
@@ -11,6 +14,31 @@ function groupValuesByField(values, refKey) {
|
|
|
11
14
|
return map;
|
|
12
15
|
}
|
|
13
16
|
|
|
17
|
+
const debounce = (fn, ms = 150) => {
|
|
18
|
+
let t;
|
|
19
|
+
return (...args) => {
|
|
20
|
+
clearTimeout(t);
|
|
21
|
+
t = setTimeout(() => fn(...args), ms);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
async function getAllRecords(collectionId) {
|
|
26
|
+
let q = wixData.query(collectionId).include(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const items = [];
|
|
30
|
+
let res = await q.limit(1000).find();
|
|
31
|
+
items.push(...res.items);
|
|
32
|
+
|
|
33
|
+
while (res.hasNext()) {
|
|
34
|
+
res = await res.next();
|
|
35
|
+
items.push(...res.items);
|
|
36
|
+
}
|
|
37
|
+
return items;
|
|
38
|
+
}
|
|
39
|
+
|
|
14
40
|
module.exports = {
|
|
15
41
|
groupValuesByField,
|
|
42
|
+
debounce,
|
|
43
|
+
getAllRecords,
|
|
16
44
|
}
|