sr-npm 1.7.636 → 1.7.638

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.636",
3
+ "version": "1.7.638",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,7 +1,8 @@
1
1
  const { COLLECTIONS,CUSTOM_VALUES_COLLECTION_FIELDS,JOBS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
2
2
  const { items: wixData } = require('@wix/data');
3
3
  const {CAREERS_MULTI_BOXES_PAGE_CONSTS} = require('../backend/careersMultiBoxesPageIds');
4
-
4
+ const { auth } = require('@wix/essentials');
5
+ const getAllRecordsElevated = auth.elevate(wixData.query);
5
6
  let valuesByFieldIdGlobal = null;
6
7
  let dontUpdateThisCheckBox;
7
8
  const selectedByField = new Map(); // fieldId -> array of selected value IDs
@@ -82,8 +83,10 @@ async function loadJobs(_$w) {
82
83
  try {
83
84
  // 1) Load all categories (fields)
84
85
  const fields = await getAllRecords(COLLECTIONS.CUSTOM_FIELDS);
86
+ console.log("fields: ",fields)
85
87
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER).data = fields;
86
-
88
+ const cities=await getAllRecords(COLLECTIONS.CITIES);
89
+ console.log("cities: ",cities)
87
90
  // 2) Load all values once and group them by referenced field
88
91
 
89
92
  const valuesByFieldId = groupValuesByField(allvaluesobjects, CUSTOM_VALUES_COLLECTION_FIELDS.CUSTOM_FIELD);
@@ -153,14 +156,15 @@ async function loadJobs(_$w) {
153
156
  console.error('Failed to load filters:', err);
154
157
  }
155
158
  }
156
-
159
+
157
160
 
158
161
  async function getAllRecords(collectionId) {
159
- let q = wixData.query(collectionId);
162
+ //let q = wixData.query(collectionId);
163
+ let q=getAllRecordsElevated(collectionId)
160
164
 
161
165
 
162
166
  const items = [];
163
- let res = await q.limit(1000).find();
167
+ let res = await q.limit(1000).find()
164
168
  items.push(...res.items);
165
169
 
166
170
  while (res.hasNext()) {
@@ -181,26 +185,19 @@ async function loadJobs(_$w) {
181
185
  function updateOptionsUI($item, fieldId, searchQuery) {
182
186
  let base = optionsByFieldId.get(fieldId) || [];
183
187
  const countsMap = countsByFieldId.get(fieldId) || new Map();
184
- console.log("base before filtering: ",base)
185
- console.log("countsMap: ",countsMap)
186
188
  if(dontUpdateThisCheckBox===fieldId)
187
189
  {
188
190
  dontUpdateThisCheckBox=null;
189
191
  return;
190
192
  }
191
193
  let filteredbase=[]
192
-
193
-
194
-
195
194
  for (const element of base)
196
195
  {
197
- console.log("element: ",element)
198
196
  if(countsMap.get(element.value))
199
197
  {
200
198
  filteredbase.push(element)
201
199
  }
202
200
  }
203
- console.log("base after filtering: ",filteredbase)
204
201
  // Build display options with counts
205
202
  const withCounts = filteredbase.map(o => {
206
203
  const count = countsMap.get(o.value)
@@ -209,7 +206,6 @@ async function loadJobs(_$w) {
209
206
  value: o.value
210
207
  };
211
208
  });
212
- console.log("withCounts: ",withCounts)
213
209
  // Apply search
214
210
  const filtered = searchQuery
215
211
  ? withCounts.filter(o => (o.label || '').toLowerCase().includes(searchQuery))
@@ -219,8 +215,6 @@ async function loadJobs(_$w) {
219
215
  const prevSelected = $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).value || [];
220
216
  const visibleSet = new Set(filtered.map(o => o.value));
221
217
  const preserved = prevSelected.filter(v => visibleSet.has(v));
222
- console.log("preserved: ",preserved)
223
- console.log("filtered: ",filtered)
224
218
 
225
219
  $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).options = filtered;
226
220
  $item(CAREERS_MULTI_BOXES_PAGE_CONSTS.FILTER_REPEATER_ITEM_CHECKBOX).value = preserved;
@@ -290,21 +284,6 @@ async function refreshFacetCounts(_$w) {
290
284
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).data = selectedItems;
291
285
  }
292
286
 
293
- // function updateSelectedValuesRepeater(_$w) {
294
- // const selectedItems = [];
295
- // for (const [fieldId, valueIds] of selectedByField.entries()) {
296
- // const opts = optionsByFieldId.get(fieldId) || [];
297
- // const byId = new Map(opts.map(o => [o.value, o.label]));
298
- // for (const id of valueIds) {
299
- // const label = byId.get(id);
300
- // if (label) {
301
- // selectedItems.push({ _id: `${fieldId}:${id}`, label, fieldId, valueId: id });
302
- // }
303
- // }
304
- // }
305
- // _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).data = selectedItems;
306
- // }
307
-
308
287
  async function updateCurrentJobs(res) {
309
288
  let newcurrentJobs = [];
310
289
  newcurrentJobs.push(...res.items.map(job=>job._id));