Commit 8cebf9cc authored by Marco Sehrer's avatar Marco Sehrer
Browse files

Extract Element base class for element models

parent 88503672
......@@ -81,7 +81,7 @@ export default class ReactionDetails extends Component {
};
const submitLabel = (reaction && reaction.isNew) ? "Create" : "Save";
return (
<Panel header="Reaction Details" bsStyle={reaction.edited ? 'info' : 'primary'}>
<Panel header="Reaction Details" bsStyle={reaction.isEdited ? 'info' : 'primary'}>
<Row>
<Col md={3}>
<h3>{reaction.name}</h3>
......
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 sha256 from 'sha256';
import _ from 'lodash';
import Element from './Element';
import Sample from './Sample';
import Sample from '../models/Sample';
export default class Reaction {
constructor(args) {
Object.assign(this, args);
this._checksum = this.checksum();
}
export default class Reaction extends Element {
static buildEmpty() {
return new Reaction({
......@@ -33,18 +26,6 @@ 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_'
}
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() {
......
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);
}
......
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