Commit 82e56e0a authored by Marco Sehrer's avatar Marco Sehrer
Browse files

Merge pull request #211 from ninjaconcept/211-confirm-unsaved-elements

Add isEdited property for all element models
parents 8fb77ba0 fa37b4d0
......@@ -109,6 +109,7 @@ module Chemotion
if reaction = Reaction.find(id)
reaction.update_attributes(attributes)
reaction.touch
ReactionUpdator.update_materials_for_reaction(reaction, materials)
reaction.reload
reaction
......
......@@ -81,7 +81,7 @@ export default class ReactionDetails extends Component {
};
const submitLabel = (reaction && reaction.isNew) ? "Create" : "Save";
return (
<Panel header="Reaction Details" bsStyle='primary'>
<Panel header="Reaction Details" bsStyle={reaction.isEdited ? 'info' : 'primary'}>
<Row>
<Col md={3}>
<h3>{reaction.name}</h3>
......
......@@ -178,7 +178,7 @@ export default class SampleDetails extends React.Component {
handleTopSecretChanged(e) {
let sample = this.state.sample;
let checkedState = this.refs.topSecretInput.props.checked;
sample.is_top_secret = !checkedState;
this.setState({
sample: sample
......@@ -513,7 +513,7 @@ export default class SampleDetails extends React.Component {
onCancel={this.handleStructureEditorCancel.bind(this)}
molfile={molfile}
/>
<Panel header="Sample Details" bsStyle='primary'>
<Panel header="Sample Details" bsStyle={sample.isEdited ? 'info' : 'primary'}>
{this.sampleHeader(sample)}
<ListGroup fill>
......
......@@ -90,7 +90,7 @@ export default class ScreenDetails extends Component {
const submitLabel = (id == '_new_') ? "Create" : "Save";
return (
<div key={screen.id}>
<Panel header="Screen Details" bsStyle='primary'>
<Panel header="Screen Details" bsStyle={screen.isEdited ? 'info' : 'primary'}>
<h3>{name}</h3>
<ElementCollectionLabels element={screen}/>
<ListGroup fill>
......
......@@ -81,7 +81,7 @@ export default class WellplateDetails extends Component {
return (
<div key={wellplate.id}>
<Panel header="Wellplate Details" bsStyle='primary'>
<Panel header="Wellplate Details" bsStyle={wellplate.isEdited ? 'info' : 'primary'} >
<h3>{name}</h3>
<ElementCollectionLabels element={wellplate}/>
<ListGroup fill>
......
import sha256 from 'sha256';
import _ from 'lodash';
export default class Element {
constructor(args) {
Object.assign(this, args);
this._checksum = this.checksum();
}
get isEdited() {
return this._checksum != this.checksum();
}
checksum() {
return sha256(JSON.stringify(_.omit(_.omit(this, '_checksum'), _.isEmpty)));
}
get isNew() {
return this.id == '_new_'
}
}
export default class Molecule {
import Element from './Element';
constructor(args) {
Object.assign(this, args);
}
export default class Molecule extends Element {
get svgPath() {
return this.molecule_svg_file && `/images/molecules/${this.molecule_svg_file}`
......
import Sample from '../models/Sample';
import Element from './Element';
import Sample from './Sample';
export default class Reaction {
constructor(args) {
Object.assign(this, args);
}
export default class Reaction extends Element {
static buildEmpty() {
return new Reaction({
......@@ -29,10 +26,6 @@ export default class Reaction {
})
}
get isNew() {
return this.id == '_new_'
}
get temperature() {
return this._temperature
}
......
import uuid from 'uuid';
import Element from './Element';
import Molecule from './Molecule';
export default class Sample {
constructor(args) {
Object.assign(this, args);
}
export default class Sample extends Element {
// methods regarding sharing and sample detail levels
isRestricted() {
......@@ -14,7 +11,7 @@ export default class Sample {
}
get isNew() {
return this.id == '_new_' || this._split
return super.isNew || this._split
}
static buildChild(sample) {
......
import Element from './Element';
import Wellplate from './Wellplate';
export default class Screen {
constructor(args) {
Object.assign(this, args);
}
export default class Screen extends Element {
static buildEmpty() {
return new Screen({
......
export default class Well {
import Element from './Element';
constructor(args) {
Object.assign(this, args);
}
export default class Well extends Element {
}
import Element from './Element';
import Well from './Well';
export default class Wellplate {
export default class Wellplate extends Element {
constructor(args) {
Object.assign(this, args);
super(args)
this.wells = this.initWellsWithPosition(this.wells, 96);
this._checksum = this.checksum();
}
static buildEmpty() {
......
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