X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/23c3b5d3792225aafe5b66d81263aa1d3d42eeb9..589a72bc858a9dec96f1fcecede0a0cff3e5b32a:/src/views-components/search-bar/search-bar-advanced-view.tsx diff --git a/src/views-components/search-bar/search-bar-advanced-view.tsx b/src/views-components/search-bar/search-bar-advanced-view.tsx index 93bd0a69..c658c33b 100644 --- a/src/views-components/search-bar/search-bar-advanced-view.tsx +++ b/src/views-components/search-bar/search-bar-advanced-view.tsx @@ -7,25 +7,24 @@ import { reduxForm, reset, InjectedFormProps } from 'redux-form'; import { compose, Dispatch } from 'redux'; import { Paper, StyleRulesCallback, withStyles, WithStyles, Button, Grid, IconButton, CircularProgress } from '@material-ui/core'; import { SearchView } from '~/store/search-bar/search-bar-reducer'; -import { SEARCH_BAR_ADVANCE_FORM_NAME, SearchBarAdvanceFormData } from '~/store/search-bar/search-bar-actions'; +import { SEARCH_BAR_ADVANCE_FORM_NAME, saveQuery } from '~/store/search-bar/search-bar-actions'; import { ArvadosTheme } from '~/common/custom-theme'; import { CloseIcon } from '~/components/icon/icon'; -import { - SearchBarTypeField, SearchBarClusterField, SearchBarProjectField, SearchBarTrashField, - SearchBarDataFromField, SearchBarDataToField, SearchBarKeyField, SearchBarValueField, +import { SearchBarAdvanceFormData } from '~/models/search-bar'; +import { + SearchBarTypeField, SearchBarClusterField, SearchBarProjectField, SearchBarTrashField, + SearchBarDateFromField, SearchBarDateToField, SearchBarPropertiesField, SearchBarSaveSearchField, SearchBarQuerySearchField } from '~/views-components/form-fields/search-bar-form-fields'; -type CssRules = 'form' | 'container' | 'closeIcon' | 'label' | 'buttonWrapper' | 'button' | 'circularProgress'; +type CssRules = 'container' | 'closeIcon' | 'label' | 'buttonWrapper' + | 'button' | 'circularProgress' | 'searchView' | 'selectGrid'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ - form: { - - }, container: { - padding: theme.spacing.unit * 3, + padding: theme.spacing.unit * 2, borderBottom: `1px solid ${theme.palette.grey["200"]}` - }, + }, closeIcon: { position: 'absolute', top: '12px', @@ -37,6 +36,7 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ alignSelf: 'center' }, buttonWrapper: { + paddingRight: '14px', paddingTop: '14px', position: 'relative', }, @@ -50,6 +50,13 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ left: 0, right: 0, margin: 'auto' + }, + searchView: { + color: theme.palette.common.black, + borderRadius: `0 0 ${theme.spacing.unit / 2}px ${theme.spacing.unit / 2}px` + }, + selectGrid: { + marginBottom: theme.spacing.unit * 2 } }); @@ -61,31 +68,47 @@ interface SearchBarAdvancedViewDataProps { interface SearchBarAdvancedViewActionProps { setView: (currentView: string) => void; + saveQuery: (data: SearchBarAdvanceFormData) => void; + tags: any; } -type SearchBarAdvancedViewProps = SearchBarAdvancedViewActionProps & SearchBarAdvancedViewDataProps +type SearchBarAdvancedViewProps = SearchBarAdvancedViewActionProps & SearchBarAdvancedViewDataProps & InjectedFormProps & WithStyles; +const validate = (values: any) => { + const errors: any = {}; + + if (values.dateFrom && values.dateTo) { + if (new Date(values.dateFrom).getTime() > new Date(values.dateTo).getTime()) { + errors.dateFrom = 'Invalid date'; + } + } + + return errors; +}; + export const SearchBarAdvancedView = compose( reduxForm({ form: SEARCH_BAR_ADVANCE_FORM_NAME, + validate, onSubmit: (data: SearchBarAdvanceFormData, dispatch: Dispatch) => { + dispatch(saveQuery(data)); dispatch(reset(SEARCH_BAR_ADVANCE_FORM_NAME)); } }), withStyles(styles))( - ({ classes, setView, handleSubmit, invalid, submitting, pristine }: SearchBarAdvancedViewProps) => - -
+ ({ classes, setView, handleSubmit, submitting, invalid, pristine, tags }: SearchBarAdvancedViewProps) => + + - + Type - + Cluster @@ -107,34 +130,18 @@ export const SearchBarAdvancedView = compose( - - Data modified - - + + Date modified + + - - + + - - Properties - - - - - - - - - - - + + @@ -146,6 +153,8 @@ export const SearchBarAdvancedView = compose(