summaryrefslogtreecommitdiff
path: root/iridescence/src/models
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-11-08 21:26:34 -0500
committerAdam T. Carpenter <atc@53hor.net>2020-11-08 21:26:34 -0500
commitc5280144de096c274f185fade287ccd63b954ceb (patch)
tree169f1c2ad86c68e5ccb37494398c5e2db33dca3d /iridescence/src/models
parent7dd36c0e699a1154c7163f25bf488fbd63edeafe (diff)
downloadtheglassyladies-c5280144de096c274f185fade287ccd63b954ceb.tar.xz
theglassyladies-c5280144de096c274f185fade287ccd63b954ceb.zip
fixed up product models and api calls, working on new product form
Diffstat (limited to 'iridescence/src/models')
-rw-r--r--iridescence/src/models/product.js42
1 files changed, 40 insertions, 2 deletions
diff --git a/iridescence/src/models/product.js b/iridescence/src/models/product.js
index c826073..fb7fd68 100644
--- a/iridescence/src/models/product.js
+++ b/iridescence/src/models/product.js
@@ -10,7 +10,45 @@ export default class Product {
photo_thumbnail = "";
category = "";
- constructor(json) {
- Object.assign(this, json);
+ constructor(from) {
+ if (from) {
+ this.id = from.id;
+ this.name = from.name;
+ this.description = from.description;
+ this.cents = from.cents;
+ this.quantity = from.quantity;
+ this.featured = from.featured;
+ this.photo_base = from.photo_base;
+ this.photo_fullsize = from.photo_fullsize;
+ this.photo_thumbnail = from.photo_thumbnail;
+ this.category = from.category;
+ }
+ }
+
+ isDifferent(product) {
+ return (
+ this.id != product.id ||
+ this.name != product.name ||
+ this.quantity != product.quantity ||
+ this.cents != product.cents ||
+ this.photo_base != product.photo_base ||
+ this.photo_thumbnail != product.photo_thumbnail ||
+ this.photo_fullsize != product.photo_fullsize ||
+ this.description != product.description ||
+ this.featured != product.featured ||
+ this.category != product.category
+ );
+ }
+
+ isValid() {
+ return (
+ this.cents > 0 &&
+ this.name != "" &&
+ this.photo_thumbnail != "" &&
+ this.photo_base != "" &&
+ this.photo_fullsize != "" &&
+ this.category != "" &&
+ this.description != ""
+ );
}
}