From 7381a7033231e6454a37fd64b1f3de4e8d59355f Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Wed, 11 Nov 2020 20:07:12 -0500 Subject: Kind of flailing with the UI; lots of API bugfixes though. --- iridescence/src/App.vue | 4 +- iridescence/src/api/dichroism.js | 18 ++++-- iridescence/src/components/Navbar.vue | 13 +--- iridescence/src/components/admin/NewProduct.vue | 12 ++-- .../src/components/admin/ProductEditCard.vue | 73 +++++++++++----------- .../src/components/admin/ProductEditList.vue | 2 +- iridescence/src/models/product.js | 62 ++++-------------- iridescence/src/models/product_diff.js | 43 +++++++++++++ iridescence/src/store/index.js | 33 +++++++--- iridescence/src/views/Admin.vue | 11 +++- 10 files changed, 153 insertions(+), 118 deletions(-) create mode 100644 iridescence/src/models/product_diff.js (limited to 'iridescence/src') diff --git a/iridescence/src/App.vue b/iridescence/src/App.vue index a586f83..debc599 100644 --- a/iridescence/src/App.vue +++ b/iridescence/src/App.vue @@ -29,5 +29,7 @@ export default { diff --git a/iridescence/src/api/dichroism.js b/iridescence/src/api/dichroism.js index 610941c..c2cc93c 100644 --- a/iridescence/src/api/dichroism.js +++ b/iridescence/src/api/dichroism.js @@ -18,7 +18,7 @@ export default class Dichroism { const photos = await this._sendRequest("photos", options); return photos.map(p => new PhotoSet(p)); } catch (err) { - console.error(err.message); + console.error("Dichroism: " + err.message); return null; } } @@ -28,7 +28,7 @@ export default class Dichroism { const products = await this._sendRequest("products", null); return products.map(p => new Product(p)); } catch (err) { - console.error(err.message); + console.error("Dichroism: " + err.message); return []; } } @@ -36,14 +36,17 @@ export default class Dichroism { async updateProduct(fieldDiff) { const options = { method: "PATCH", - body: fieldDiff + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(fieldDiff) }; try { const product = await this._sendRequest("products", options); return new Product(product); } catch (err) { - console.error(err.message); + console.error("Dichroism: " + err.message); return null; } } @@ -51,14 +54,17 @@ export default class Dichroism { async createProduct(newProduct) { const options = { method: "POST", - body: newProduct + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(newProduct) }; try { const product = await this._sendRequest("products", options); return new Product(product); } catch (err) { - console.error(err.message); + console.error("Dichroism: " + err.message); return null; } } diff --git a/iridescence/src/components/Navbar.vue b/iridescence/src/components/Navbar.vue index 0a66fa8..78627e9 100644 --- a/iridescence/src/components/Navbar.vue +++ b/iridescence/src/components/Navbar.vue @@ -36,14 +36,9 @@ > -