}
});
-interface SearchBarAdvancedViewDataProps {
+interface SearchBarAdvancedViewFormDataProps {
submitting: boolean;
invalid: boolean;
pristine: boolean;
}
-export interface Tags {
- values?: {
- properties?: { key: string, value: string },
- value?: string;
- key?: string;
- };
+export interface SearchBarAdvancedViewDataProps {
+ tags: any;
}
-interface SearchBarAdvancedViewActionProps {
- setView: (currentView: string) => void;
+export interface SearchBarAdvancedViewActionProps {
+ onSetView: (currentView: string) => void;
saveQuery: (data: SearchBarAdvanceFormData) => void;
- tags: Tags;
}
-type SearchBarAdvancedViewProps = SearchBarAdvancedViewActionProps & SearchBarAdvancedViewDataProps
+type SearchBarAdvancedViewProps = SearchBarAdvancedViewActionProps & SearchBarAdvancedViewDataProps;
+
+type SearchBarAdvancedViewFormProps = SearchBarAdvancedViewProps & SearchBarAdvancedViewFormDataProps
& InjectedFormProps & WithStyles<CssRules>;
const validate = (values: any) => {
};
export const SearchBarAdvancedView = compose(
- reduxForm<SearchBarAdvanceFormData, SearchBarAdvancedViewActionProps>({
+ reduxForm<SearchBarAdvanceFormData, SearchBarAdvancedViewProps>({
form: SEARCH_BAR_ADVANCE_FORM_NAME,
validate,
onSubmit: (data: SearchBarAdvanceFormData, dispatch: Dispatch) => {
}
}),
withStyles(styles))(
- ({ classes, setView, handleSubmit, submitting, invalid, pristine, tags }: SearchBarAdvancedViewProps) =>
+ ({ classes, onSetView, handleSubmit, submitting, invalid, pristine, tags }: SearchBarAdvancedViewFormProps) =>
<Paper className={classes.searchView}>
<form onSubmit={handleSubmit}>
<Grid container direction="column" justify="flex-start" alignItems="flex-start">
<SearchBarTrashField />
</Grid>
</Grid>
- <IconButton onClick={() => setView(SearchView.BASIC)} className={classes.closeIcon}>
+ <IconButton onClick={() => onSetView(SearchView.BASIC)} className={classes.closeIcon}>
<CloseIcon />
</IconButton>
</Grid>
<Grid container item xs={12} justify='flex-end'>
<div className={classes.buttonWrapper}>
<Button type="submit" className={classes.button}
- disabled={invalid || submitting || pristine || !!((tags.values!.key || tags.values!.value) && !tags.values!.properties)}
+ // ToDo: create easier condition
+ disabled={invalid || submitting || pristine || !!(tags && tags.values && ((tags.values.key) || (tags.values.value)) && !Object.keys(tags.values).find(el => el !== 'value' && el !== 'key'))}
color="primary"
size='small'
variant="contained">