[ARVADOS-WORKBENCH2] updated: 1.2.0-497-gcfff004
Git user
git at public.curoverse.com
Mon Oct 1 04:02:39 EDT 2018
Summary of changes:
src/views/run-process-panel/inputs/float-input.tsx | 31 +++++++++++++++++++---
1 file changed, 27 insertions(+), 4 deletions(-)
via cfff00494c45cb6f8a53373a64d72dbd2fe8cd85 (commit)
from 428d454e2681d66bb14558946cfe2fb77a2c8dce (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit cfff00494c45cb6f8a53373a64d72dbd2fe8cd85
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Mon Oct 1 10:02:19 2018 +0200
Create DecimalInput for storing decimal separator info
Feature #13863
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/views/run-process-panel/inputs/float-input.tsx b/src/views/run-process-panel/inputs/float-input.tsx
index 0f5a116..664425d 100644
--- a/src/views/run-process-panel/inputs/float-input.tsx
+++ b/src/views/run-process-panel/inputs/float-input.tsx
@@ -4,10 +4,9 @@
import * as React from 'react';
import { getInputLabel, FloatCommandInputParameter } from '~/models/workflow';
-import { Field } from 'redux-form';
+import { Field, WrappedFieldProps } from 'redux-form';
import { TextField } from '~/components/text-field/text-field';
import { isNumber } from '~/validators/is-number';
-import { toNumber } from 'lodash';
export interface FloatInputProps {
input: FloatCommandInputParameter;
}
@@ -15,8 +14,32 @@ export const FloatInput = ({ input }: FloatInputProps) =>
<Field
name={input.id}
label={getInputLabel(input)}
- component={TextField}
- parse={value => toNumber(value)}
+ component={DecimalInput}
+ parse={parseFloat}
format={value => isNaN(value) ? '' : JSON.stringify(value)}
validate={[isNumber]} />;
+
+class DecimalInput extends React.Component<WrappedFieldProps & { label?: string }> {
+ state = {
+ endsWithDecimalSeparator: false,
+ };
+
+ handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
+ const [base, fraction] = event.target.value.split('.');
+ this.setState({ endsWithDecimalSeparator: fraction === '' });
+ this.props.input.onChange(event);
+ }
+
+ render() {
+ const props = {
+ ...this.props,
+ input: {
+ ...this.props.input,
+ value: this.props.input.value + (this.state.endsWithDecimalSeparator ? '.' : ''),
+ onChange: this.handleChange,
+ },
+ };
+ return <TextField {...props} />;
+ }
+}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list