sr-npm 1.7.716 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.716",
3
+ "version": "1.7.717",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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();
@@ -52,6 +54,7 @@ async function handleParams(_$w,param,value) {
52
54
  const decodedValue = decodeURIComponent(value);
53
55
  const field=getFieldByTitle(fieldTitlesInCMS[param],allfields);
54
56
  const options=optionsByFieldId.get(field._id);
57
+ console.log("all options availbe for this field: ", field.title, " are ", options);
55
58
  const option=getCorrectOption(decodedValue,options);
56
59
  if(option) {
57
60
  const optionIndex=getOptionIndexFromCheckBox(_$w(`#${FiltersIds[field.title]}CheckBox`).options,option.value);
@@ -347,6 +350,42 @@ async function refreshFacetCounts(_$w,clearAll=false) {
347
350
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SELECTED_VALUES_REPEATER).data = selectedItems;
348
351
  }
349
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
+
350
389
  module.exports = {
351
390
  careersMultiBoxesPageOnReady
352
391
  };