34 lines
830 B
TypeScript
34 lines
830 B
TypeScript
|
import _ from 'lodash';
|
||
|
import {Deserializable} from './deserializable.model';
|
||
|
import {IdModel} from './id.model';
|
||
|
import {SendFormat} from './sendformat.model';
|
||
|
|
||
|
export class MaterialModel implements Deserializable, SendFormat {
|
||
|
_id: IdModel = null;
|
||
|
name = '';
|
||
|
supplier = '';
|
||
|
group = '';
|
||
|
mineral = 0;
|
||
|
glass_fiber = 0;
|
||
|
carbon_fiber = 0;
|
||
|
private numberTemplate = {color: '', number: ''};
|
||
|
numbers: {color: string, number: string}[] = [_.cloneDeep(this.numberTemplate)];
|
||
|
|
||
|
deserialize(input: any): this {
|
||
|
Object.assign(this, input);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
sendFormat() {
|
||
|
return _.pick(this, ['name', 'supplier', 'group', 'mineral', 'glass_fiber', 'carbon_fiber', 'numbers']);
|
||
|
}
|
||
|
|
||
|
addNumber() {
|
||
|
this.numbers.push(_.cloneDeep(this.numberTemplate));
|
||
|
}
|
||
|
|
||
|
popNumber() {
|
||
|
this.numbers.pop();
|
||
|
}
|
||
|
}
|