sr-npm 1.7.695 → 1.7.697

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.695",
3
+ "version": "1.7.697",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,8 +1,7 @@
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,FiltersIds} = require('../backend/careersMultiBoxesPageIds');
4
-
5
- let valuesByFieldIdGlobal = null;
4
+ const { groupValuesByField } = require('./pagesUtils');
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
@@ -33,23 +32,17 @@ async function careersMultiBoxesPageOnReady(_$w) {
33
32
 
34
33
  async function loadPaginationButtons(_$w) {
35
34
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_NEXT).onClick(async () => {
36
- console.log("next page button clicked");
37
- console.log("current page: ", pagination.currentPage);
38
35
  let nextPageJobs=currentJobs.slice(pagination.pageSize*pagination.currentPage,pagination.pageSize*(pagination.currentPage+1));
39
36
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationCurrentText).text = (nextPageJobs.length+pagination.pageSize*pagination.currentPage).toString();
40
37
  pagination.currentPage++;
41
- console.log("next page ", pagination.currentPage);
42
38
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = nextPageJobs;
43
39
  handlePaginationButtons(_$w);
44
40
  });
45
41
 
46
42
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_PREVIOUS).onClick(async () => {
47
- console.log("previous page button clicked");
48
- console.log("current page: ", pagination.currentPage);
49
43
  let previousPageJobs=currentJobs.slice(pagination.pageSize*(pagination.currentPage-1),pagination.pageSize*pagination.currentPage);
50
44
  pagination.currentPage--;
51
45
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationCurrentText).text = (pagination.pageSize*pagination.currentPage).toString();
52
- console.log("previous page ", pagination.currentPage);
53
46
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = previousPageJobs;
54
47
  handlePaginationButtons(_$w);
55
48
  });
@@ -92,7 +85,6 @@ async function loadSelectedValuesRepeater(_$w) {
92
85
  }
93
86
 
94
87
  async function loadData(_$w) {
95
-
96
88
  if(alljobs.length===0) {
97
89
  alljobs=await getAllRecords(COLLECTIONS.JOBS);
98
90
  currentJobs=alljobs;
@@ -117,13 +109,14 @@ async function loadJobsRepeater(_$w) {
117
109
 
118
110
  const jobsFirstPage=alljobs.slice(0,pagination.pageSize);
119
111
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = jobsFirstPage;
112
+ _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationCurrentText).text = jobsFirstPage.length.toString();
113
+ _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationTotalCountText).text = currentJobs.length.toString();
120
114
  updateTotalJobsCountText(_$w);
121
115
  handlePaginationButtons(_$w);
122
116
  }
123
117
 
124
118
  function updateTotalJobsCountText(_$w) {
125
119
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.TotalJobsCountText).text = `${currentJobs.length} Jobs`;
126
- _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationTotalCountText).text = currentJobs.length.toString();
127
120
  }
128
121
 
129
122
  async function loadFilters(_$w) {
@@ -136,7 +129,6 @@ async function loadJobsRepeater(_$w) {
136
129
  // 2) Load all values once and group them by referenced field
137
130
  let valuesByFieldId = groupValuesByField(allvaluesobjects, CUSTOM_VALUES_COLLECTION_FIELDS.CUSTOM_FIELD);
138
131
  valuesByFieldId.set("Location",cities)
139
- valuesByFieldIdGlobal = valuesByFieldId; // store globally
140
132
 
141
133
  // Build CheckboxGroup options for this field
142
134
 
@@ -293,6 +285,8 @@ async function loadJobsRepeater(_$w) {
293
285
  currentJobs=finalFilteredJobs;
294
286
  const jobsFirstPage=currentJobs.slice(0,pagination.pageSize);
295
287
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = jobsFirstPage;
288
+ _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationCurrentText).text = jobsFirstPage.length.toString();
289
+ _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationTotalCountText).text = currentJobs.length.toString();
296
290
  pagination.currentPage=1;
297
291
  handlePaginationButtons(_$w);
298
292
  }
@@ -325,18 +319,7 @@ async function refreshFacetCounts(_$w,clearAll=false) {
325
319
  }
326
320
  }
327
321
 
328
- function groupValuesByField(values, refKey) {
329
- const map = new Map();
330
- for (const v of values) {
331
- const ref = v[refKey]; // should be the _id of the CustomFields item
332
- if (!map.has(ref)) map.set(ref, []);
333
- map.get(ref).push({
334
- label: v.title ,
335
- value: v._id
336
- });
337
- }
338
- return map;
339
- }
322
+
340
323
 
341
324
  function updateSelectedValuesRepeater(_$w) {
342
325
  const selectedItems = [];
package/pages/index.js CHANGED
@@ -3,5 +3,6 @@ module.exports = {
3
3
  ...require('./homePage'),
4
4
  ...require('./careersPage'),
5
5
  ...require('./careersMultiBoxesPage'),
6
+ ...require('./pagesUtils'),
6
7
  };
7
8
 
@@ -0,0 +1,16 @@
1
+ function groupValuesByField(values, refKey) {
2
+ const map = new Map();
3
+ for (const v of values) {
4
+ const ref = v[refKey]; // should be the _id of the CustomFields item
5
+ if (!map.has(ref)) map.set(ref, []);
6
+ map.get(ref).push({
7
+ label: v.title ,
8
+ value: v._id
9
+ });
10
+ }
11
+ return map;
12
+ }
13
+
14
+ module.exports = {
15
+ groupValuesByField,
16
+ }