Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add order_by parameter to GET Layers/Maps #28

Merged
merged 2 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions components/FormDropdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {Form} from 'semantic-ui-react'

class FormDropdown extends React.PureComponent {
state = {}

handle_value_change = (e, data) => {
this.setState({
value: data.value,
});
}

handle_search_change = (e) => {
this.setState({
value: e.target.value,
});
}

render() {
const {options, placeholder, label, additionLabel, name} = this.props;
const {value} = this.state;
let dropbox_value, dropbox_search_query;
if (!!options.find(opt => opt.value === value)) {
dropbox_value = value;
dropbox_search_query = '';
} else {
dropbox_value = null;
dropbox_search_query = value;
}
return (
<>
<Form.Dropdown
options={options}
placeholder={placeholder}
label={label}
onChange={this.handle_value_change}
onSearchChange={this.handle_search_change}
value={dropbox_value}
search={(options, query) => options.filter(opt => opt.key !== 'addition')}
searchQuery={dropbox_search_query}
selection
inline
allowAdditions
additionLabel={additionLabel}
/>
<input
hidden
name={name}
type="text"
value={value || ''}
onChange={() => {
}}
/>
</>
);
}
}

export default FormDropdown;
12 changes: 12 additions & 0 deletions components/GetPublicationsParams.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Form} from 'semantic-ui-react'
import FormDropdown from './FormDropdown'

class GetPublicationsParams extends React.PureComponent {

Expand All @@ -9,6 +10,17 @@ class GetPublicationsParams extends React.PureComponent {
inline
name="full_text_filter" label='Full-text filter'
placeholder='Full-text filter'/>
<FormDropdown
options={[
{key: 1, text: 'No value', value: ''},
{key: 2, text: 'Full-text', value: 'full_text'},
{key: 3, text: 'Title', value: 'title'},
]}
placeholder='Choose how to order publications'
label='Order by'
additionLabel='Custom value: '
name="order_by"
/>
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ const endpointToPathParamsClass = {
}

const requestToQueryParams = {
'get-layers': ['full_text_filter'],
'get-maps': ['full_text_filter'],
'get-layers': ['full_text_filter', 'order_by'],
'get-maps': ['full_text_filter', 'order_by'],
'patch-current-user': ['adjust_username'],
}

Expand Down