X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/5e61d3dd53b8ff5ea925d0897274cc267985e4f9..cdad04a31b572aa401e3f5d1fdc2c0f69d6e2d08:/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 c658c33b..b001cb3e 100644 --- a/src/views-components/search-bar/search-bar-advanced-view.tsx +++ b/src/views-components/search-bar/search-bar-advanced-view.tsx @@ -3,11 +3,14 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; -import { reduxForm, reset, InjectedFormProps } from 'redux-form'; +import { reduxForm, InjectedFormProps, reset } 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, saveQuery } from '~/store/search-bar/search-bar-actions'; +import { + SEARCH_BAR_ADVANCE_FORM_NAME, SEARCH_BAR_ADVANCE_FORM_PICKER_ID, + searchAdvanceData, + setSearchValueFromAdvancedData +} 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'; @@ -16,6 +19,7 @@ import { SearchBarDateFromField, SearchBarDateToField, SearchBarPropertiesField, SearchBarSaveSearchField, SearchBarQuerySearchField } from '~/views-components/form-fields/search-bar-form-fields'; +import { treePickerActions } from "~/store/tree-picker/tree-picker-actions"; type CssRules = 'container' | 'closeIcon' | 'label' | 'buttonWrapper' | 'button' | 'circularProgress' | 'searchView' | 'selectGrid'; @@ -23,7 +27,8 @@ type CssRules = 'container' | 'closeIcon' | 'label' | 'buttonWrapper' const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ container: { padding: theme.spacing.unit * 2, - borderBottom: `1px solid ${theme.palette.grey["200"]}` + borderBottom: `1px solid ${theme.palette.grey["200"]}`, + position: 'relative', }, closeIcon: { position: 'absolute', @@ -36,8 +41,8 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ alignSelf: 'center' }, buttonWrapper: { - paddingRight: '14px', - paddingTop: '14px', + marginRight: '14px', + marginTop: '14px', position: 'relative', }, button: { @@ -45,7 +50,7 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ }, circularProgress: { position: 'absolute', - top: -9, + top: 0, bottom: 0, left: 0, right: 0, @@ -60,19 +65,26 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ } }); -interface SearchBarAdvancedViewDataProps { +// ToDo: maybe we should remove invalid and prostine +interface SearchBarAdvancedViewFormDataProps { submitting: boolean; invalid: boolean; pristine: boolean; } -interface SearchBarAdvancedViewActionProps { - setView: (currentView: string) => void; - saveQuery: (data: SearchBarAdvanceFormData) => void; +// ToDo: maybe we should remove tags +export interface SearchBarAdvancedViewDataProps { tags: any; + saveQuery: boolean; +} + +export interface SearchBarAdvancedViewActionProps { + closeAdvanceView: () => void; } -type SearchBarAdvancedViewProps = SearchBarAdvancedViewActionProps & SearchBarAdvancedViewDataProps +type SearchBarAdvancedViewProps = SearchBarAdvancedViewActionProps & SearchBarAdvancedViewDataProps; + +type SearchBarAdvancedViewFormProps = SearchBarAdvancedViewProps & SearchBarAdvancedViewFormDataProps & InjectedFormProps & WithStyles; const validate = (values: any) => { @@ -88,16 +100,20 @@ const validate = (values: any) => { }; export const SearchBarAdvancedView = compose( - reduxForm({ + reduxForm({ form: SEARCH_BAR_ADVANCE_FORM_NAME, validate, onSubmit: (data: SearchBarAdvanceFormData, dispatch: Dispatch) => { - dispatch(saveQuery(data)); + dispatch(searchAdvanceData(data)); dispatch(reset(SEARCH_BAR_ADVANCE_FORM_NAME)); - } + dispatch(treePickerActions.DEACTIVATE_TREE_PICKER_NODE({ pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID })); + }, + onChange: (data: SearchBarAdvanceFormData, dispatch: Dispatch, props: any, prevData: SearchBarAdvanceFormData) => { + dispatch(setSearchValueFromAdvancedData(data, prevData)); + }, }), withStyles(styles))( - ({ classes, setView, handleSubmit, submitting, invalid, pristine, tags }: SearchBarAdvancedViewProps) => + ({ classes, closeAdvanceView, handleSubmit, submitting, invalid, pristine, tags, saveQuery }: SearchBarAdvancedViewFormProps) =>
@@ -116,7 +132,7 @@ export const SearchBarAdvancedView = compose( Project - + @@ -126,7 +142,7 @@ export const SearchBarAdvancedView = compose( - setView(SearchView.BASIC)} className={classes.closeIcon}> + @@ -147,14 +163,15 @@ export const SearchBarAdvancedView = compose( - + {saveQuery && }