definma-ui/src/app/models/measurement.model.ts
2020-08-21 16:11:57 +02:00

32 lines
802 B
TypeScript

import omit from 'lodash/omit';
import pick from 'lodash/pick';
import {IdModel} from './id.model';
import {BaseModel} from './base.model';
export class MeasurementModel extends BaseModel {
_id: IdModel = null;
sample_id: IdModel = null;
measurement_template: IdModel;
values: {[prop: string]: any} = {};
status = '';
constructor(measurementTemplate: IdModel = null) {
super();
this.measurement_template = measurementTemplate;
}
deserialize(input: any): this {
Object.assign(this, input);
Object.keys(this.values).forEach(key => {
if (this.values[key] === null) {
this.values[key] = '';
}
});
return this;
}
sendFormat(omitValues = []) {
return omit(pick(this, ['sample_id', 'measurement_template', 'values']), omitValues);
}
}