From 74c5bb3fa6fd725685ad549c972ec0dee58f1b6b Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Thu, 24 Sep 2020 20:18:09 -0400 Subject: fixed resizing issues with edit boxes; switched from panels to cards --- .../src/components/admin/NewProductModal.vue | 33 ++++-- .../src/components/admin/ProductEditCard.vue | 119 ++++++++++++--------- .../src/components/admin/ProductEditList.vue | 4 +- 3 files changed, 98 insertions(+), 58 deletions(-) (limited to 'iridescence/src/components/admin') diff --git a/iridescence/src/components/admin/NewProductModal.vue b/iridescence/src/components/admin/NewProductModal.vue index 228ee4c..8df0faa 100644 --- a/iridescence/src/components/admin/NewProductModal.vue +++ b/iridescence/src/components/admin/NewProductModal.vue @@ -1,24 +1,45 @@ diff --git a/iridescence/src/components/admin/ProductEditCard.vue b/iridescence/src/components/admin/ProductEditCard.vue index 9fdf0c6..8ea23b1 100644 --- a/iridescence/src/components/admin/ProductEditCard.vue +++ b/iridescence/src/components/admin/ProductEditCard.vue @@ -1,32 +1,37 @@ @@ -129,7 +134,7 @@ export default { } }, computed: { - newProductChanged() { + isDifferent() { // TODO: check categories! return ( this.newProduct.id != this.currentProduct.id || @@ -141,6 +146,14 @@ export default { this.newProduct.featured != this.currentProduct.featured ); }, + isValid() { + return ( + this.newProductPrice > 0 && + this.newProduct.name != "" && + this.newProduct.imgPath != "" && + this.newProduct.description != "" + ); + }, newProductQuantity: { get: function() { return this.newProduct.quantity; @@ -165,7 +178,13 @@ export default { }, methods: { saveProduct() { - this.$store.dispatch("updateProduct", this.newProduct); + if (this.newProduct.id == 0) { + // new product + this.$store.dispatch("createProduct", this.newProduct); + } else { + // update existing + this.$store.dispatch("updateProduct", this.newProduct); + } }, incrementQuantity(amount) { if (this.newProduct.quantity + amount >= 0) { diff --git a/iridescence/src/components/admin/ProductEditList.vue b/iridescence/src/components/admin/ProductEditList.vue index 128e7bb..ae57406 100644 --- a/iridescence/src/components/admin/ProductEditList.vue +++ b/iridescence/src/components/admin/ProductEditList.vue @@ -1,8 +1,8 @@