sr-npm 1.7.888 → 1.7.889

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.
@@ -41,7 +41,7 @@ const CUSTOM_VALUES_COLLECTION_FIELDS = {
41
41
  TITLE: 'title',
42
42
  CUSTOM_FIELD: 'customField',
43
43
  MULTI_REF_JOBS_CUSTOM_VALUES: 'multiRefJobsCustomValues',
44
- TOTAL_JOBS: 'totalJobs',
44
+ count: 'count',
45
45
  JOB_IDS: 'jobIds',
46
46
  }
47
47
  const CUSTOM_FIELDS_COLLECTION_FIELDS = {
@@ -112,7 +112,7 @@ const COLLECTIONS_FIELDS = {
112
112
  CUSTOM_VALUES: [
113
113
  {key:'title', type: 'TEXT'},
114
114
  {key:'customField', type: 'REFERENCE', typeMetadata: { reference: { referencedCollectionId: COLLECTIONS.CUSTOM_FIELDS } } },
115
- {key:'totalJobs', type: 'NUMBER'},
115
+ {key:'count', type: 'NUMBER'},
116
116
  {key:'multiRefJobsCustomValues', type: 'MULTI_REFERENCE', typeMetadata: { multiReference: { referencedCollectionId: COLLECTIONS.JOBS,referencingFieldKey:CUSTOM_VALUES_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,referencingDisplayName:CUSTOM_VALUES_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES } } },
117
117
  {key:'jobIds', type: 'ARRAY'},
118
118
  ],
package/backend/data.js CHANGED
@@ -145,6 +145,7 @@ async function saveJobsDataToCMS() {
145
145
  getEmploymentType(position,customFieldsValues);
146
146
  getLocation(position,basicJob);
147
147
  if(templateType===TEMPLATE_TYPE.INTERNAL){
148
+
148
149
  getVisibility(position,customFieldsValues);
149
150
  }
150
151
 
@@ -219,7 +220,7 @@ async function populateCustomValuesCollection(customFieldsValues) {
219
220
  _id: valueId,
220
221
  title: valuesMap[valueId],
221
222
  customField: fieldId,
222
- totalJobs:customValuesToJobs[valueId].length,
223
+ count:customValuesToJobs[valueId].length,
223
224
  jobIds:customValuesToJobs[valueId],
224
225
  })
225
226
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.888",
3
+ "version": "1.7.889",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -255,7 +255,7 @@ async function loadJobsRepeater(_$w) {
255
255
 
256
256
  optionsByFieldId.set(key, originalOptions);
257
257
  for (const val of allvaluesobjects) {
258
- counter[val.title]=val.totalJobs
258
+ counter[val.title]=val.count
259
259
  }
260
260
 
261
261
  countsByFieldId.set(key, new Map(originalOptions.map(o => [o.value, counter[o.label]])));
@@ -110,8 +110,6 @@ async function handleUrlParams(_$w) {
110
110
  if (queryBrandVar && _$w('#dropdownBrand').isVisible) { //if it is not visible, ignore it
111
111
  await handleBrandParam(_$w,queryBrandVar);
112
112
  }
113
-
114
-
115
113
  if (queryPageVar) {
116
114
  await handlePageParam(_$w);
117
115
  }
@@ -124,8 +122,6 @@ async function handleUrlParams(_$w) {
124
122
  if (queryJobTypeVar) {
125
123
  await handleJobTypeParam(_$w,queryJobTypeVar);
126
124
  }
127
-
128
-
129
125
  await applyFilters(_$w, true); // Skip URL update since we're handling initial URL params
130
126
  }
131
127
 
package/pages/homePage.js CHANGED
@@ -10,6 +10,7 @@ const { COLLECTIONS } = require('../backend/collectionConsts');
10
10
  const { bindPrimarySearch,getAllRecords,loadPrimarySearchRepeater } = require('./pagesUtils');
11
11
  let thisObjectVar;
12
12
  let searchByCityFlag=false;
13
+ let loadedCategories=false;
13
14
  async function homePageOnReady(_$w,thisObject=null) {
14
15
 
15
16
  const queryResult = await wixData.query(COLLECTIONS.SITE_CONFIGS).find();
@@ -19,7 +20,10 @@ async function homePageOnReady(_$w,thisObject=null) {
19
20
  const allvaluesobjects=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
20
21
  await Promise.all([
21
22
  bindPrimarySearch(_$w,allvaluesobjects,allJobs),
22
- loadPrimarySearchRepeater(_$w)
23
+ loadPrimarySearchRepeater(_$w),
24
+ bindTeamRepeater(_$w),
25
+ bindViewAllButton(_$w),
26
+
23
27
  ]);
24
28
  }
25
29
  else{
@@ -32,13 +36,9 @@ async function homePageOnReady(_$w,thisObject=null) {
32
36
  }
33
37
 
34
38
  function bind(_$w) {
35
- _$w('#teamRepeater').onItemReady(($item, itemData) => {
36
- $item('#teamButton').label = `View ${itemData.count} Open Positions`;
37
- $item('#teamButton').onClick(()=>{
38
- const department = encodeURIComponent(itemData.title);
39
- location.to(`/positions?department=${department}`);
40
- });
41
- });
39
+
40
+ bindTeamRepeater(_$w);
41
+
42
42
 
43
43
  _$w('#citiesDataset').onReady(async () => {
44
44
  const numOfItems = await _$w('#citiesDataset').getTotalCount();
@@ -64,6 +64,45 @@ async function homePageOnReady(_$w,thisObject=null) {
64
64
  });
65
65
  }
66
66
 
67
+ function bindTeamRepeater(_$w) {
68
+ _$w('#teamRepeater').onItemReady(($item, itemData) => {
69
+ $item('#teamButton').label = `View ${itemData.count} Open Positions`;
70
+ const department = encodeURIComponent(itemData.title);
71
+ if (itemData.customField) {
72
+ [$item('#teamButton'), $item('#teamButton2')].forEach(btn => {
73
+ btn.onClick(() => {
74
+ location.to(`/search?category=${department}`);
75
+ });
76
+ });
77
+
78
+ }
79
+ else{
80
+ $item('#teamButton').onClick(()=>{
81
+ location.to(`/positions?department=${department}`);
82
+ });
83
+ }
84
+ });
85
+ }
86
+
87
+ function bindViewAllButton(_$w) {
88
+
89
+ _$w('#viewAllCategoriesButton').onClick(()=>{
90
+ if(!loadedCategories) {
91
+ loadedCategories=true;
92
+ _$w('#viewAllCategoriesButton').label = "View Less";
93
+ _$w("#categoriesDataset").loadMore();
94
+ }
95
+ else{
96
+ loadedCategories=false;
97
+ _$w('#viewAllCategoriesButton').label = "View All";
98
+ _$w("#categoriesDataset").loadPage(1);
99
+ }
100
+ });
101
+ }
102
+
103
+
104
+
105
+
67
106
  function init(_$w) {
68
107
  const debouncedInput = debounce(()=>handleSearchInput(_$w), 400,thisObjectVar);
69
108
 
@@ -141,7 +141,7 @@ async function loadCategoriesListPrimarySearch(_$w,allvaluesobjects) {
141
141
  let categoryValues=[]
142
142
  for(const value of allvaluesobjects) {
143
143
  if(value.customField===CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
144
- categoryValues.push({title:value.title+` (${value.totalJobs})` ,_id:value._id});
144
+ categoryValues.push({title:value.title+` (${value.count})` ,_id:value._id});
145
145
  }
146
146
  }
147
147
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data = categoryValues;
@@ -37,10 +37,9 @@ async function getCategoryValueId(customValues) {
37
37
  const item = await _$w('#datasetJobsItem').getCurrentItem();
38
38
  const multiRefField=await getPositionWithMultiRefField(item._id);
39
39
  const categoryValueId=await getCategoryValueId(multiRefField);
40
-
41
40
  handleReferFriendButton(_$w,item);
42
-
43
41
  handleApplyButton(_$w,item);
42
+
44
43
 
45
44
  _$w('#companyDescriptionText').text = htmlToText(item.jobDescription.companyDescription.text);
46
45
  _$w('#responsibilitiesText').text = htmlToText(item.jobDescription.jobDescription.text);
@@ -52,12 +51,12 @@ async function getCategoryValueId(customValues) {
52
51
  }
53
52
  if(_$w('#relatedJobsRepNoDepartment')) // when there is no department, we filter based on category
54
53
  {
55
- const relatedJobs=await getRelatedJobs(categoryValueId,item._id);
54
+ const relatedJobs=await getRelatedJobs(categoryValueId,item._id,5);
56
55
  _$w('#relatedJobsRepNoDepartment').onItemReady(($item, itemData) => {
57
56
  $item('#relatedJobTitle').text = itemData.title;
58
57
  $item('#relatedJobLocation').text = itemData.location.fullLocation;
59
58
  });
60
- _$w('#relatedJobsRepNoDepartment').data = relatedJobs
59
+ _$w('#relatedJobsRepNoDepartment').data = relatedJobs;
61
60
 
62
61
 
63
62
  }
@@ -83,19 +82,25 @@ async function getCategoryValueId(customValues) {
83
82
 
84
83
  function handleReferFriendButton(_$w,item) {
85
84
  if(!item.referFriendLink && isElementExistOnPage(_$w('#referFriendButton'))){
86
- console.log("hiding referFriendButton");
87
85
  _$w('#referFriendButton').hide();
88
86
  }
89
87
  }
90
88
 
91
89
  function handleApplyButton(_$w,item) {
90
+ try{
92
91
  _$w('#applyButton').target="_blank";//so it can open in new tab
93
- const url=appendQueryParams(item.applyLink,query);
94
- _$w('#applyButton').link=url; //so it can be clicked
92
+ const url=appendQueryParams(item.applyLink,query);
93
+ _$w('#applyButton').link=url; //so it can be clicked
94
+ }
95
+ catch(error){
96
+ console.warn("error in handleApplyButton: , using applyLink directly", error);
97
+ _$w('#applyButton').target="_blank";
98
+ _$w('#applyButton').link=item.applyLink;
99
+ }
95
100
  }
96
101
 
97
- async function getRelatedJobs(categoryValueId,itemId) {
98
- const relatedJobs=await wixData.query(COLLECTIONS.JOBS).include(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES).hasSome(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,[categoryValueId]).ne("_id",itemId).find();
102
+ async function getRelatedJobs(categoryValueId,itemId,limit=1000) {
103
+ const relatedJobs=await wixData.query(COLLECTIONS.JOBS).include(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES).hasSome(JOBS_COLLECTION_FIELDS.MULTI_REF_JOBS_CUSTOM_VALUES,[categoryValueId]).ne("_id",itemId).limit(limit).find();
99
104
  return relatedJobs.items;
100
105
  }
101
106
 
@@ -158,15 +158,16 @@ describe('primarySearch function tests', () => {
158
158
 
159
159
  await primarySearch(mockW, 'unicorn hunter',mockJobs);
160
160
 
161
+
161
162
  expect(mockprimarySearchMultiBox.changeState).toHaveBeenCalledWith('noResults');
162
163
  expect(mockprimarySearcJobResult.data).toBeNull();
163
164
  });
164
165
 
165
166
  it('should fill category repeater when clicking on empty primary search input', async () => {
166
167
  const mockCategoryValues = [
167
- { _id: 'cat1', title: 'Engineering', customField: CATEGORY_CUSTOM_FIELD_ID_IN_CMS, totalJobs: 5 },
168
- { _id: 'cat2', title: 'Marketing', customField: CATEGORY_CUSTOM_FIELD_ID_IN_CMS, totalJobs: 3 },
169
- { _id: 'cat3', title: 'Sales', customField: CATEGORY_CUSTOM_FIELD_ID_IN_CMS, totalJobs: 7 }
168
+ { _id: 'cat1', title: 'Engineering', customField: CATEGORY_CUSTOM_FIELD_ID_IN_CMS, count: 5 },
169
+ { _id: 'cat2', title: 'Marketing', customField: CATEGORY_CUSTOM_FIELD_ID_IN_CMS, count: 3 },
170
+ { _id: 'cat3', title: 'Sales', customField: CATEGORY_CUSTOM_FIELD_ID_IN_CMS, count: 7 }
170
171
  ];
171
172
 
172
173
  careersMultiBoxesPage.__set__('allvaluesobjects', mockCategoryValues);