sr-npm 1.2.76 → 1.2.81
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/backend/careersMultiBoxesPageIds.js +7 -0
- package/backend/fetchPositionsFromSRAPI.js +175 -1
- package/package.json +1 -1
- package/pages/careersMultiBoxesPage.js +42 -22
- package/pages/careersPage.js +19 -20
- package/pages/homePage.js +12 -23
- package/pages/positionPage.js +8 -4
- package/public/primarySearchUtils.js +17 -15
- package/public/selectors.js +6 -2
|
@@ -34,6 +34,12 @@ const CAREERS_MULTI_BOXES_PAGE_CONSTS={
|
|
|
34
34
|
RESULTS_MULTI_STATE_BOX: '#multiStateBox1',
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
const PRIMARY_SEARCH_STATES={
|
|
38
|
+
CATEGORY_RESULTS: 'categoryResults',
|
|
39
|
+
JOB_RESULTS: 'jobResults',
|
|
40
|
+
NO_RESULTS: 'noResults',
|
|
41
|
+
}
|
|
42
|
+
|
|
37
43
|
const TWG_JOBS_COLLECTION_FIELDS={
|
|
38
44
|
LINK_JOBS_TITLE: 'link-jobs-title',
|
|
39
45
|
LINK_JOBS_REF_ID_SLUG: 'link-jobs-refId-slug',
|
|
@@ -82,4 +88,5 @@ module.exports = {
|
|
|
82
88
|
CATEGORY_CUSTOM_FIELD_ID_IN_CMS,
|
|
83
89
|
possibleUrlParams,
|
|
84
90
|
TWG_JOBS_COLLECTION_FIELDS,
|
|
91
|
+
PRIMARY_SEARCH_STATES,
|
|
85
92
|
}
|
|
@@ -115,6 +115,7 @@ async function fetchJobDescription(jobId,testObject=undefined) {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
async function htmlRichContentConverter(sections,richContentConverterToken) {
|
|
118
|
+
|
|
118
119
|
const richContentObject = {}
|
|
119
120
|
for (const [sectionTitle, sectionData] of Object.entries(sections)) {
|
|
120
121
|
if (sectionData.text) {
|
|
@@ -136,7 +137,8 @@ async function htmlRichContentConverter(sections,richContentConverterToken) {
|
|
|
136
137
|
);
|
|
137
138
|
if (response.ok) {
|
|
138
139
|
const data = await response.json();
|
|
139
|
-
|
|
140
|
+
const richContentWithSpacing=addSpacingToRichContent(sectionData.text,data.richContent.richContent);
|
|
141
|
+
richContentObject[sectionTitle] = richContentWithSpacing
|
|
140
142
|
}
|
|
141
143
|
else {
|
|
142
144
|
throw new Error("Error converting html to rich content response: "+response);
|
|
@@ -146,6 +148,178 @@ async function htmlRichContentConverter(sections,richContentConverterToken) {
|
|
|
146
148
|
return richContentObject;
|
|
147
149
|
}
|
|
148
150
|
|
|
151
|
+
//Adds empty paragraph nodes between sections in rich content
|
|
152
|
+
// to create visual spacing that the Wix RICOS converter strips out
|
|
153
|
+
function addSpacingToRichContent(html, richContent) {
|
|
154
|
+
if (!richContent || !richContent.nodes) {
|
|
155
|
+
return richContent;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Extract paragraph texts from HTML that end with  
|
|
159
|
+
const htmlParagraphsWithSpace = [];
|
|
160
|
+
// Extract paragraphs with <br> tags
|
|
161
|
+
const htmlParagraphsWithBr = new Map(); // text -> array of parts split by <br>
|
|
162
|
+
|
|
163
|
+
const pTagRegex = /<p>(.*?)<\/p>/gi;
|
|
164
|
+
let match;
|
|
165
|
+
|
|
166
|
+
while ((match = pTagRegex.exec(html)) !== null) {
|
|
167
|
+
const content = match[1];
|
|
168
|
+
|
|
169
|
+
// Check if this paragraph ends with   (before closing tags)
|
|
170
|
+
if (content.includes(' ')) {
|
|
171
|
+
const textOnly = content.replace(/<[^>]+>/g, '').trim();
|
|
172
|
+
htmlParagraphsWithSpace.push(textOnly);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Check if this paragraph contains <br> tags
|
|
176
|
+
if (content.includes('<br>') || content.includes('<br/>') || content.includes('<br />')) {
|
|
177
|
+
// Split by <br> tags and extract text parts
|
|
178
|
+
const parts = content.split(/<br\s*\/?>/i).map(part =>
|
|
179
|
+
part.replace(/<[^>]+>/g, '').trim()
|
|
180
|
+
).filter(part => part.length > 0);
|
|
181
|
+
|
|
182
|
+
if (parts.length > 1) {
|
|
183
|
+
// Store the parts for this paragraph
|
|
184
|
+
const fullText = content.replace(/<[^>]+>/g, '').replace(/\s+/g, '').trim();
|
|
185
|
+
htmlParagraphsWithBr.set(fullText, parts);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const nodes = richContent.nodes;
|
|
191
|
+
const newNodes = [];
|
|
192
|
+
let nodeIdCounter = 0;
|
|
193
|
+
|
|
194
|
+
// Check if a paragraph is bold (has BOLD decoration)
|
|
195
|
+
const isBoldParagraph = (node) => {
|
|
196
|
+
if (node.type !== 'PARAGRAPH') return false;
|
|
197
|
+
const decorations = node.nodes?.[0]?.textData?.decorations || [];
|
|
198
|
+
return decorations.some(d => d.type === 'BOLD');
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// Check if a paragraph node's text matches one with   in HTML
|
|
202
|
+
const needsSpacingAfter = (node) => {
|
|
203
|
+
if (node.type !== 'PARAGRAPH') return false;
|
|
204
|
+
|
|
205
|
+
// Add spacing after bold paragraphs
|
|
206
|
+
if (isBoldParagraph(node)) {
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const text = node.nodes?.[0]?.textData?.text || '';
|
|
211
|
+
const trimmedText = text.trim();
|
|
212
|
+
|
|
213
|
+
// Check if this text matches any HTML paragraph that had  
|
|
214
|
+
return htmlParagraphsWithSpace.some(htmlText => {
|
|
215
|
+
const cleanHtml = htmlText.replace(/ /g, ' ').trim();
|
|
216
|
+
return trimmedText.includes(cleanHtml) || cleanHtml.includes(trimmedText);
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// Check if a paragraph contains text that should be split by <br>
|
|
221
|
+
const shouldSplitByBr = (node) => {
|
|
222
|
+
if (node.type !== 'PARAGRAPH') return null;
|
|
223
|
+
|
|
224
|
+
const text = node.nodes?.[0]?.textData?.text || '';
|
|
225
|
+
const normalizedText = text.replace(/\s+/g, '').trim();
|
|
226
|
+
|
|
227
|
+
// Find matching HTML paragraph with <br>
|
|
228
|
+
for (const [htmlText, parts] of htmlParagraphsWithBr.entries()) {
|
|
229
|
+
if (normalizedText.includes(htmlText) || htmlText.includes(normalizedText)) {
|
|
230
|
+
return parts;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return null;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// Add spacing after bulleted lists
|
|
237
|
+
const isListEnd = (currentNode, nextNode) => {
|
|
238
|
+
return currentNode.type === 'BULLETED_LIST' &&
|
|
239
|
+
nextNode &&
|
|
240
|
+
nextNode.type === 'PARAGRAPH';
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
244
|
+
const currentNode = nodes[i];
|
|
245
|
+
const nextNode = nodes[i + 1];
|
|
246
|
+
|
|
247
|
+
// Check if this paragraph should be split by <br>
|
|
248
|
+
const brParts = shouldSplitByBr(currentNode);
|
|
249
|
+
if (brParts && brParts.length > 1) {
|
|
250
|
+
// Split into multiple paragraphs and add spacing between them
|
|
251
|
+
const decorations = currentNode.nodes?.[0]?.textData?.decorations || [];
|
|
252
|
+
|
|
253
|
+
brParts.forEach((part, idx) => {
|
|
254
|
+
newNodes.push({
|
|
255
|
+
...currentNode,
|
|
256
|
+
id: `${currentNode.id}_split_${idx}`,
|
|
257
|
+
nodes: [{
|
|
258
|
+
type: "TEXT",
|
|
259
|
+
id: "",
|
|
260
|
+
nodes: [],
|
|
261
|
+
textData: {
|
|
262
|
+
text: part,
|
|
263
|
+
decorations: decorations
|
|
264
|
+
}
|
|
265
|
+
}]
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// Add empty paragraph after each split part except the last
|
|
269
|
+
if (idx < brParts.length - 1) {
|
|
270
|
+
newNodes.push(createEmptyParagraph(`empty_br_${nodeIdCounter++}`));
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// Add spacing after the split paragraphs if there's a next node
|
|
275
|
+
if (nextNode) {
|
|
276
|
+
newNodes.push(createEmptyParagraph(`empty_${nodeIdCounter++}`));
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
newNodes.push(currentNode);
|
|
280
|
+
|
|
281
|
+
// Add empty paragraph ONLY after paragraphs with   or after lists
|
|
282
|
+
if ((needsSpacingAfter(currentNode) || isListEnd(currentNode, nextNode)) && nextNode) {
|
|
283
|
+
newNodes.push(createEmptyParagraph(`empty_${nodeIdCounter++}`));
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return {
|
|
289
|
+
...richContent,
|
|
290
|
+
nodes: newNodes
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function createEmptyParagraph(id) {
|
|
295
|
+
return {
|
|
296
|
+
type: "PARAGRAPH",
|
|
297
|
+
id: id,
|
|
298
|
+
nodes: [
|
|
299
|
+
{
|
|
300
|
+
type: "TEXT",
|
|
301
|
+
id: "",
|
|
302
|
+
nodes: [],
|
|
303
|
+
textData: {
|
|
304
|
+
text: "",
|
|
305
|
+
decorations: []
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
],
|
|
309
|
+
paragraphData: {
|
|
310
|
+
textStyle: {
|
|
311
|
+
textAlignment: "AUTO"
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
149
323
|
|
|
150
324
|
|
|
151
325
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { COLLECTIONS,CUSTOM_VALUES_COLLECTION_FIELDS,JOBS_COLLECTION_FIELDS } = require('../backend/collectionConsts');
|
|
2
|
-
const { CAREERS_PAGE_SELECTORS } = require('../public/selectors');
|
|
2
|
+
const { CAREERS_PAGE_SELECTORS, GLOBAL_SECTIONS_SELECTORS } = require('../public/selectors');
|
|
3
3
|
|
|
4
4
|
const { window } = require('@wix/site-window');
|
|
5
5
|
const { queryParams,onChange} = require('wix-location-frontend');
|
|
@@ -44,24 +44,25 @@ const pagination = {
|
|
|
44
44
|
|
|
45
45
|
async function careersMultiBoxesPageOnReady(_$w,urlParams) {
|
|
46
46
|
//to handle back and forth , url changes
|
|
47
|
-
onChange(async ()=>{
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
await loadData(_$w);
|
|
51
|
-
await loadJobsRepeater(_$w); // if we remove the await here the job list will be flaky , it doesn't fill it properly
|
|
52
|
-
handlePrimarySearch(_$w, allvaluesobjects);
|
|
53
|
-
await loadFilters(_$w);
|
|
54
|
-
loadSelectedValuesRepeater(_$w);
|
|
55
|
-
bindSearchInput(_$w);
|
|
56
|
-
loadPaginationButtons(_$w);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
47
|
+
// onChange(async ()=>{
|
|
48
|
+
// await handleBackAndForth(_$w);
|
|
49
|
+
// });
|
|
50
|
+
// await loadData(_$w);
|
|
51
|
+
// await loadJobsRepeater(_$w); // if we remove the await here the job list will be flaky , it doesn't fill it properly
|
|
52
|
+
// handlePrimarySearch(_$w, allvaluesobjects);
|
|
53
|
+
// await loadFilters(_$w);
|
|
54
|
+
// loadSelectedValuesRepeater(_$w);
|
|
55
|
+
// bindSearchInput(_$w);
|
|
56
|
+
// loadPaginationButtons(_$w);
|
|
57
|
+
|
|
58
|
+
// await handleUrlParams(_$w, urlParams);
|
|
59
|
+
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CLEAR_ALL_BUTTON_ID).onClick(async () => {
|
|
60
|
+
// await clearAll(_$w);
|
|
61
|
+
// });
|
|
62
|
+
// if (await window.formFactor() === "Mobile") {
|
|
63
|
+
// handleFilterInMobile(_$w);
|
|
64
|
+
// }
|
|
65
|
+
// _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_MULTI_STATE_BOX).changeState("results");
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
async function handleBackAndForth(_$w){
|
|
@@ -113,16 +114,26 @@ function handleFilterInMobile(_$w) {
|
|
|
113
114
|
CAREERS_PAGE_SELECTORS.SECTION_3,
|
|
114
115
|
CAREERS_PAGE_SELECTORS.LINE_3,
|
|
115
116
|
CAREERS_PAGE_SELECTORS.FILTER_ICON];
|
|
117
|
+
|
|
118
|
+
const mobileFilterBoxSelectors = [
|
|
119
|
+
CAREERS_PAGE_SELECTORS.FILTER_BOX,
|
|
120
|
+
CAREERS_PAGE_SELECTORS.REFINE_SEARCH_BUTTON,
|
|
121
|
+
CAREERS_PAGE_SELECTORS.EXIT_BUTTON,
|
|
122
|
+
];
|
|
116
123
|
|
|
117
124
|
_$w(CAREERS_PAGE_SELECTORS.FILTER_ICON).onClick(()=>{
|
|
118
|
-
|
|
125
|
+
mobileFilterBoxSelectors.forEach(selector => {
|
|
126
|
+
_$w(selector).expand();
|
|
127
|
+
});
|
|
119
128
|
searchResultsSelectors.forEach(selector => {
|
|
120
129
|
_$w(selector).collapse();
|
|
121
130
|
});
|
|
122
131
|
});
|
|
123
132
|
|
|
124
133
|
const exitFilterBox = () => {
|
|
125
|
-
|
|
134
|
+
mobileFilterBoxSelectors.forEach(selector => {
|
|
135
|
+
_$w(selector).collapse();
|
|
136
|
+
});
|
|
126
137
|
searchResultsSelectors.forEach(selector => {
|
|
127
138
|
_$w(selector).expand();
|
|
128
139
|
});
|
|
@@ -135,6 +146,11 @@ function handleFilterInMobile(_$w) {
|
|
|
135
146
|
_$w(CAREERS_PAGE_SELECTORS.REFINE_SEARCH_BUTTON).onClick(()=>{
|
|
136
147
|
exitFilterBox();
|
|
137
148
|
});
|
|
149
|
+
|
|
150
|
+
//onmobile we should collapse the filter box and the refine search button by default
|
|
151
|
+
mobileFilterBoxSelectors.forEach(selector => {
|
|
152
|
+
_$w(selector).collapse();
|
|
153
|
+
});
|
|
138
154
|
}
|
|
139
155
|
|
|
140
156
|
|
|
@@ -147,7 +163,7 @@ async function handleUrlParams(_$w,urlParams,handleBackAndForth=false) {
|
|
|
147
163
|
applyFiltering = await queryPrimarySearchResults(_$w, decodeURIComponent(urlParams.keyword));
|
|
148
164
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).value = decodeURIComponent(urlParams.keyword);
|
|
149
165
|
|
|
150
|
-
const items = await getAllDatasetItems(_$w,
|
|
166
|
+
const items = await getAllDatasetItems(_$w, GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET);
|
|
151
167
|
|
|
152
168
|
currentJobs = items;
|
|
153
169
|
keywordAllJobs = items;
|
|
@@ -237,6 +253,7 @@ async function handleParams(_$w,param,values) {
|
|
|
237
253
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationCurrentText).text = pagination.currentPage.toString();
|
|
238
254
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = nextPageJobs;
|
|
239
255
|
handlePaginationButtons(_$w);
|
|
256
|
+
await _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).scrollTo();
|
|
240
257
|
});
|
|
241
258
|
|
|
242
259
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_PREVIOUS).onClick(async () => {
|
|
@@ -245,6 +262,7 @@ async function handleParams(_$w,param,values) {
|
|
|
245
262
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationCurrentText).text = pagination.currentPage.toString();
|
|
246
263
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = previousPageJobs;
|
|
247
264
|
handlePaginationButtons(_$w);
|
|
265
|
+
await _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).scrollTo();
|
|
248
266
|
});
|
|
249
267
|
} catch (error) {
|
|
250
268
|
console.error('Failed to load pagination buttons:', error);
|
|
@@ -466,6 +484,8 @@ function getValueFromValueId(valueIds, value) {
|
|
|
466
484
|
? withCounts.filter(o => (o.label || '').toLowerCase().includes(searchQuery))
|
|
467
485
|
: withCounts;
|
|
468
486
|
|
|
487
|
+
// Sort alphabetically by label
|
|
488
|
+
filtered.sort((a, b) => (a.label || '').localeCompare(b.label || ''));
|
|
469
489
|
// Preserve currently selected values that are still visible
|
|
470
490
|
// let prevSelected=[]
|
|
471
491
|
// clearAll? prevSelected=[]:prevSelected= _$w(`#${FiltersIds[fieldTitle]}CheckBox`).value;
|
package/pages/careersPage.js
CHANGED
|
@@ -6,7 +6,7 @@ const { location } = require("@wix/site-location");
|
|
|
6
6
|
const { COLLECTIONS } = require('../backend/collectionConsts');
|
|
7
7
|
const { careersMultiBoxesPageOnReady } = require('./careersMultiBoxesPage');
|
|
8
8
|
const { debounce, getFilter} = require('../public/filterUtils');
|
|
9
|
-
const { CAREERS_PAGE_SELECTORS, FILTER_FIELDS } = require('../public/selectors');
|
|
9
|
+
const { CAREERS_PAGE_SELECTORS, FILTER_FIELDS, GLOBAL_SECTIONS_SELECTORS } = require('../public/selectors');
|
|
10
10
|
const { filterBrokenMarkers } = require('../public/utils');
|
|
11
11
|
|
|
12
12
|
let currentLoadedItems =100;
|
|
@@ -58,10 +58,10 @@ async function careersPageOnReady(_$w,thisObject=null,queryParams=null) {
|
|
|
58
58
|
|
|
59
59
|
function activateAutoLoad(_$w)
|
|
60
60
|
{
|
|
61
|
-
_$w(
|
|
61
|
+
_$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).onReady(() => {
|
|
62
62
|
updateCount(_$w);
|
|
63
63
|
_$w(CAREERS_PAGE_SELECTORS.FOOTER).onViewportEnter(() => {
|
|
64
|
-
if (currentLoadedItems<_$w(
|
|
64
|
+
if (currentLoadedItems<_$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getTotalCount()) {
|
|
65
65
|
loadMoreJobs(_$w);
|
|
66
66
|
}
|
|
67
67
|
else {
|
|
@@ -81,7 +81,7 @@ async function loadMoreJobs(_$w) {
|
|
|
81
81
|
pageParamSet = Number(pageParamSet) + 1;
|
|
82
82
|
}
|
|
83
83
|
if (shouldLoad) {
|
|
84
|
-
_$w(
|
|
84
|
+
_$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).loadMore();
|
|
85
85
|
console.log("loading more jobs");
|
|
86
86
|
|
|
87
87
|
currentLoadedItems = currentLoadedItems + itemsPerPage;
|
|
@@ -148,7 +148,7 @@ async function handlePageParam(_$w) {
|
|
|
148
148
|
//scrolls a bit to load the dataset data
|
|
149
149
|
await window.scrollTo(0, 200,{scrollAnimation:false});
|
|
150
150
|
for (let i = 2; i <= queryPageVar; i++) {
|
|
151
|
-
await _$w(
|
|
151
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).loadMore();
|
|
152
152
|
currentLoadedItems=currentLoadedItems+itemsPerPage
|
|
153
153
|
}
|
|
154
154
|
// the timeout is to wait for the repeater to render, then scroll to the last item.
|
|
@@ -170,7 +170,7 @@ async function handlePageParam(_$w) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
async function bind(_$w) {
|
|
173
|
-
await _$w(
|
|
173
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).onReady(async () => {
|
|
174
174
|
await updateCount(_$w);
|
|
175
175
|
await updateMapMarkers(_$w);
|
|
176
176
|
|
|
@@ -192,18 +192,18 @@ function init(_$w) {
|
|
|
192
192
|
searchInputBlurredFirstTime=false;
|
|
193
193
|
}
|
|
194
194
|
});
|
|
195
|
-
_$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT, CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION, CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE, CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).onChange(()=>{
|
|
195
|
+
_$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT+', '+ CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION+', '+ CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE+', '+ CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).onChange(()=>{
|
|
196
196
|
console.log("dropdown onChange is triggered");
|
|
197
197
|
applyFilters(_$w);
|
|
198
198
|
});
|
|
199
|
-
_$w(CAREERS_PAGE_SELECTORS.RESET_FILTERS_BUTTON, CAREERS_PAGE_SELECTORS.CLEAR_SEARCH).onClick(()=>resetFilters(_$w));
|
|
199
|
+
_$w(CAREERS_PAGE_SELECTORS.RESET_FILTERS_BUTTON+', '+ CAREERS_PAGE_SELECTORS.CLEAR_SEARCH).onClick(()=>resetFilters(_$w));
|
|
200
200
|
|
|
201
201
|
_$w(CAREERS_PAGE_SELECTORS.OPEN_FILTERS_BUTTON).onClick(()=>{
|
|
202
|
-
_$w(CAREERS_PAGE_SELECTORS.DROPDOWN_CONTAINER, CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).expand();
|
|
202
|
+
_$w(CAREERS_PAGE_SELECTORS.DROPDOWN_CONTAINER+', '+ CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).expand();
|
|
203
203
|
});
|
|
204
204
|
|
|
205
205
|
_$w(CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).onClick(()=>{
|
|
206
|
-
_$w(CAREERS_PAGE_SELECTORS.DROPDOWN_CONTAINER, CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).collapse();
|
|
206
|
+
_$w(CAREERS_PAGE_SELECTORS.DROPDOWN_CONTAINER+', '+ CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).collapse();
|
|
207
207
|
});
|
|
208
208
|
|
|
209
209
|
//URL onChange
|
|
@@ -337,8 +337,8 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
|
|
|
337
337
|
});
|
|
338
338
|
|
|
339
339
|
const filter = await getFilter(filters, 'and');
|
|
340
|
-
await _$w(
|
|
341
|
-
await _$w(
|
|
340
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).setFilter(filter);
|
|
341
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).refresh();
|
|
342
342
|
|
|
343
343
|
const count = await updateCount(_$w);
|
|
344
344
|
console.log("updating map markers");
|
|
@@ -355,10 +355,10 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
|
|
|
355
355
|
}
|
|
356
356
|
|
|
357
357
|
async function resetFilters(_$w) {
|
|
358
|
-
_$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT, CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT, CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION, CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE, CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).value = '';
|
|
358
|
+
_$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT+', '+ CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT+', '+ CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION+', '+ CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE+', '+ CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).value = '';
|
|
359
359
|
|
|
360
|
-
await _$w(
|
|
361
|
-
await _$w(
|
|
360
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).setFilter(wixData.filter());
|
|
361
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).refresh();
|
|
362
362
|
|
|
363
363
|
_$w(CAREERS_PAGE_SELECTORS.RESULTS_MULTI_STATE).changeState('results');
|
|
364
364
|
|
|
@@ -374,7 +374,7 @@ async function resetFilters(_$w) {
|
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
async function updateCount(_$w) {
|
|
377
|
-
const count = await _$w(
|
|
377
|
+
const count = await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getTotalCount();
|
|
378
378
|
_$w('#numOfPositionText').text = `Showing ${count} Open Positions`;
|
|
379
379
|
|
|
380
380
|
return count;
|
|
@@ -404,8 +404,7 @@ async function handleDepartmentParam(_$w,department) {
|
|
|
404
404
|
queryParams.remove(["department" ]);
|
|
405
405
|
|
|
406
406
|
}
|
|
407
|
-
|
|
408
|
-
|
|
407
|
+
|
|
409
408
|
|
|
410
409
|
}
|
|
411
410
|
|
|
@@ -485,8 +484,8 @@ async function handleJobTypeParam(_$w,jobType) {
|
|
|
485
484
|
}
|
|
486
485
|
|
|
487
486
|
async function updateMapMarkers(_$w){
|
|
488
|
-
const numOfItems = await _$w(
|
|
489
|
-
const items = await _$w(
|
|
487
|
+
const numOfItems = await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getTotalCount();
|
|
488
|
+
const items = await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getItems(0, numOfItems);
|
|
490
489
|
const markers = filterBrokenMarkers(items.items).map(item => {
|
|
491
490
|
const location = item.locationAddress.location;
|
|
492
491
|
return {
|
package/pages/homePage.js
CHANGED
|
@@ -6,6 +6,8 @@ const {wixData} = require('wix-data');
|
|
|
6
6
|
const { COLLECTIONS } = require('../backend/collectionConsts');
|
|
7
7
|
const { getAllRecords } = require('./pagesUtils');
|
|
8
8
|
const { handlePrimarySearch } = require('../public/primarySearchUtils');
|
|
9
|
+
const { GLOBAL_SECTIONS_SELECTORS } = require('../public/selectors');
|
|
10
|
+
const { isElementExistOnPage } = require('psdev-utils');
|
|
9
11
|
|
|
10
12
|
let thisObjectVar;
|
|
11
13
|
let searchByCityFlag=false;
|
|
@@ -64,35 +66,22 @@ function bind(_$w) {
|
|
|
64
66
|
function bindTeamRepeater(_$w) {
|
|
65
67
|
_$w('#teamRepeater').onItemReady(($item, itemData) => {
|
|
66
68
|
$item('#teamButton').label = `View ${itemData.count} Open Positions`;
|
|
67
|
-
// const department = encodeURIComponent(itemData.title);
|
|
68
|
-
// if (itemData.customField) {
|
|
69
|
-
// [$item('#teamButton'), $item('#teamButton2')].forEach(btn => {
|
|
70
|
-
// btn.onClick(() => {
|
|
71
|
-
// location.to(`/search?category=${department}`);
|
|
72
|
-
// });
|
|
73
|
-
// });
|
|
74
|
-
|
|
75
|
-
// }
|
|
76
|
-
// else{
|
|
77
|
-
// $item('#teamButton').onClick(()=>{
|
|
78
|
-
// location.to(`/positions?department=${department}`);
|
|
79
|
-
// });
|
|
80
|
-
// }
|
|
81
69
|
});
|
|
82
70
|
|
|
83
71
|
_$w("#teamRepeaterItem").onClick((event) => {
|
|
84
72
|
|
|
85
73
|
const $item = _$w.at(event.context);
|
|
86
74
|
|
|
87
|
-
if(_$w("#categoriesDataset")) {
|
|
75
|
+
if(isElementExistOnPage(_$w("#categoriesDataset"))) {
|
|
88
76
|
const clickedItemData = $item("#categoriesDataset").getCurrentItem();
|
|
89
77
|
const department = encodeURIComponent(clickedItemData.title);
|
|
90
78
|
location.to(`/search?category=${department}`);
|
|
91
79
|
}
|
|
92
80
|
else
|
|
93
81
|
{
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
const clickedItemData = $item("#dataset1").getCurrentItem()
|
|
83
|
+
const department = encodeURIComponent(clickedItemData.title);
|
|
84
|
+
location.to(`/positions?department=${department}`);
|
|
96
85
|
}
|
|
97
86
|
});
|
|
98
87
|
|
|
@@ -161,10 +150,10 @@ async function handleSearchInput(_$w) {
|
|
|
161
150
|
|
|
162
151
|
let filter = await getFilter(searchByTitle);
|
|
163
152
|
|
|
164
|
-
await _$w(
|
|
165
|
-
await _$w(
|
|
153
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).setFilter(filter);
|
|
154
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).refresh();
|
|
166
155
|
|
|
167
|
-
count = _$w(
|
|
156
|
+
count = _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getTotalCount();
|
|
168
157
|
|
|
169
158
|
if (count > 0) {
|
|
170
159
|
searchByCityFlag = false;
|
|
@@ -172,9 +161,9 @@ async function handleSearchInput(_$w) {
|
|
|
172
161
|
_$w('#searchMultiStateBox').changeState('results');
|
|
173
162
|
} else {
|
|
174
163
|
filter = await getFilter(searchByCity);
|
|
175
|
-
await _$w(
|
|
176
|
-
await _$w(
|
|
177
|
-
count = _$w(
|
|
164
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).setFilter(filter);
|
|
165
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).refresh();
|
|
166
|
+
count = _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getTotalCount();
|
|
178
167
|
if( count > 0 )
|
|
179
168
|
{
|
|
180
169
|
searchByCityFlag = true;
|
package/pages/positionPage.js
CHANGED
|
@@ -10,8 +10,6 @@ const {
|
|
|
10
10
|
} = require('../public/utils');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
13
|
async function positionPageOnReady(_$w) {
|
|
16
14
|
console.log("positionPageOnReady called");
|
|
17
15
|
await bind(_$w);
|
|
@@ -90,8 +88,14 @@ async function getCategoryValue(customValues) {
|
|
|
90
88
|
}
|
|
91
89
|
|
|
92
90
|
function handleReferFriendButton(_$w,item) {
|
|
93
|
-
if(
|
|
94
|
-
|
|
91
|
+
if(isElementExistOnPage(_$w('#referFriendButton'))){
|
|
92
|
+
if(!item.referFriendLink){
|
|
93
|
+
_$w('#referFriendButton').hide();
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
_$w('#referFriendButton').target="_blank";
|
|
97
|
+
_$w('#referFriendButton').link=item.referFriendLink;
|
|
98
|
+
}
|
|
95
99
|
}
|
|
96
100
|
}
|
|
97
101
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { location } = require("@wix/site-location");
|
|
2
2
|
|
|
3
|
-
const { CAREERS_MULTI_BOXES_PAGE_CONSTS, CATEGORY_CUSTOM_FIELD_ID_IN_CMS } = require('../backend/careersMultiBoxesPageIds');
|
|
3
|
+
const { CAREERS_MULTI_BOXES_PAGE_CONSTS, CATEGORY_CUSTOM_FIELD_ID_IN_CMS, PRIMARY_SEARCH_STATES } = require('../backend/careersMultiBoxesPageIds');
|
|
4
|
+
const { GLOBAL_SECTIONS_SELECTORS } = require('../public/selectors');
|
|
4
5
|
const { getFilter } = require('../public/filterUtils');
|
|
5
6
|
const { debounce } = require('../pages/pagesUtils');
|
|
6
7
|
|
|
@@ -9,7 +10,7 @@ async function handlePrimarySearch(_$w, allvaluesobjects) {
|
|
|
9
10
|
loadCategoryRepeaterData(_$w, allvaluesobjects);
|
|
10
11
|
|
|
11
12
|
// wait for the jobs dataset to be ready
|
|
12
|
-
await _$w(
|
|
13
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).onReadyAsync();
|
|
13
14
|
|
|
14
15
|
await bindPrimarySearch(_$w);
|
|
15
16
|
}
|
|
@@ -72,7 +73,7 @@ function getSearchQuery(_$w) {
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
async function handleSearchInput(_$w) {
|
|
75
|
-
_$w(
|
|
76
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_INPUT).enable();
|
|
76
77
|
|
|
77
78
|
// on Input call the queryPrimarySearchResults function
|
|
78
79
|
const callQueryPrimarySearchResults = async () => {
|
|
@@ -91,7 +92,7 @@ async function handleSearchInput(_$w) {
|
|
|
91
92
|
await queryPrimarySearchResults(_$w, searchQuery);
|
|
92
93
|
}
|
|
93
94
|
else {
|
|
94
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(
|
|
95
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(PRIMARY_SEARCH_STATES.CATEGORY_RESULTS);
|
|
95
96
|
}
|
|
96
97
|
});
|
|
97
98
|
|
|
@@ -114,36 +115,36 @@ async function handleSearchInput(_$w) {
|
|
|
114
115
|
|
|
115
116
|
async function queryPrimarySearchResults(_$w, query) {
|
|
116
117
|
if(query === undefined || query === '') {
|
|
117
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(
|
|
118
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(PRIMARY_SEARCH_STATES.CATEGORY_RESULTS);
|
|
118
119
|
return false;
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
const searchByTitle = [{field: 'title', searchTerm: query}];
|
|
122
123
|
const searchByCity = [{field: 'location.fullLocation', searchTerm: query}];
|
|
123
124
|
|
|
124
|
-
let filter = await getFilter(searchByTitle);
|
|
125
|
+
let filter = await getFilter(searchByTitle);
|
|
125
126
|
|
|
126
|
-
await _$w(
|
|
127
|
-
await _$w(
|
|
127
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).setFilter(filter);
|
|
128
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).refresh();
|
|
128
129
|
|
|
129
|
-
let count = _$w(
|
|
130
|
+
let count = _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getTotalCount();
|
|
130
131
|
|
|
131
132
|
if( count > 0 ) {
|
|
132
133
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
|
|
133
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(
|
|
134
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(PRIMARY_SEARCH_STATES.JOB_RESULTS);
|
|
134
135
|
}
|
|
135
136
|
else {
|
|
136
137
|
filter = await getFilter(searchByCity);
|
|
137
|
-
await _$w(
|
|
138
|
-
await _$w(
|
|
138
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).setFilter(filter);
|
|
139
|
+
await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).refresh();
|
|
139
140
|
|
|
140
|
-
count = _$w(
|
|
141
|
+
count = _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).getTotalCount();
|
|
141
142
|
if (count > 0) {
|
|
142
143
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_CONTAINER).expand();
|
|
143
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(
|
|
144
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(PRIMARY_SEARCH_STATES.JOB_RESULTS);
|
|
144
145
|
}
|
|
145
146
|
else{
|
|
146
|
-
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(
|
|
147
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PRIMARY_SEARCH_MULTI_BOX).changeState(PRIMARY_SEARCH_STATES.NO_RESULTS);
|
|
147
148
|
}
|
|
148
149
|
}
|
|
149
150
|
|
|
@@ -152,4 +153,5 @@ return count > 0;
|
|
|
152
153
|
|
|
153
154
|
module.exports = {
|
|
154
155
|
handlePrimarySearch,
|
|
156
|
+
queryPrimarySearchResults
|
|
155
157
|
}
|
package/public/selectors.js
CHANGED
|
@@ -26,19 +26,22 @@ const CAREERS_PAGE_SELECTORS = {
|
|
|
26
26
|
OPEN_FILTERS_BUTTON: '#openFiltersButton',
|
|
27
27
|
CLOSE_FILTERS_BUTTON: '#closeFiltersButton',
|
|
28
28
|
RESET_FILTERS_BUTTON: '#resetFiltersButton',
|
|
29
|
-
RESET_FILTERS_BUTTON: '#resetFiltersButton',
|
|
30
29
|
|
|
31
30
|
RESULTS_MULTI_STATE: '#resultsMultiState',
|
|
32
31
|
BRANDS_DATASET: '#brandsDataset',
|
|
33
32
|
DEPARTMENTS_DATASET: '#departmentsDataset',
|
|
34
33
|
LOCATIONS_DATASET: '#locationsDataset',
|
|
35
34
|
JOB_TYPES_DATASET: '#jobTypesDataset',
|
|
36
|
-
JOBS_DATASET: '#jobsDataset',
|
|
37
35
|
|
|
38
36
|
GOOGLE_MAPS: '#googleMaps',
|
|
39
37
|
FOOTER: '#footer',
|
|
40
38
|
}
|
|
41
39
|
|
|
40
|
+
const GLOBAL_SECTIONS_SELECTORS = {
|
|
41
|
+
JOBS_DATASET: '#jobsDataset',
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
42
45
|
const FILTER_FIELDS = {
|
|
43
46
|
DEPARTMENT: 'department',
|
|
44
47
|
LOCATION: 'cityText',
|
|
@@ -49,5 +52,6 @@ const FILTER_FIELDS = {
|
|
|
49
52
|
|
|
50
53
|
module.exports = {
|
|
51
54
|
CAREERS_PAGE_SELECTORS,
|
|
55
|
+
GLOBAL_SECTIONS_SELECTORS,
|
|
52
56
|
FILTER_FIELDS,
|
|
53
57
|
}
|