sr-npm 1.2.31 → 1.2.33
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 +1 -1
- package/pages/careersMultiBoxesPage.js +6 -6
- package/pages/homePage.js +22 -28
- package/pages/pagesUtils.js +50 -47
- package/public/filterUtils.js +1 -1
package/package.json
CHANGED
|
@@ -119,10 +119,11 @@ async function handleUrlParams(_$w,urlParams) {
|
|
|
119
119
|
let currentApplyFilterFlag=false;
|
|
120
120
|
//apply this first to determine all jobs
|
|
121
121
|
if(urlParams.keyword) {
|
|
122
|
-
applyFiltering = await primarySearch(_$w, decodeURIComponent(urlParams.keyword)
|
|
122
|
+
applyFiltering = await primarySearch(_$w, decodeURIComponent(urlParams.keyword));
|
|
123
123
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value = decodeURIComponent(urlParams.keyword);
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
const data = _$w("#jobsDataset").getItems()?.items || [];
|
|
125
|
+
currentJobs = data;
|
|
126
|
+
keywordAllJobs = data;
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
for (const url of possibleUrlParams)
|
|
@@ -600,16 +601,15 @@ async function secondarySearch(_$w,query) {
|
|
|
600
601
|
await refreshFacetCounts(_$w);
|
|
601
602
|
return allsecondarySearchJobs;
|
|
602
603
|
}
|
|
603
|
-
|
|
604
|
+
function bindSearchInput(_$w) {
|
|
604
605
|
try {
|
|
605
|
-
bindPrimarySearch(_$w,allvaluesobjects
|
|
606
|
+
bindPrimarySearch(_$w, allvaluesobjects);
|
|
606
607
|
|
|
607
608
|
const secondarySearchDebounced = debounce(async () => {
|
|
608
609
|
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).value || '').toLowerCase().trim();
|
|
609
610
|
await secondarySearch(_$w, query);
|
|
610
611
|
}, 150);
|
|
611
612
|
|
|
612
|
-
|
|
613
613
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).onInput(secondarySearchDebounced);
|
|
614
614
|
|
|
615
615
|
} catch (error) {
|
package/pages/homePage.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
const {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} = require('../public/filterUtils');
|
|
5
|
-
const { handleOnLocationClick } = require('../public/mapUtils');
|
|
6
|
-
const { filterBrokenMarkers } = require('../public/utils');
|
|
1
|
+
const { debounce, getFilter } = require('../public/filterUtils');
|
|
2
|
+
const { handleOnLocationClick } = require('../public/mapUtils');
|
|
3
|
+
const { filterBrokenMarkers } = require('../public/utils');
|
|
7
4
|
const { location } = require('@wix/site-location');
|
|
8
5
|
const {wixData} = require('wix-data');
|
|
9
6
|
const { COLLECTIONS } = require('../backend/collectionConsts');
|
|
10
|
-
const { bindPrimarySearch,getAllRecords,loadPrimarySearchRepeater } = require('./pagesUtils');
|
|
7
|
+
const { bindPrimarySearch, getAllRecords, loadPrimarySearchRepeater } = require('./pagesUtils');
|
|
8
|
+
|
|
11
9
|
let thisObjectVar;
|
|
12
10
|
let searchByCityFlag=false;
|
|
13
11
|
let loadedCategories=false;
|
|
14
|
-
async function homePageOnReady(_$w,thisObject=null) {
|
|
15
12
|
|
|
13
|
+
async function homePageOnReady(_$w,thisObject = null) {
|
|
16
14
|
const queryResult = await wixData.query(COLLECTIONS.SITE_CONFIGS).find();
|
|
17
15
|
const siteconfig = queryResult.items[0];
|
|
16
|
+
|
|
18
17
|
if(siteconfig.twg) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
bindPrimarySearch(_$w,allvaluesobjects,allJobs);
|
|
18
|
+
const allvaluesobjects = await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
19
|
+
bindPrimarySearch(_$w, allvaluesobjects);
|
|
22
20
|
loadPrimarySearchRepeater(_$w)
|
|
23
21
|
console.log("siteconfig.twg: ",siteconfig.twg);
|
|
24
22
|
if(siteconfig.twg==="external") {
|
|
@@ -27,19 +25,16 @@ async function homePageOnReady(_$w,thisObject=null) {
|
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
27
|
else{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
await init(_$w);
|
|
28
|
+
thisObjectVar = thisObject;
|
|
29
|
+
bind(_$w);
|
|
30
|
+
init(_$w);
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
function bind(_$w) {
|
|
33
|
+
}
|
|
39
34
|
|
|
35
|
+
function bind(_$w) {
|
|
40
36
|
bindTeamRepeater(_$w);
|
|
41
37
|
|
|
42
|
-
|
|
43
38
|
_$w('#citiesDataset').onReady(async () => {
|
|
44
39
|
const numOfItems = await _$w('#citiesDataset').getTotalCount();
|
|
45
40
|
const items = await _$w('#citiesDataset').getItems(0, numOfItems);
|
|
@@ -53,8 +48,8 @@ async function homePageOnReady(_$w,thisObject=null) {
|
|
|
53
48
|
latitude: location.latitude,
|
|
54
49
|
longitude: location.longitude
|
|
55
50
|
},
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
address: item.locationAddress.formatted,
|
|
52
|
+
title: item.title,
|
|
58
53
|
link: cityLinkUrl,
|
|
59
54
|
linkTitle:`View ${item.count} Open Positions`
|
|
60
55
|
};
|
|
@@ -103,7 +98,6 @@ function bindTeamRepeater(_$w) {
|
|
|
103
98
|
}
|
|
104
99
|
|
|
105
100
|
function bindViewAllButton(_$w) {
|
|
106
|
-
|
|
107
101
|
_$w('#viewAllCategoriesButton').onClick(()=>{
|
|
108
102
|
if(!loadedCategories) {
|
|
109
103
|
loadedCategories=true;
|
|
@@ -122,11 +116,11 @@ function bindViewAllButton(_$w) {
|
|
|
122
116
|
|
|
123
117
|
|
|
124
118
|
function init(_$w) {
|
|
125
|
-
const debouncedInput = debounce(()=>handleSearchInput(_$w), 400,thisObjectVar);
|
|
119
|
+
const debouncedInput = debounce(() => handleSearchInput(_$w), 400, thisObjectVar);
|
|
126
120
|
|
|
127
121
|
_$w('#searchInput').onInput(debouncedInput);
|
|
128
122
|
_$w('#searchInput').maxLength = 40;
|
|
129
|
-
_$w('#searchButton').onClick(()=>handleSearch(_$w('#searchInput').value));
|
|
123
|
+
_$w('#searchButton').onClick(() => handleSearch(_$w('#searchInput').value));
|
|
130
124
|
|
|
131
125
|
_$w('#searchInput').onKeyPress((event) => {
|
|
132
126
|
if (event.key === 'Enter') {
|
|
@@ -171,17 +165,17 @@ async function handleSearchInput(_$w) {
|
|
|
171
165
|
count = _$w('#jobsDataset').getTotalCount();
|
|
172
166
|
|
|
173
167
|
if (count > 0) {
|
|
174
|
-
searchByCityFlag=false;
|
|
168
|
+
searchByCityFlag = false;
|
|
175
169
|
_$w('#resultsContainer').expand();
|
|
176
170
|
_$w('#searchMultiStateBox').changeState('results');
|
|
177
171
|
} else {
|
|
178
|
-
filter=await getFilter(searchByCity);
|
|
172
|
+
filter = await getFilter(searchByCity);
|
|
179
173
|
await _$w('#jobsDataset').setFilter(filter);
|
|
180
174
|
await _$w('#jobsDataset').refresh();
|
|
181
175
|
count = _$w('#jobsDataset').getTotalCount();
|
|
182
|
-
if(count > 0)
|
|
176
|
+
if( count > 0 )
|
|
183
177
|
{
|
|
184
|
-
searchByCityFlag=true;
|
|
178
|
+
searchByCityFlag = true;
|
|
185
179
|
_$w('#resultsContainer').expand();
|
|
186
180
|
_$w('#searchMultiStateBox').changeState('results');
|
|
187
181
|
}
|
package/pages/pagesUtils.js
CHANGED
|
@@ -3,6 +3,7 @@ const { JOBS_COLLECTION_FIELDS,COLLECTIONS } = require('../backend/collectionCon
|
|
|
3
3
|
const { CAREERS_MULTI_BOXES_PAGE_CONSTS,CATEGORY_CUSTOM_FIELD_ID_IN_CMS } = require('../backend/careersMultiBoxesPageIds');
|
|
4
4
|
const { location } = require("@wix/site-location");
|
|
5
5
|
const { normalizeString } = require('../backend/utils');
|
|
6
|
+
const { getFilter } = require('../public/filterUtils');
|
|
6
7
|
|
|
7
8
|
function groupValuesByField(values, refKey) {
|
|
8
9
|
const map = new Map();
|
|
@@ -83,19 +84,13 @@ function groupValuesByField(values, refKey) {
|
|
|
83
84
|
|
|
84
85
|
function loadPrimarySearchRepeater(_$w) {
|
|
85
86
|
|
|
86
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).onItemReady(async ($item, itemData) => {
|
|
87
|
-
if(!itemData.title) {
|
|
88
|
-
console.log("!!!!!!!!!!!! itemData has no title: ",itemData);
|
|
89
|
-
}
|
|
90
|
-
$item(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_POSITION_BUTTON).label = itemData.title || '';
|
|
91
|
-
});
|
|
92
|
-
|
|
93
87
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER_ITEM).onClick((event) => {
|
|
94
88
|
const data = _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data;
|
|
95
89
|
const clickedItemData = data.find(
|
|
96
90
|
(item) => item._id === event.context.itemId,
|
|
97
91
|
|
|
98
92
|
);
|
|
93
|
+
|
|
99
94
|
// 'link-jobs-title' or 'link-copy-of-jobs-title'
|
|
100
95
|
const linkKey = Object.keys(clickedItemData).find(
|
|
101
96
|
key => key.startsWith('link') && key.includes('jobs') && key.includes('title')
|
|
@@ -124,21 +119,24 @@ function loadPrimarySearchRepeater(_$w) {
|
|
|
124
119
|
|
|
125
120
|
}
|
|
126
121
|
|
|
127
|
-
|
|
122
|
+
function bindPrimarySearch(_$w, allvaluesobjects) {
|
|
128
123
|
|
|
129
|
-
const
|
|
130
|
-
const query =
|
|
131
|
-
await primarySearch(_$w, query
|
|
132
|
-
}
|
|
124
|
+
const handleSearchInput = async () => {
|
|
125
|
+
const query = _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value?.toLowerCase().trim() || '';
|
|
126
|
+
await primarySearch(_$w, query);
|
|
127
|
+
}
|
|
133
128
|
|
|
134
|
-
|
|
129
|
+
const primarySearchDebounced = debounce(() => handleSearchInput(), 400);
|
|
130
|
+
|
|
131
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onInput(async () => {
|
|
135
132
|
await primarySearchDebounced();
|
|
136
133
|
});
|
|
137
134
|
|
|
138
135
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onClick(async () => {
|
|
139
136
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
|
|
140
137
|
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()!=='') {
|
|
141
|
-
|
|
138
|
+
const query = _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value?.toLowerCase().trim() || '';
|
|
139
|
+
await primarySearch(_$w, query);
|
|
142
140
|
}
|
|
143
141
|
else {
|
|
144
142
|
await loadCategoriesListPrimarySearch(_$w,allvaluesobjects);
|
|
@@ -162,30 +160,29 @@ _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).onKeyPress(async (even
|
|
|
162
160
|
else {
|
|
163
161
|
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
164
162
|
const baseUrl = await location.baseUrl();
|
|
165
|
-
|
|
163
|
+
location.to(`${baseUrl}/search?keyword=${encodedKeyWord}`);
|
|
166
164
|
}
|
|
167
165
|
}
|
|
168
166
|
});
|
|
169
167
|
|
|
170
168
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_BUTTON).onClick(async () => {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
|
|
169
|
+
console.log("primary search button clicked");
|
|
170
|
+
console.log("_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value: ",_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
171
|
+
if(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value.trim()==='') {
|
|
172
|
+
const baseUrl = await location.baseUrl();
|
|
173
|
+
location.to(`${baseUrl}/search`);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
let encodedKeyWord=encodeURIComponent(_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value);
|
|
177
|
+
const baseUrl = await location.baseUrl();
|
|
178
|
+
location.to(`${baseUrl}/search?keyword=${encodedKeyWord}`);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
185
181
|
}
|
|
186
182
|
|
|
187
183
|
async function loadCategoriesListPrimarySearch(_$w,allvaluesobjects) {
|
|
188
184
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("categoryResults");
|
|
185
|
+
|
|
189
186
|
let categoryValues=[]
|
|
190
187
|
for(const value of allvaluesobjects) {
|
|
191
188
|
if(value.customField===CATEGORY_CUSTOM_FIELD_ID_IN_CMS) {
|
|
@@ -195,39 +192,45 @@ async function loadCategoriesListPrimarySearch(_$w,allvaluesobjects) {
|
|
|
195
192
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CATEGORY_RESULTS_REPEATER).data = categoryValues;
|
|
196
193
|
}
|
|
197
194
|
|
|
198
|
-
async function primarySearch(_$w,query
|
|
199
|
-
if(query
|
|
195
|
+
async function primarySearch(_$w, query) {
|
|
196
|
+
if(query === undefined || query === '') {
|
|
200
197
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("categoryResults");
|
|
201
198
|
return false;
|
|
202
199
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
|
|
201
|
+
const searchByTitle = [{field: 'title', searchTerm: query}];
|
|
202
|
+
const searchByCity = [{field: 'location.fullLocation', searchTerm: query}];
|
|
203
|
+
|
|
204
|
+
let filter = await getFilter(searchByTitle);
|
|
205
|
+
|
|
206
|
+
await _$w('#jobsDataset').setFilter(filter);
|
|
207
|
+
await _$w('#jobsDataset').refresh();
|
|
208
|
+
|
|
209
|
+
let count = _$w('#jobsDataset').getTotalCount();
|
|
210
|
+
|
|
211
|
+
if( count > 0 ) {
|
|
212
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
|
|
207
213
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("jobResults");
|
|
208
214
|
}
|
|
209
215
|
else {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
216
|
+
filter = await getFilter(searchByCity);
|
|
217
|
+
await _$w('#jobsDataset').setFilter(filter);
|
|
218
|
+
await _$w('#jobsDataset').refresh();
|
|
219
|
+
|
|
220
|
+
count = _$w('#jobsDataset').getTotalCount();
|
|
221
|
+
if (count > 0) {
|
|
222
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
|
|
213
223
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("jobResults");
|
|
214
224
|
}
|
|
215
225
|
else{
|
|
216
|
-
console.log('filteredJobs is empty');
|
|
217
226
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState("noResults");
|
|
218
227
|
}
|
|
219
228
|
}
|
|
220
|
-
|
|
221
|
-
console.log("filteredJobs: ",filteredJobs);
|
|
222
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOB_RESULTS_REPEATER).data = filteredJobs
|
|
223
|
-
return filteredJobs.length>0;
|
|
224
229
|
}
|
|
225
230
|
|
|
226
231
|
async function getValueFromValueId(valueId) {
|
|
227
|
-
const result=await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
228
|
-
|
|
229
|
-
console.log("valueId: ",valueId);
|
|
230
|
-
return result.find(value=>value._id===valueId);
|
|
232
|
+
const result = await getAllRecords(COLLECTIONS.CUSTOM_VALUES);
|
|
233
|
+
return result.find(value => value._id === valueId);
|
|
231
234
|
|
|
232
235
|
}
|
|
233
236
|
|
package/public/filterUtils.js
CHANGED