summaryrefslogtreecommitdiff
path: root/iridescence/src/models
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-11-12 16:27:13 -0500
committerAdam T. Carpenter <atc@53hor.net>2020-11-12 16:27:13 -0500
commit9b77f9ec2c00b48c551f65b2e9d7a087004de4c0 (patch)
treeb7eb96fc4a2c7baffcb4acfc93c572ab079f11a2 /iridescence/src/models
parent7381a7033231e6454a37fd64b1f3de4e8d59355f (diff)
downloadtheglassyladies-9b77f9ec2c00b48c551f65b2e9d7a087004de4c0.tar.xz
theglassyladies-9b77f9ec2c00b48c551f65b2e9d7a087004de4c0.zip
Noice. Product creation and updating is totally functional.
Diffstat (limited to 'iridescence/src/models')
-rw-r--r--iridescence/src/models/product.js4
-rw-r--r--iridescence/src/models/product_diff.js43
2 files changed, 2 insertions, 45 deletions
diff --git a/iridescence/src/models/product.js b/iridescence/src/models/product.js
index c408b79..ded5434 100644
--- a/iridescence/src/models/product.js
+++ b/iridescence/src/models/product.js
@@ -4,8 +4,8 @@ export default class Product {
this.id = json.id ? json.id : null;
this.name = json.name ? json.name : null;
this.description = json.description ? json.description : null;
- this.cents = json.cents ? json.cents : null;
- this.quantity = json.quantity ? json.quantity : null;
+ this.cents = Number.isFinite(json.cents) ? json.cents : null;
+ this.quantity = Number.isFinite(json.quantity) ? json.quantity : null;
this.featured = json.featured ? json.featured : false;
this.category = json.category ? json.category : null;
this.photo_base = json.photo_base ? json.photo_base : null;
diff --git a/iridescence/src/models/product_diff.js b/iridescence/src/models/product_diff.js
deleted file mode 100644
index a683102..0000000
--- a/iridescence/src/models/product_diff.js
+++ /dev/null
@@ -1,43 +0,0 @@
-export default class ProductDiff {
- constructor(product) {
- if (product) {
- this.id = product.id ? product.id : 0;
- this.name = product.name ? product.name : null;
- this.description = product.description ? product.description : null;
- this.cents = product.cents ? product.cents : null;
- this.quantity = product.quantity ? product.quantity : null;
- this.featured =
- typeof product.featured === "boolean" ? product.featured : null;
- this.category_path = product.category ? product.category : null;
- this.photo_set = null;
- }
- }
-
- isValidPost() {
- return (
- !this.id &&
- this.name &&
- this.description &&
- this.cents &&
- !this.quantity.isNaN &&
- this.photo_set &&
- this.category_path &&
- this.description &&
- typeof this.featured === "boolean"
- );
- }
-
- isValidPatch(product) {
- return (
- this.id &&
- (this.photo_set ||
- (this.name && this.name != product.name) ||
- (this.cents && this.cents != product.cents) ||
- (this.category_path && this.category_path != product.category) ||
- (this.quantity && this.quantity != product.quantity) ||
- (this.description && this.description != product.description) ||
- (typeof this.featured === "boolean" &&
- this.featured != product.featured))
- );
- }
-}