Skip to content

Commit

Permalink
Merge pull request #8 from eea/118769_glossary_search
Browse files Browse the repository at this point in the history
Implemented Glossary search and Search result page
  • Loading branch information
mihai-macaneata authored Jun 30, 2020
2 parents 83f3e77 + 4e4a944 commit eddf39b
Show file tree
Hide file tree
Showing 11 changed files with 842 additions and 51 deletions.
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"npm": "^6.13.7",
"react": "^16.13.0",
"react-component-queries": "^2.3.0",
"react-highlight-words": "^0.16.0",
"react-image-gallery": "^0.9.1",
"react-infinite-scroll-component": "^5.0.4",
"react-lazy-load-image-component": "^1.4.0",
Expand Down
62 changes: 58 additions & 4 deletions src/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import {
SET_SECTION_TABS,
GET_PARENT_FOLDER_DATA,
GET_NAV_ITEMS
SET_SECTION_TABS,
GET_PARENT_FOLDER_DATA,
GET_NAV_ITEMS,
QUICK_RESET_SEARCH_CONTENT,
QUICK_SEARCH_CONTENT,
} from '~/constants/ActionTypes';

import { compact, concat, isArray, join, map, pickBy, toPairs } from 'lodash';

export function setSectionTabs(payload) {
return {
Expand All @@ -12,7 +15,6 @@ export function setSectionTabs(payload) {
};
}


export function getParentFolderData(url) {
return {
type: GET_PARENT_FOLDER_DATA,
Expand All @@ -22,3 +24,55 @@ export function getParentFolderData(url) {
},
};
}

export function quickSearchContent(url, options, subrequest = null) {
let queryArray = [];
const arrayOptions = pickBy(options, item => isArray(item));
console.log(options, arrayOptions);

queryArray = concat(
queryArray,
options
? join(
map(toPairs(pickBy(options, item => !isArray(item))), item => {
if (item[0] === 'SearchableText') {
// Adds the wildcard to the SearchableText param
item[1] = `${item[1]}*`;
}
return join(item, '=');
}),
'&',
)
: '',
);

queryArray = concat(
queryArray,
arrayOptions
? join(
map(pickBy(arrayOptions), (item, key) =>
join(item.map(value => `${key}:list=${value}`), '&'),
),
'&',
)
: '',
);

const querystring = join(compact(queryArray), '&');

return {
type: QUICK_SEARCH_CONTENT,
subrequest,
request: {
op: 'get',
path: `${url}/@search${querystring ? `?${querystring}` : ''}`,
},
};
}

export function quickResetSearchContent(subrequest = null) {
return {
type: QUICK_RESET_SEARCH_CONTENT,
subrequest,
};
}
2 changes: 1 addition & 1 deletion src/components/theme/View/TabsChildView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const DefaultView = props => {

return hasBlocksData(content) ? (
<div className="ui wrapper">
<div className="glossary-search search">
<div className="glossary-search">
<SearchWidget pathname={props.pathname} />
</div>

Expand Down
4 changes: 2 additions & 2 deletions src/constants/ActionTypes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const SET_SECTION_TABS = 'SET_SECTION_TABS';
export const GET_PARENT_FOLDER_DATA = 'GET_PARENT_FOLDER_DATA';
export const GET_NAV_ITEMS = 'GET_NAV_ITEMS';


export const QUICK_RESET_SEARCH_CONTENT = 'QUICK_RESET_SEARCH_CONTENT';
export const QUICK_SEARCH_CONTENT = 'QUICK_SEARCH_CONTENT';
Loading

0 comments on commit eddf39b

Please sign in to comment.