Commit ad0e407f authored by pei-chi.huang's avatar pei-chi.huang
Browse files

fix solvents issue

parent 0c0c3bbb
......@@ -129,6 +129,7 @@ class Material extends Component {
metricPrefix="milli"
metricPrefixes={['milli', 'none', 'micro']}
precision={3}
disabled={(this.props.materialGroup !== 'products' && this.props.materialGroup !== 'solvents') && !material.reference && this.props.lockEquivColumn}
onChange={this.handleAmountUnitChange}
bsStyle={material.amount_unit === 'l' ? 'success' : 'default'}
/>
......@@ -155,7 +156,7 @@ class Material extends Component {
metricPrefixes={['none']}
bsStyle={material.error_loading ? 'error' : 'success'}
precision={3}
disabled={this.props.materialGroup === 'products'}
disabled={this.props.materialGroup === 'products' || (!material.reference && this.props.lockEquivColumn)}
onChange={loading => this.handleLoadingChange(loading)}
/>
</td>
......@@ -403,6 +404,7 @@ class Material extends Component {
metricPrefix="milli"
metricPrefixes={['milli', 'none', 'micro']}
precision={4}
disabled={this.props.materialGroup !== 'products' && !material.reference && this.props.lockEquivColumn}
onChange={this.handleAmountUnitChange}
bsStyle={material.error_mass ? 'error' : massBsStyle}
/>
......@@ -420,7 +422,7 @@ class Material extends Component {
metricPrefix="milli"
metricPrefixes={['milli', 'none']}
precision={4}
disabled={this.props.materialGroup === 'products'}
disabled={this.props.materialGroup === 'products' || (!material.reference && this.props.lockEquivColumn)}
onChange={this.handleAmountUnitChange}
bsStyle={material.amount_unit === 'mol' ? 'success' : 'default'}
/>
......
......@@ -85,7 +85,7 @@ const SwitchEquivButton = (lockEquivColumn, switchEquiv) => {
<Button
id="lock_equiv_column_btn"
bsSize="xsmall"
bsStyle={lockEquivColumn ? 'warning' : 'light'}
bsStyle={lockEquivColumn ? 'warning' : 'default'}
onClick={switchEquiv}
>
<i className={lockEquivColumn ? 'fa fa-lock' : 'fa fa-unlock'} />
......@@ -178,8 +178,7 @@ const GeneralMaterialGroup = ({
<col style={{ width: showLoadingColumn ? '11%' : '12%' }} />
{ showLoadingColumn && <col style={{ width: '11%' }} /> }
<col style={{ width: showLoadingColumn ? '11%' : '12%' }} />
<col style={{ width: showLoadingColumn ? '8%' : '9%' }} />
<col style={{ width: '4%' }} />
<col style={{ width: showLoadingColumn ? '12%' : '13%' }} />
</colgroup>
<thead>
<tr>
......@@ -288,7 +287,7 @@ MaterialGroup.propTypes = {
dropMaterial: PropTypes.func.isRequired,
dropSample: PropTypes.func.isRequired,
switchEquiv: PropTypes.func.isRequired,
lockEquivColumn: PropTypes.bool.isRequired
lockEquivColumn: PropTypes.bool
};
GeneralMaterialGroup.propTypes = {
......@@ -298,7 +297,7 @@ GeneralMaterialGroup.propTypes = {
addDefaultSolvent: PropTypes.func.isRequired,
contents: PropTypes.arrayOf(PropTypes.shape).isRequired,
switchEquiv: PropTypes.func.isRequired,
lockEquivColumn: PropTypes.bool.isRequired
lockEquivColumn: PropTypes.bool
};
SolventsMaterialGroup.propTypes = {
......@@ -310,10 +309,12 @@ SolventsMaterialGroup.propTypes = {
MaterialGroup.defaultProps = {
showLoadingColumn: false,
lockEquivColumn: false
};
GeneralMaterialGroup.defaultProps = {
showLoadingColumn: false,
lockEquivColumn: false
};
......
......@@ -108,10 +108,12 @@ MaterialGroupContainer.propTypes = {
isOver: PropTypes.bool.isRequired,
canDrop: PropTypes.bool.isRequired,
connectDropTarget: PropTypes.func.isRequired,
switchEquiv: PropTypes.func.isRequired,
lockEquivColumn: PropTypes.bool.isRequired
switchEquiv: PropTypes.func,
lockEquivColumn: PropTypes.bool
};
MaterialGroupContainer.defaultProps = {
showLoadingColumn: false,
switchEquiv: () => null,
lockEquivColumn: false
};
......@@ -404,7 +404,7 @@ export default class ReactionDetailsScheme extends Component {
}
sample.equivalent = sample.amount_mol / referenceMaterial.amount_mol;
} else {
if (!lockEquivColumn) {
if (!lockEquivColumn || materialGroup === 'solvents') {
sample.equivalent = sample.amount_mol / referenceMaterial.amount_mol;
} else {
if (referenceMaterial && referenceMaterial.amount_value) {
......@@ -429,7 +429,7 @@ export default class ReactionDetailsScheme extends Component {
}
}
} else {
if (!lockEquivColumn || materialGroup === 'products' ) {
if (!lockEquivColumn || materialGroup === 'products' || materialGroup === 'solvents') {
// calculate equivalent, don't touch real amount
sample.equivalent = sample.amount_mol / referenceMaterial.amount_mol;
} else {
......@@ -605,7 +605,7 @@ export default class ReactionDetailsScheme extends Component {
dropSample={this.dropSample}
showLoadingColumn={!!reaction.hasPolymers()}
onChange={changeEvent => this.handleMaterialsChange(changeEvent)}
switchEquiv={this.toggleLockEquivColumn}
switchEquiv={this.switchEquiv}
lockEquivColumn={lockEquivColumn}
headIndex={headReactants}
/>
......@@ -621,7 +621,7 @@ export default class ReactionDetailsScheme extends Component {
dropSample={this.dropSample}
showLoadingColumn={!!reaction.hasPolymers()}
onChange={changeEvent => this.handleMaterialsChange(changeEvent)}
switchEquiv={this.toggleLockEquivColumn}
switchEquiv={this.switchEquiv}
lockEquivColumn={this.state.lockEquivColumn}
headIndex={0}
/>
......@@ -639,7 +639,7 @@ export default class ReactionDetailsScheme extends Component {
dropSample={this.dropSample}
showLoadingColumn={!!reaction.hasPolymers()}
onChange={changeEvent => this.handleMaterialsChange(changeEvent)}
switchEquiv={this.toggleLockEquivColumn}
switchEquiv={this.switchEquiv}
lockEquivColumn={this.state.lockEquivColumn}
headIndex={0}
/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment