sr-npm 1.7.577 → 1.7.579

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.577",
3
+ "version": "1.7.579",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -36,12 +36,12 @@ async function careersMultiBoxesPageOnReady(_$w) {
36
36
  }
37
37
  });
38
38
 
39
- applyJobFilters(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES);
40
- refreshFacetCounts();
41
- updateSelectedValuesRepeater();
39
+ applyJobFilters(_$w,JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES);
40
+ refreshFacetCounts(_$w);
41
+ updateSelectedValuesRepeater(_$w);
42
42
  });
43
43
  });
44
- updateSelectedValuesRepeater();
44
+ updateSelectedValuesRepeater(_$w);
45
45
  }
46
46
 
47
47
  async function loadJobs(_$w) {
@@ -73,7 +73,7 @@ async function loadJobs(_$w) {
73
73
 
74
74
 
75
75
  // 3) Bind each filter repeater item
76
- $w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).onItemReady(async ($item, itemData) => {
76
+ _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).onItemReady(async ($item, itemData) => {
77
77
  $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).onClick(()=>{
78
78
  $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_CHECKBOX_CONTAINER).collapsed ? $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_CHECKBOX_CONTAINER).expand() : $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_CHECKBOX_CONTAINER).collapse()
79
79
  })
@@ -108,8 +108,8 @@ async function loadJobs(_$w) {
108
108
  } else {
109
109
  selectedByField.delete(fieldId);
110
110
  }
111
- applyJobFilters(); // re-query jobs
112
- refreshFacetCounts(); // recompute and update counts in all lists
111
+ applyJobFilters(_$w,JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES); // re-query jobs
112
+ refreshFacetCounts(_$w); // recompute and update counts in all lists
113
113
 
114
114
  });
115
115
 
@@ -121,7 +121,7 @@ async function loadJobs(_$w) {
121
121
  $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).onInput(runFilter);
122
122
  });
123
123
 
124
- await refreshFacetCounts();
124
+ await refreshFacetCounts(_$w);
125
125
  // After counts are ready, re-render all items to show numbers
126
126
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).forEachItem(($item, itemData) => {
127
127
  const query = ($item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_LABEL).value || '').toLowerCase().trim();
@@ -184,7 +184,7 @@ async function loadJobs(_$w) {
184
184
  $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).value = preserved;
185
185
  }
186
186
 
187
- function applyJobFilters(filterByField) {
187
+ function applyJobFilters(_$w,filterByField) {
188
188
  let q = wixData.query(COLLECTIONS.JOBS)
189
189
 
190
190
  // AND across categories, OR within each category
@@ -200,7 +200,7 @@ async function loadJobs(_$w) {
200
200
  }
201
201
 
202
202
 
203
- async function refreshFacetCounts() {
203
+ async function refreshFacetCounts(_$w) {
204
204
  if (!valuesByFieldIdGlobal)
205
205
  {
206
206
  return;
@@ -269,6 +269,32 @@ async function refreshFacetCounts() {
269
269
  return map;
270
270
  }
271
271
 
272
+ function updateSelectedValuesRepeater(_$w) {
273
+ const selectedItems = [];
274
+ for (const [fieldId, valueIds] of selectedByField.entries()) {
275
+ const opts = optionsByFieldId.get(fieldId) || [];
276
+ const byId = new Map(opts.map(o => [o.value, o.label]));
277
+ for (const id of valueIds) {
278
+ const label = byId.get(id);
279
+ if (label) {
280
+ selectedItems.push({ _id: `${fieldId}:${id}`, label, fieldId, valueId: id });
281
+ }
282
+ }
283
+ }
284
+ _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).data = selectedItems;
285
+ }
286
+
287
+ async function findAll(q) {
288
+ const out = [];
289
+ let res = await q.limit(1000).find();
290
+ out.push(...res.items);
291
+ while (res.hasNext()) {
292
+ res = await res.next();
293
+ out.push(...res.items);
294
+ }
295
+ return out;
296
+ }
297
+
272
298
 
273
299
  module.exports = {
274
300
  careersMultiBoxesPageOnReady