Commit 88503672 authored by Marco Sehrer's avatar Marco Sehrer
Browse files

PoC detect edited elements

parent 8fb77ba0
......@@ -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.edited ? 'info' : 'primary'}>
<Row>
<Col md={3}>
<h3>{reaction.name}</h3>
......
import sha256 from 'sha256';
import _ from 'lodash';
import Sample from '../models/Sample';
export default class Reaction {
constructor(args) {
Object.assign(this, args);
this._checksum = this.checksum();
}
static buildEmpty() {
......@@ -29,6 +33,14 @@ export default class Reaction {
})
}
get edited() {
return this._checksum != this.checksum();
}
checksum() {
return sha256(JSON.stringify(_.omit(_.omit(this, '_checksum'), _.isEmpty)));
}
get isNew() {
return this.id == '_new_'
}
......
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