-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for an autocomplete livesearch widget
- Loading branch information
Showing
15 changed files
with
776 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add support for an autocomplete livesearch widget @reebalazs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,10 +31,12 @@ | |
}, | ||
"devDependencies": { | ||
"@plone/scripts": "^2.3.0", | ||
"react-autosuggest": "10.1.0", | ||
"release-it": "^16.1.0" | ||
}, | ||
"peerDependencies": { | ||
"@plone/volto": "^16.20.0 || ^17.0.0-alpha.4" | ||
"@plone/volto": "^16.20.0 || ^17.0.0-alpha.4", | ||
"react-autosuggest": "10.1.0" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
import { solrSearchContent, copyContentForSolr } from './solrsearch/solrsearch'; | ||
export { solrSearchContent, copyContentForSolr }; | ||
import { solrSearchSuggestions } from './solrsearch/solrSearchSuggestions'; | ||
export { solrSearchContent, copyContentForSolr, solrSearchSuggestions }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const GET_SOLR_SEARCH_SUGGESTIONS = 'GET_SOLR_SEARCH_SUGGESTIONS'; | ||
|
||
export function solrSearchSuggestions(term) { | ||
return { | ||
type: GET_SOLR_SEARCH_SUGGESTIONS, | ||
request: { | ||
op: 'get', | ||
path: `/@solr-suggest?query=${term}`, | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export SolrSearch from '@kitconcept/volto-solr/components/theme/SolrSearch/SolrSearch'; | ||
export SolrFormattedDate from '@kitconcept/volto-solr/components/theme/SolrSearch/resultItems/helpers/SolrFormattedDate'; | ||
export SolrSearchWidget, { | ||
SolrSearchAutosuggest, | ||
} from '@kitconcept/volto-solr/components/theme/SolrSearchWidget/SolrSearchWidget'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { useIntl, defineMessages } from 'react-intl'; | ||
import { Icon } from '@plone/volto/components'; | ||
import mailSVG from '@plone/volto/icons/email.svg'; | ||
|
||
const messages = defineMessages({ | ||
openMailTo: { | ||
id: 'Open a Mailto Link to the Members Email Address', | ||
defaultMessage: 'Open a Mailto Link to the Members Email Address', | ||
}, | ||
}); | ||
|
||
export default ({ email, className }) => { | ||
let decoded; | ||
if (!email.includes('@')) { | ||
const buffer = Buffer.from(email, 'base64'); | ||
decoded = buffer.toString('ascii'); | ||
} | ||
|
||
const intl = useIntl(); | ||
|
||
const rot10 = (s) => { | ||
return s.replace( | ||
/[a-z]/g, | ||
(c) => | ||
'abcdefghijklmnopqrstuvwxyz'['klmnopqrstuvwxyzabcdefghij'.indexOf(c)], | ||
); | ||
}; | ||
|
||
const onClickEmail = (e) => { | ||
const emailClear = email.includes('@') ? email : rot10(decoded); | ||
window.open(`mailto:${emailClear}`, '_self'); | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
}; | ||
|
||
return ( | ||
<span | ||
className={className} | ||
onClick={(e) => onClickEmail(e)} | ||
onKeyDown={(e) => { | ||
if (e.key === 'Enter') { | ||
onClickEmail(); | ||
} | ||
}} | ||
title={intl.formatMessage(messages.openMailTo)} | ||
role="button" | ||
tabIndex={0} | ||
> | ||
<Icon className="mail" color="#555555" size="24px" name={mailSVG} /> | ||
</span> | ||
); | ||
}; |
Oops, something went wrong.