sr-npm 1.7.697 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.697",
3
+ "version": "1.7.698",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,7 +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');
3
+ const { groupValuesByField, debounce, getAllRecords } = require('./pagesUtils');
4
+
5
5
  let dontUpdateThisCheckBox;
6
6
  const selectedByField = new Map(); // fieldId -> array of selected value IDs
7
7
  const optionsByFieldId = new Map(); // fieldId -> [{label, value}] array of objects with label which is the valueLabel and value which is the valueId
@@ -21,11 +21,13 @@ async function careersMultiBoxesPageOnReady(_$w) {
21
21
  await loadFilters(_$w);
22
22
  await loadSelectedValuesRepeater(_$w);
23
23
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CLEAR_ALL_BUTTON_ID).onClick(async () => {
24
+ if(selectedByField.size>0) {
24
25
  selectedByField.clear();
25
26
  await applyJobFilters(_$w);
26
- await refreshFacetCounts(_$w,true);
27
- await updateSelectedValuesRepeater(_$w);
28
- updateTotalJobsCountText(_$w);
27
+ await refreshFacetCounts(_$w,true);
28
+ await updateSelectedValuesRepeater(_$w);
29
+ updateTotalJobsCountText(_$w);
30
+ }
29
31
  });
30
32
  await loadPaginationButtons(_$w);
31
33
  }
@@ -176,6 +178,7 @@ async function loadJobsRepeater(_$w) {
176
178
  const query = (_$w(`#${FiltersIds[field.title]}input`).value || '').toLowerCase().trim();
177
179
  updateOptionsUI(_$w, field.title, field._id, query);
178
180
  }, 150);
181
+
179
182
  _$w(`#${FiltersIds[field.title]}input`).onInput(runFilter);
180
183
  }
181
184
  }
@@ -188,29 +191,6 @@ async function loadJobsRepeater(_$w) {
188
191
  }
189
192
 
190
193
 
191
- async function getAllRecords(collectionId) {
192
- let q = wixData.query(collectionId).include(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES)
193
-
194
-
195
- const items = [];
196
- let res = await q.limit(1000).find();
197
- items.push(...res.items);
198
-
199
- while (res.hasNext()) {
200
- res = await res.next();
201
- items.push(...res.items);
202
- }
203
- return items;
204
- }
205
-
206
- const debounce = (fn, ms = 150) => {
207
- let t;
208
- return (...args) => {
209
- clearTimeout(t);
210
- t = setTimeout(() => fn(...args), ms);
211
- };
212
- };
213
-
214
194
  function updateOptionsUI(_$w,fieldTitle, fieldId, searchQuery,clearAll=false) {
215
195
  let base = optionsByFieldId.get(fieldId) || [];
216
196
  const countsMap = countsByFieldId.get(fieldId) || new Map();
@@ -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
  }