From 6bf9da5b77c88a62a4cb53ef8b428fe5d5fac561 Mon Sep 17 00:00:00 2001 From: Le Deng Date: Fri, 10 Mar 2017 12:20:55 -0500 Subject: [PATCH] latest --- bookstore-api/.idea/workspace.xml | 14 ++--- .../resource/ShoppingCartResource.java | 4 +- .../resource/ShoppingCartResource.class | Bin 5205 -> 5210 bytes .../shopping-cart.component.html | 48 +++++++++--------- .../shopping-cart/shopping-cart.component.ts | 13 +++++ store-front/src/app/models/cart-item.ts | 2 +- store-front/src/app/services/cart.service.ts | 4 +- 7 files changed, 50 insertions(+), 35 deletions(-) diff --git a/bookstore-api/.idea/workspace.xml b/bookstore-api/.idea/workspace.xml index c92ac6e..07b7465 100644 --- a/bookstore-api/.idea/workspace.xml +++ b/bookstore-api/.idea/workspace.xml @@ -151,8 +151,8 @@ - - + + @@ -1038,12 +1038,12 @@ - + - @@ -1067,7 +1067,7 @@ - + @@ -1555,8 +1555,8 @@ - - + + diff --git a/bookstore-api/src/main/java/com/bookstore/resource/ShoppingCartResource.java b/bookstore-api/src/main/java/com/bookstore/resource/ShoppingCartResource.java index 3943dfc..05db602 100644 --- a/bookstore-api/src/main/java/com/bookstore/resource/ShoppingCartResource.java +++ b/bookstore-api/src/main/java/com/bookstore/resource/ShoppingCartResource.java @@ -91,7 +91,7 @@ public class ShoppingCartResource { } @RequestMapping("/updateCartItem") - public ResponseEntity updateShoppingCart( + public ResponseEntity updateCartItem( @RequestBody HashMap mapper ) { String cartItemId = mapper.get("cartItemId"); @@ -102,7 +102,7 @@ public class ShoppingCartResource { cartItemService.updateCartItem(cartItem); - return new ResponseEntity("Cart Updated Successfully!", HttpStatus.OK); + return new ResponseEntity("Cart Item Updated Successfully!", HttpStatus.OK); } } diff --git a/bookstore-api/target/classes/com/bookstore/resource/ShoppingCartResource.class b/bookstore-api/target/classes/com/bookstore/resource/ShoppingCartResource.class index 32fbc0a76d31b55da95f3da69fadb7ea18077108..034ddab00c35d829215634ff7787eb669496d1e5 100644 GIT binary patch delta 104 zcmcbraZ6)^H9J3FX+cV2Nvd;VQHf_sYVKw~c10%My$t(!81^$9;9)q(aA+SA$b(cXfR%6J^k)$kf|wDUkzY`dnU@Zdo&2Bo(`F|AU{(MyEhCx$ delta 97 zcmcbmaaCi3HTz^HKGDrS?D9;!DGYmg81^yj=V3U&aBy-3r;5-a9)`mVM|c>HG8|)M zkaA8eD%rf5)1QUWWAc1nwaIpTCx!V+3sMqGQbAIlC8@cL3=SHTKd{Pg*5Ef{1pvPC B9rgeK diff --git a/store-front/src/app/components/shopping-cart/shopping-cart.component.html b/store-front/src/app/components/shopping-cart/shopping-cart.component.html index 7bbd71d..d24cf0e 100644 --- a/store-front/src/app/components/shopping-cart/shopping-cart.component.html +++ b/store-front/src/app/components/shopping-cart/shopping-cart.component.html @@ -14,12 +14,16 @@
+
+ Cart Item Updated Successfully! +
Oops, some of the products don't have enough stock. Please update product quantity.
@@ -36,32 +40,30 @@
-
-
-
- -
-
-

+
+
+ +
+
+

{{cartItem.book.title}}

-

In Stock

-

Only {{cartItem.book.inStockNumber}} In Stock -

-

Product Unavailable

- delete -
-
-
$In Stock

+

Only {{cartItem.book.inStockNumber}} In Stock +

+

Product Unavailable

+ delete +
+
+
${{cartItem.book.ourPrice}}
-
-
- - - -
- +

+
+ + + Update +

diff --git a/store-front/src/app/components/shopping-cart/shopping-cart.component.ts b/store-front/src/app/components/shopping-cart/shopping-cart.component.ts index 709466d..74e8530 100644 --- a/store-front/src/app/components/shopping-cart/shopping-cart.component.ts +++ b/store-front/src/app/components/shopping-cart/shopping-cart.component.ts @@ -17,6 +17,7 @@ export class ShoppingCartComponent implements OnInit { private cartItemList: CartItem[] = []; private cartItemNumber: number; private shoppingCart: ShoppingCart = new ShoppingCart(); + private cartItemUpdated:boolean; constructor(private router:Router, private cartService: CartService) { } @@ -37,6 +38,18 @@ export class ShoppingCartComponent implements OnInit { ); } + onUpdateCartItem(cartItem:CartItem) { + this.cartService.updateCartItem(cartItem.id, cartItem.qty).subscribe( + res=>{ + console.log(res.text()); + this.cartItemUpdated=true; + }, + error=>{ + console.log(error.text()); + } + ); + } + getCartItemList(){ this.cartService.getCartItemList().subscribe( res=>{ diff --git a/store-front/src/app/models/cart-item.ts b/store-front/src/app/models/cart-item.ts index 85d6c4f..2ae5aa2 100644 --- a/store-front/src/app/models/cart-item.ts +++ b/store-front/src/app/models/cart-item.ts @@ -10,5 +10,5 @@ export class CartItem { public book: Book; public shoppingCart: ShoppingCart; public order: Order; - + public toUpdate:boolean; } diff --git a/store-front/src/app/services/cart.service.ts b/store-front/src/app/services/cart.service.ts index 15de943..99ade3a 100644 --- a/store-front/src/app/services/cart.service.ts +++ b/store-front/src/app/services/cart.service.ts @@ -37,8 +37,8 @@ export class CartService { return this.http.get(url, {headers : tokenHeader}); } - updateShoppingCart(cartItemId:number, qty:number) { - let url = AppConst.serverPath+"/cart/removeItem"; + updateCartItem(cartItemId:number, qty:number) { + let url = AppConst.serverPath+"/cart/updateCartItem"; let cartItemInfo = { "cartItemId" : cartItemId, "qty" : qty