Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample types extension updates #2058

Draft
wants to merge 1 commit into
base: sample-types-extension
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/api/entities/sample_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SampleEntity < ApplicationEntity
expose! :melting_point, unless: :displayed_in_list
expose! :metrics
expose! :molarity_unit, unless: :displayed_in_list
expose! :molarity_value, unless: :displayed_in_list
expose! :molarity_value
expose! :molecule_name_hash, anonymize_with: {}
expose! :name
expose! :parent_id, unless: :displayed_in_list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FormControl, ControlLabel, InputGroup, Button } from 'react-bootstrap';
import {
FormControl, ControlLabel, InputGroup, Button, OverlayTrigger, Tooltip
} from 'react-bootstrap';
import { metPreConv, metPrefSymbols } from 'src/utilities/metricPrefix';

export default class NumeralInputWithUnitsCompo extends Component {
Expand Down Expand Up @@ -135,7 +137,7 @@ export default class NumeralInputWithUnitsCompo extends Component {

render() {
const {
bsSize, bsStyle, disabled, label, unit, name
bsSize, bsStyle, disabled, label, unit, name, showInfoTooltipTotalVol
} = this.props;
const {
showString, value, metricPrefix,
Expand Down Expand Up @@ -173,6 +175,20 @@ export default class NumeralInputWithUnitsCompo extends Component {
return (
<div className={`numeric-input-unit_${this.props.unit}`}>
{labelWrap}
{showInfoTooltipTotalVol && (
<OverlayTrigger
placement="top"
overlay={(
<Tooltip id="info-total-volume">
It is only a value given manually, i.e. volume by definition - not (re)calculated
</Tooltip>
)}
>
<ControlLabel style={{ marginLeft: '5px', cursor: 'pointer' }}>
<span style={{ cursor: 'pointer' }} className="glyphicon glyphicon-info-sign" />
</ControlLabel>
</OverlayTrigger>
)}
<InputGroup
onDoubleClick={event => this.handleInputDoubleClick(event)}
>
Expand Down Expand Up @@ -228,7 +244,8 @@ NumeralInputWithUnitsCompo.propTypes = {
label: PropTypes.node,
bsSize: PropTypes.string,
bsStyle: PropTypes.string,
name: PropTypes.string
name: PropTypes.string,
showInfoTooltipTotalVol: PropTypes.bool,
};

NumeralInputWithUnitsCompo.defaultProps = {
Expand All @@ -239,5 +256,6 @@ NumeralInputWithUnitsCompo.defaultProps = {
block: false,
bsSize: 'small',
bsStyle: 'default',
name: ''
name: '',
showInfoTooltipTotalVol: false,
};
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,8 @@ export default class SampleDetails extends React.Component {

saveBtn(sample, closeView = false) {
let submitLabel = (sample && sample.isNew) ? 'Create' : 'Save';
const hasComponents = sample.sample_type === 'Mixture' && sample.components && sample.components.length > 0;
const hasComponents = sample.sample_type !== 'Mixture'
|| (sample.components && sample.components.length > 0);
const isDisabled = !sample.can_update || !hasComponents;
if (closeView) submitLabel += ' and close';

Expand Down Expand Up @@ -968,8 +969,9 @@ export default class SampleDetails extends React.Component {
const timesTag = (
<i className="fa fa-times" />
);
const hasComponents = sample.sample_type === 'Mixture' && sample.components && sample.components.length > 0;
const sampleUpdateCondition = !this.sampleIsValid() || !sample.can_update || !hasComponents;
const hasComponents = sample.sample_type !== 'Mixture'
|| (sample.components && sample.components.length > 0);
const sampleUpdateCondition = !this.sampleIsValid() || !sample.can_update || !hasComponents;

const elementToSave = activeTab === 'inventory' ? 'Chemical' : 'Sample';
const saveAndClose = (
Expand Down Expand Up @@ -1420,13 +1422,13 @@ export default class SampleDetails extends React.Component {

sampleAverageMW(sample) {
let mw;

if (sample.sample_type === 'Mixture' && sample.sample_details) {
mw = sample.total_molecular_weight;
} else {
mw = sample.molecule_molecular_weight;
}

if (mw) return <ClipboardCopyText text={`${mw.toFixed(MWPrecision)} g/mol`} />;
return '';
}
Expand Down
Loading
Loading