sr-npm 1.7.715 → 1.7.717
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.
|
@@ -16,6 +16,11 @@ const CAREERS_MULTI_BOXES_PAGE_CONSTS={
|
|
|
16
16
|
PAGE_BUTTON_PREVIOUS: '#previousPageButton',
|
|
17
17
|
paginationCurrentText: '#paginationCurrent',
|
|
18
18
|
paginationTotalCountText: '#paginationTotalCount',
|
|
19
|
+
SEARCH_INPUT: '#searchInput',
|
|
20
|
+
PRIMARY_SEARCH_RESULTS: '#resultsRepeater',
|
|
21
|
+
SEARCH_BUTTON: '#searchButton',
|
|
22
|
+
SECONDARY_SEARCH_INPUT: '#secondarySearchInput',
|
|
23
|
+
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
const fieldTitlesInCMS={
|
package/package.json
CHANGED
|
@@ -12,6 +12,7 @@ let alljobs=[] // all jobs in the database
|
|
|
12
12
|
let allvaluesobjects=[] // all values in the database
|
|
13
13
|
let valueToJobs={} // valueId -> array of jobIds
|
|
14
14
|
let currentJobs=[] // current jobs that are displayed in the jobs repeater
|
|
15
|
+
let currentJobsBeforeSecondarySearch=[]
|
|
15
16
|
const pagination = {
|
|
16
17
|
pageSize: 10,
|
|
17
18
|
currentPage: 1,
|
|
@@ -21,6 +22,7 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
|
|
|
21
22
|
await loadJobsRepeater(_$w);
|
|
22
23
|
await loadFilters(_$w);
|
|
23
24
|
await loadSelectedValuesRepeater(_$w);
|
|
25
|
+
await bindSearchInput(_$w);
|
|
24
26
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CLEAR_ALL_BUTTON_ID).onClick(async () => {
|
|
25
27
|
if(selectedByField.size>0) {
|
|
26
28
|
selectedByField.clear();
|
|
@@ -34,10 +36,26 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
|
|
|
34
36
|
async function handleUrlParams(_$w,urlParams) {
|
|
35
37
|
let applyFiltering=false;
|
|
36
38
|
if(urlParams.brand) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
applyFiltering=await handleParams(_$w,"brand",urlParams.brand)
|
|
40
|
+
}
|
|
41
|
+
if(urlParams.category) {
|
|
42
|
+
applyFiltering=await handleParams(_$w,"category",urlParams.category)
|
|
43
|
+
}
|
|
44
|
+
if(urlParams.keyword) {
|
|
45
|
+
console.log("keyword urlparam handling coming soon...")
|
|
46
|
+
}
|
|
47
|
+
if(applyFiltering) {
|
|
48
|
+
await updateJobsAndNumbersAndFilters(_$w);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function handleParams(_$w,param,value) {
|
|
53
|
+
let applyFiltering=false;
|
|
54
|
+
const decodedValue = decodeURIComponent(value);
|
|
55
|
+
const field=getFieldByTitle(fieldTitlesInCMS[param],allfields);
|
|
39
56
|
const options=optionsByFieldId.get(field._id);
|
|
40
|
-
|
|
57
|
+
console.log("all options availbe for this field: ", field.title, " are ", options);
|
|
58
|
+
const option=getCorrectOption(decodedValue,options);
|
|
41
59
|
if(option) {
|
|
42
60
|
const optionIndex=getOptionIndexFromCheckBox(_$w(`#${FiltersIds[field.title]}CheckBox`).options,option.value);
|
|
43
61
|
_$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = [optionIndex];
|
|
@@ -46,38 +64,9 @@ async function handleUrlParams(_$w,urlParams) {
|
|
|
46
64
|
dontUpdateThisCheckBox=field._id;
|
|
47
65
|
}
|
|
48
66
|
else {
|
|
49
|
-
console.warn(
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if(urlParams.category) {
|
|
53
|
-
const categoryValue = decodeURIComponent(urlParams.category);
|
|
54
|
-
const field=getFieldByTitle(fieldTitlesInCMS.category,allfields);
|
|
55
|
-
const options=optionsByFieldId.get(field._id);
|
|
56
|
-
const option=getCorrectOption(categoryValue,options);
|
|
57
|
-
if(option) {
|
|
58
|
-
const optionIndex=getOptionIndexFromCheckBox(_$w(`#${FiltersIds[field.title]}CheckBox`).options,option.value);
|
|
59
|
-
_$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = [optionIndex];
|
|
60
|
-
selectedByField.set(field._id, [option.value]);
|
|
61
|
-
applyFiltering=true
|
|
62
|
-
if(dontUpdateThisCheckBox)
|
|
63
|
-
{
|
|
64
|
-
//to update the checkboxes after applying the filters
|
|
65
|
-
dontUpdateThisCheckBox=null;
|
|
66
|
-
}
|
|
67
|
-
else{
|
|
68
|
-
dontUpdateThisCheckBox=field._id;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
console.warn("category value not found in dropdown options");
|
|
67
|
+
console.warn(`${param} value not found in dropdown options`);
|
|
73
68
|
}
|
|
74
|
-
|
|
75
|
-
if(urlParams.keyword) {
|
|
76
|
-
console.log("keyword urlparam handling coming soon...")
|
|
77
|
-
}
|
|
78
|
-
if(applyFiltering) {
|
|
79
|
-
await updateJobsAndNumbersAndFilters(_$w);
|
|
80
|
-
}
|
|
69
|
+
return applyFiltering;
|
|
81
70
|
}
|
|
82
71
|
|
|
83
72
|
async function loadPaginationButtons(_$w) {
|
|
@@ -361,6 +350,42 @@ async function refreshFacetCounts(_$w,clearAll=false) {
|
|
|
361
350
|
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).data = selectedItems;
|
|
362
351
|
}
|
|
363
352
|
|
|
353
|
+
|
|
354
|
+
function primarySearch(_$w,query) {
|
|
355
|
+
console.log("primary search query: ", query);
|
|
356
|
+
}
|
|
357
|
+
function secondarySearch(_$w,query) {
|
|
358
|
+
console.log("secondary search query: ", query);
|
|
359
|
+
if(query.length===0) {
|
|
360
|
+
if(currentJobsBeforeSecondarySearch.length>0) {
|
|
361
|
+
currentJobs=currentJobsBeforeSecondarySearch
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
else
|
|
365
|
+
{
|
|
366
|
+
currentJobsBeforeSecondarySearch=currentJobs;
|
|
367
|
+
currentJobs=currentJobs.filter(job=>job.title.toLowerCase().includes(query));
|
|
368
|
+
}
|
|
369
|
+
const jobsFirstPage=currentJobs.slice(0,pagination.pageSize);
|
|
370
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = jobsFirstPage;
|
|
371
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationCurrentText).text = jobsFirstPage.length.toString();
|
|
372
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationTotalCountText).text = currentJobs.length.toString();
|
|
373
|
+
pagination.currentPage=1;
|
|
374
|
+
handlePaginationButtons(_$w);
|
|
375
|
+
}
|
|
376
|
+
function bindSearchInput(_$w) {
|
|
377
|
+
const primarySearchDebounced = debounce(() => {
|
|
378
|
+
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SEARCH_INPUT).value || '').toLowerCase().trim();
|
|
379
|
+
primarySearch(_$w, query);
|
|
380
|
+
}, 150);
|
|
381
|
+
const secondarySearchDebounced = debounce(() => {
|
|
382
|
+
const query = (_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).value || '').toLowerCase().trim();
|
|
383
|
+
secondarySearch(_$w, query);
|
|
384
|
+
}, 150);
|
|
385
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SEARCH_INPUT).onInput(primarySearchDebounced);
|
|
386
|
+
_$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).onInput(secondarySearchDebounced);
|
|
387
|
+
}
|
|
388
|
+
|
|
364
389
|
module.exports = {
|
|
365
390
|
careersMultiBoxesPageOnReady
|
|
366
391
|
};
|