Skip to content

Commit

Permalink
add search input to filter form (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap authored Aug 13, 2021
1 parent d006ea4 commit e22bdbc
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ import FilterByExtent from './FilterByExtent';
import FilterItems from './FilterItems';
import debounce from 'lodash/debounce';
import isEmpty from 'lodash/isEmpty';
import withDebounceOnCallback from '@mapstore/framework/components/misc/enhancers/withDebounceOnCallback';
import localizedProps from '@mapstore/framework/components/misc/enhancers/localizedProps';
import { FormControl as FormControlRB } from 'react-bootstrap';
const FormControl = localizedProps('placeholder')(FormControlRB);
function InputControl({ onChange, value, ...props }) {
return <FormControl {...props} value={value} onChange={event => onChange(event.target.value)}/>;
}
const InputControlWithDebounce = withDebounceOnCallback('onChange', 'value')(InputControl);

/**
* FilterForm component allows to configure a list of field that can be used to apply filter on the page
* @name FilterForm
Expand Down Expand Up @@ -65,6 +74,12 @@ function FilterForm({
<form
style={style}
>
<InputControlWithDebounce
placeholder="gnhome.search"
value={query.q || ''}
debounceTime={300}
onChange={(q) => handleFieldChange({ q })}
/>
<FilterItems
id={id}
items={fields}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
"pendingApproval": "Ausstehende Genehmigung",
"featuredList": "Vorgestellt",
"uploadDataset": "Datensatz hochladen",
"createDataset": "Dataset erstellen"
"createDataset": "Dataset erstellen",
"search": "Suchen..."
},
"viewer": {
"document": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
"pendingApproval": "Pending approval",
"featuredList": "Featured",
"uploadDataset": "Upload dataset",
"createDataset": "Create dataset"
"createDataset": "Create dataset",
"search": "Search..."
},
"viewer": {
"document": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
"pendingApproval": "Aprobación pendiente",
"featuredList": "Presentada",
"uploadDataset": "Subir conjunto de datos",
"createDataset": "Crear conjunto de datos"
"createDataset": "Crear conjunto de datos",
"search": "Buscar..."
},
"viewer": {
"document": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
"pendingApproval": "En attente de validation",
"featuredList": "Mis en exergue",
"uploadDataset": "Télécharger l'ensemble de données",
"createDataset": "Créer un ensemble de données"
"createDataset": "Créer un ensemble de données",
"search": "Chercher..."
},
"viewer": {
"document": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
"pendingApproval": "In attesa di approvazione",
"featuredList": "In primo piano",
"uploadDataset": "Carica dataset",
"createDataset": "Crea dataset"
"createDataset": "Crea dataset",
"search": "Cerca..."
},
"viewer": {
"document": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,9 @@

function hashChange() {
const newQParam = getQParamFromHash();
if (newQParam !== value) {
if (!value || newQParam !== value) {
searchInput.value = newQParam;
value = newQParam;
}
searchClear.style.display = newQParam ? 'block' : 'none';
}
Expand All @@ -226,9 +227,9 @@
searchInput.addEventListener('keyup', function(event) {
if (event.keyCode === 13) {
event.preventDefault();
if (value) {
onSearch(value);
}

onSearch(value);

}
});

Expand Down

0 comments on commit e22bdbc

Please sign in to comment.