dispatch(untouch(SEARCH_BAR_ADVANCED_FORM_NAME, propertyField));
};
-export const updateAdvancedFormProperties = (propertyValue: PropertyValue) =>
- (dispatch: Dispatch) => {
- dispatch(arrayPush(SEARCH_BAR_ADVANCED_FORM_NAME, 'properties', propertyValue));
- };
-
export const moveUp = () =>
(dispatch: Dispatch) => {
dispatch(searchBarActions.MOVE_UP());
import {
SEARCH_BAR_ADVANCED_FORM_NAME,
changeAdvancedFormProperty,
- resetAdvancedFormProperty,
- updateAdvancedFormProperties
+ resetAdvancedFormProperty
} from '~/store/search-bar/search-bar-actions';
import { PropertyValue } from '~/models/search-bar';
import { ArvadosTheme } from '~/common/custom-theme';
interface SearchBarAdvancedPropertiesViewActionProps {
setProps: () => void;
- addProp: (propertyValues: PropertyValue) => void;
+ setProp: (propertyValues: PropertyValue, properties: PropertyValue[]) => void;
getAllFields: (propertyValues: PropertyValue[]) => PropertyValue[] | [];
}
setProps: (propertyValues: PropertyValue[]) => {
dispatch<any>(changeAdvancedFormProperty('properties', propertyValues));
},
- addProp: (propertyValue: PropertyValue) => {
- dispatch<any>(updateAdvancedFormProperties(propertyValue));
+ setProp: (propertyValue: PropertyValue, properties: PropertyValue[]) => {
+ dispatch<any>(changeAdvancedFormProperty(
+ 'properties',
+ [...properties.filter(e => e.keyID! !== propertyValue.keyID!), propertyValue]
+ ));
dispatch<any>(resetAdvancedFormProperty('key'));
dispatch<any>(resetAdvancedFormProperty('value'));
dispatch<any>(resetAdvancedFormProperty('keyID'));
connectVocabulary,
connect(mapStateToProps, mapDispatchToProps))(
withStyles(styles)(
- ({ classes, fields, propertyValues, setProps, addProp, getAllFields, vocabulary }: SearchBarAdvancedPropertiesViewProps) =>
+ ({ classes, fields, propertyValues, setProps, setProp, getAllFields, vocabulary }: SearchBarAdvancedPropertiesViewProps) =>
<Grid container item xs={12} spacing={16}>
<Grid item xs={2} className={classes.label}>Properties</Grid>
<Grid item xs={4}>
<SearchBarValueField />
</Grid>
<Grid container item xs={2} justify='flex-end' alignItems="center">
- <Button className={classes.button} onClick={() => addProp(propertyValues)}
+ <Button className={classes.button} onClick={() => setProp(propertyValues, getAllFields(fields))}
color="primary"
size='small'
variant="contained"