Commit 4131ebcd authored by pierre.tremouilhac's avatar pierre.tremouilhac
Browse files

Merge branch '673-display-sample-inchikey' into 'development'

Resolve "display sample inchikey"

Closes #673

See merge request ComPlat/chemotion_ELN!912
parents e58114cd 4688b12b
......@@ -66,6 +66,7 @@ export default class SampleDetails extends React.Component {
showMolfileModal: false,
smileReadonly: !props.sample.isNew,
quickCreator: false,
showInchikey: false
};
const data = UserStore.getState().profile.data || {};
......@@ -78,6 +79,7 @@ export default class SampleDetails extends React.Component {
this.handleMolfileClose = this.handleMolfileClose.bind(this);
this.handleSampleChanged = this.handleSampleChanged.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.toggleInchi = this.toggleInchi.bind(this);
}
componentWillReceiveProps(nextProps) {
......@@ -158,6 +160,11 @@ export default class SampleDetails extends React.Component {
})
}
toggleInchi() {
const { showInchikey } = this.state
this.setState({ showInchikey: !showInchikey })
}
handleMoleculeBySmile() {
const smi = this.smilesInput.value;
const { sample } = this.state;
......@@ -428,21 +435,34 @@ export default class SampleDetails extends React.Component {
&& typeof (sample.molecule_inchistring) !== 'undefined' && sample.molecule_inchistring) {
this.inchistringInput.value = sample.molecule_inchistring;
}
const inchiLabel = this.state.showInchikey ? 'InChiKey' : 'InChI';
const inchiTooltip = <Tooltip id="inchi_tooltip">toogle InChI/InChiKey</Tooltip>;
return (
<InputGroup className='sample-molecule-identifier'>
<InputGroup.Addon>InChI</InputGroup.Addon>
<InputGroup.Button>
<OverlayTrigger placement="top" overlay={inchiTooltip}>
<Button
active
onClick={this.toggleInchi}
>
{inchiLabel}
</Button>
</OverlayTrigger>
</InputGroup.Button>
<FormGroup controlId="inchistringInput">
<FormControl type="text"
inputRef={(m) => { this.inchistringInput = m; }}
key={sample.id}
defaultValue={sample.molecule_inchistring || ''}
disabled
readOnly
inputRef={(m) => { this.inchistringInput = m; }}
key={sample.id}
value={(this.state.showInchikey ? sample.molecule_inchikey : sample.molecule_inchistring) || ''}
defaultValue={(this.state.showInchikey ? sample.molecule_inchikey : sample.molecule_inchistring) || ''}
disabled
readOnly
/>
</FormGroup>
<InputGroup.Button>
<OverlayTrigger placement="bottom" overlay={this.clipboardTooltip()}>
<Button active className="clipboardBtn" data-clipboard-text={sample.molecule_inchistring || " "} >
<Button active className="clipboardBtn" data-clipboard-text={(this.state.showInchikey ? sample.molecule_inchikey : sample.molecule_inchistring) || " "} >
<i className="fa fa-clipboard"></i>
</Button>
</OverlayTrigger>
......
......@@ -59,13 +59,14 @@ feature 'Sample management' do
molarity = sample.molarity_value
expect(find_bs_field('Molarity').value.to_f).to eq(molarity)
expect(find('input#inchistringInput')[:disabled]).to eq('true')
expect(find('input#inchistringInput')[:readonly]).to eq('true')
# test read-only molecule data
{ inchistring: 'InChI', cano_smiles: 'Canonical Smiles' }.each do |f, v|
inchi_field = find_bs_field(v, 'span.input-group-addon')
expect(inchi_field.value.presence).to eq(sample.molecule[f].presence)
expect(inchi_field[:disabled]).to eq('true')
expect(inchi_field[:readonly]).to eq('true')
end
smile_field = find_bs_field('Canonical Smiles', 'span.input-group-addon')
expect(smile_field.value.presence).to eq(sample.molecule['cano_smiles'].presence)
expect(smile_field[:disabled]).to eq('true')
expect(smile_field[:readonly]).to eq('true')
# click on EA/polymer section div
find('div.polymer-section').click
......
Supports Markdown
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