80 lines
1.6 KiB
JavaScript
80 lines
1.6 KiB
JavaScript
export class Article{
|
|
constructor() {
|
|
this.name = "";
|
|
this.short = "";
|
|
this.dimension = "";
|
|
this.content = {
|
|
size : 0,
|
|
price: 0
|
|
};
|
|
this.portion = {
|
|
size : 0,
|
|
price : 0,
|
|
type : ""
|
|
};
|
|
}
|
|
get Name() {
|
|
return this.name;
|
|
}
|
|
set Name(value) {
|
|
this.name = value;
|
|
}
|
|
get Short() {
|
|
return this.short;
|
|
}
|
|
set Short(value) {
|
|
this.short = value;
|
|
}
|
|
get ContentSize() {
|
|
return this.content.size;
|
|
}
|
|
set ContentSize(value) {
|
|
this.content.size = value;
|
|
}
|
|
get Dimension() {
|
|
return this.dimension;
|
|
}
|
|
set Dimension(value) {
|
|
this.dimension = value;
|
|
}
|
|
get PortionSize() {
|
|
return this.portion.size;
|
|
}
|
|
set PortionSize(value) {
|
|
this.portion.size = value;
|
|
}
|
|
get PortionType() {
|
|
return this.portion.type;
|
|
}
|
|
set PortionType(value) {
|
|
this.portion.type = value;
|
|
}
|
|
get PortionPrice() {
|
|
return this.portion.price;
|
|
}
|
|
set PortionPrice(value) {
|
|
this.portion.price = value;
|
|
}
|
|
get ContentPrice() {
|
|
return this.Portions * this.portion.price;
|
|
}
|
|
get Portions() {
|
|
return this.content.size / (this.portion.size || 1);
|
|
}
|
|
}
|
|
|
|
Article.thaw = function (json) {
|
|
var article = new Article();
|
|
article.id = json.id;
|
|
article.Name = json.name;
|
|
article.Short = json.short;
|
|
article.Dimension = json.dimension;
|
|
article.ContentSize = json.content.size;
|
|
article.PortionPrice = json.portion.price;
|
|
article.PortionSize = json.portion.size;
|
|
article.PortionType = json.portion.type;
|
|
|
|
return article;
|
|
};
|
|
|
|
export const thawArticle = Article.thaw; |