X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/32dcbe112366f6ce4037e87527aac5ea7865bee0..c59db7f1ffae1a16a5458740510e173582e68925:/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 d96062ea93..a8d65a496b 100644 --- a/src/views-components/search-bar/search-bar-advanced-view.tsx +++ b/src/views-components/search-bar/search-bar-advanced-view.tsx @@ -7,23 +7,22 @@ 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, saveQuery } 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 { SearchBarAdvanceFormData } from '~/models/search-bar'; import { SearchBarTypeField, SearchBarClusterField, SearchBarProjectField, SearchBarTrashField, - SearchBarDataFromField, SearchBarDataToField, SearchBarKeyField, SearchBarValueField, + SearchBarDateFromField, SearchBarDateToField, SearchBarPropertiesField, SearchBarSaveSearchField, SearchBarQuerySearchField } from '~/views-components/form-fields/search-bar-form-fields'; -type CssRules = 'form' | 'container' | 'closeIcon' | 'label' | 'buttonWrapper' | 'button' | 'circularProgress' | 'searchView'; +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: { @@ -37,6 +36,7 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ alignSelf: 'center' }, buttonWrapper: { + paddingRight: '14px', paddingTop: '14px', position: 'relative', }, @@ -54,6 +54,9 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ 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 } }); @@ -71,27 +74,40 @@ interface SearchBarAdvancedViewActionProps { 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 }: SearchBarAdvancedViewProps) => -
+ - + Type - + Cluster @@ -113,34 +129,18 @@ export const SearchBarAdvancedView = compose( - - Data modified - - + + Date modified + + - - + + - - Properties - - - - - - - - - - - + + @@ -152,6 +152,7 @@ export const SearchBarAdvancedView = compose(