Commit 208edcd6 authored by prumde's avatar prumde

Updated


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@174449 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 63a723ef
...@@ -216,7 +216,9 @@ export class EcmProductDetailsComponent implements OnInit { ...@@ -216,7 +216,9 @@ export class EcmProductDetailsComponent implements OnInit {
} }
removeFromWishlist( itemCode ) { removeFromWishlist( itemCode ) {
this.store.dispatch({ type: REMOVE_WISLIST, payload: itemCode }); let cartData = new Item;
cartData.itemCode = itemCode;
this.store.dispatch({ type: REMOVE_WISLIST, payload: cartData });
this.productDetailService.removeFromWishlist( itemCode ); this.productDetailService.removeFromWishlist( itemCode );
} }
......
...@@ -4,7 +4,7 @@ import { EcmCartService } from '../ecm-view/ecm-cart/ecm-cart.service'; ...@@ -4,7 +4,7 @@ import { EcmCartService } from '../ecm-view/ecm-cart/ecm-cart.service';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { EcmStoreModel } from '../ecm-store/ecm-store.model'; import { EcmStoreModel } from '../ecm-store/ecm-store.model';
import { RESET } from '../ecm-store/ecm-store'; import { RESET,RESET_WISHLIST } from '../ecm-store/ecm-store';
declare var getContentPlugin: any; declare var getContentPlugin: any;
...@@ -83,6 +83,7 @@ export class EcmUserOptionComponent implements OnInit { ...@@ -83,6 +83,7 @@ export class EcmUserOptionComponent implements OnInit {
localStorage.removeItem( 'userInfo' ); localStorage.removeItem( 'userInfo' );
this.store.dispatch({ type: RESET }); this.store.dispatch({ type: RESET });
this.store.dispatch({ type: RESET_WISHLIST });
this.signinService.sendLogout( this.userData.jti, this.userData.TOKEN_ID ).subscribe( this.signinService.sendLogout( this.userData.jti, this.userData.TOKEN_ID ).subscribe(
result => { result => {
...@@ -93,6 +94,7 @@ export class EcmUserOptionComponent implements OnInit { ...@@ -93,6 +94,7 @@ export class EcmUserOptionComponent implements OnInit {
this.userData = null; this.userData = null;
localStorage.removeItem( 'userInfo' ); localStorage.removeItem( 'userInfo' );
this.store.dispatch({ type: RESET }); this.store.dispatch({ type: RESET });
this.store.dispatch({ type: RESET_WISHLIST });
this.cartService.setCartItems(); this.cartService.setCartItems();
} }
else if ( result.Response.status == 'error' ) { else if ( result.Response.status == 'error' ) {
......
...@@ -104,6 +104,9 @@ ...@@ -104,6 +104,9 @@
.total-description { .total-description {
width: 70%; width: 70%;
} }
.deleteCart{
padding-left: 7px !important;
}
.ecm-productDetails{ .ecm-productDetails{
padding: 0px !important; padding: 0px !important;
} }
...@@ -222,20 +225,19 @@ ...@@ -222,20 +225,19 @@
border-radius: 2px; border-radius: 2px;
background: white; background: white;
color: mediumvioletred; color: mediumvioletred;
position: relative; /* position: relative; */
float: right; /* float: right; */
width: 100%; width: 100%;
margin-top: 15px; margin-top: 15px;
margin-bottom: 15px; margin-bottom: 15px;
} }
.item-image{ .item-image{
/* width: 140px; /* width: 16%; */
padding-top: 16px;
position: relative; */
width: 16%;
display: inline-block; display: inline-block;
position: relative; position: relative;
bottom: 16px; vertical-align: top;
padding-top: 18px;
width: 120px;
} }
.change-color{ .change-color{
...@@ -335,8 +337,9 @@ ...@@ -335,8 +337,9 @@
background-color: ghostwhite; background-color: ghostwhite;
} }
.delete-cartitems-button{ .delete-cartitems-button{
padding-bottom: 20px; /* padding-bottom: 20px;
padding-top: 36px; padding-top: 36px; */
padding-left: 8px;
} }
.continue-shopping{ .continue-shopping{
...@@ -504,7 +507,7 @@ ...@@ -504,7 +507,7 @@
.total-description{ .total-description{
display: inline-block; display: inline-block;
position: inherit; position: inherit;
padding-left: 15px;
} }
.counter-screen{ .counter-screen{
display: inline-block; display: inline-block;
...@@ -549,5 +552,9 @@ ...@@ -549,5 +552,9 @@
display: none; display: none;
} }
.deleteCart{
padding-left: 28px;
padding-top: 40px;
}
\ No newline at end of file
...@@ -134,8 +134,8 @@ export class EcmCartComponent implements OnInit, AfterViewChecked { ...@@ -134,8 +134,8 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
confirmDialog( item: any ) { confirmDialog( item: any ) {
this.cartService.setItemCode( item.itemCode ); this.cartService.setItemCode( item.itemCode );
let dialogRef = this.dialog.open( ECMConfirmDialog,{ let dialogRef = this.dialog.open( ECMConfirmDialog,{
width:'250px', width:'300px',
height:'150px', height:'180px',
disableClose: true disableClose: true
}); });
dialogRef.componentInstance.dialogTitle = "Remove Item from cart?"; dialogRef.componentInstance.dialogTitle = "Remove Item from cart?";
......
...@@ -18,18 +18,6 @@ private userActionUrl = '/ecm/service/feeds/cart'; ...@@ -18,18 +18,6 @@ private userActionUrl = '/ecm/service/feeds/cart';
constructor(private http: Http, private store: Store<EcmStoreModel>) { } constructor(private http: Http, private store: Store<EcmStoreModel>) { }
getCartItems() {
let cartItems;
this.store.select('cart').forEach(
value => {
cartItems=value;
}
);
return cartItems;
}
setCartItems(){ setCartItems(){
this.fetchCartItems().subscribe( this.fetchCartItems().subscribe(
data => { data => {
......
<!--
<div class="deleteCart"> <div class="deleteCart">
<i class="material-icons" style="color: mediumvioletred;">remove_shopping_cart</i> <i class="material-icons" style="color: mediumvioletred;font-size: 26px;padding-bottom: 22px;">remove_shopping_cart</i>
<span style="font-size: 16px;padding-left: 12px;position: relative;bottom: 6px;">Remove the item from the cart ?</span> <span style="font-size: 19px;position: relative;bottom: 6px;">{{dialogTitle}}</span>
<div md-dialog-content>{{confirmMsg}}</div>
<div md-dialog-actions class="delete-cartitems-button"> <div md-dialog-actions class="delete-cartitems-button">
<button style="background-color: mediumvioletred;color: white;" md-button md-dialog-close="Option 1" ">Yes</button> <button style="background-color: mediumvioletred;color: white;" md-button md-dialog-close="false">{{cancelText}}</button>
<button class="no-button" md-button md-dialog-close="Option 2">No</button> <button class="no-button" md-button md-dialog-close="true">{{confirmText}}</button>
</div> </div>
</div> </div>
-->
<!--
<h1 md-dialog-title>{{dialogTitle}}</h1> <h1 md-dialog-title>{{dialogTitle}}</h1>
<div md-dialog-content>{{confirmMsg}}</div> <div md-dialog-content>{{confirmMsg}}</div>
<div md-dialog-actions> <div md-dialog-actions>
<button md-button md-dialog-close="false">{{cancelText}}</button> <button md-button md-dialog-close="false">{{cancelText}}</button>
<button md-button md-dialog-close="true">{{confirmText}}</button> <button md-button md-dialog-close="true">{{confirmText}}</button>
</div> </div> -->
\ No newline at end of file \ No newline at end of file
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
width: 10%; width: 10%;
display: inline-block; display: inline-block;
position: relative; position: relative;
bottom: 38px; bottom: 96px;
} }
.change-color{ .change-color{
......
<div *ngIf="wishListItems"> <div *ngIf="wishListItems | async">
<ecm-header [isFixedHeader]=false> </ecm-header> <ecm-header [isFixedHeader]=false> </ecm-header>
<ecm-breadcrumbs [pageName]="'WISHLIST'"></ecm-breadcrumbs> <ecm-breadcrumbs [pageName]="'WISHLIST'"></ecm-breadcrumbs>
<div class="row details-of-Cart"> <div class="row details-of-Cart">
<md-card class="medium-12 columns cartItemsDetails"> <md-card class="medium-12 columns cartItemsDetails">
<div class="ecmdetailsItems"> <div class="ecmdetailsItems">
<div class="ecm-headings"> <div class="ecm-headings">
<span class="my-cart-title">My Wishlist ({{cartCount}})</span> <span class="my-cart-title">My Wishlist ( {{(wishListItems | async)?.length}} )</span>
</div> </div>
<div class="listItems" *ngFor="let item of wishListItems"> <div class="listItems" *ngFor="let item of wishListItems | async">
<div class="item-image"> <div class="item-image">
<ecm-image [refId]='item.itemCode' [refSer]="'M-ITEM'" <ecm-image [refId]='item.itemCode' [refSer]="'M-ITEM'"
[object]="'ITEM'" [isSingleImage]="true" [isThumbnail]="true"></ecm-image> [object]="'ITEM'" [isSingleImage]="true" [isThumbnail]="true"></ecm-image>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<div class="counter-screen"> <div class="counter-screen">
<div class="wish-remove-dipslay"> <div class="wish-remove-dipslay">
<!-- <span class="remove-items" (click)=" confirmDialog(item)" style="cursor: pointer;">Remove</span> --> <!-- <span class="remove-items" (click)=" confirmDialog(item)" style="cursor: pointer;">Remove</span> -->
<span class="remove-items" (click)="deleteCartItem(item.itemCode) "><i class="material-icons" style="font-size: 24px;color: mediumvioletred;">delete</i></span> <span class="remove-items" (click)="deletewishlistItem(item) "><i class="material-icons" style="font-size: 24px;color: mediumvioletred;">delete</i></span>
</div> </div>
</div> </div>
......
...@@ -6,6 +6,10 @@ import { ItemDetail } from '../../ecm-model/product-detail-model'; ...@@ -6,6 +6,10 @@ import { ItemDetail } from '../../ecm-model/product-detail-model';
import { EcmProductDetailService } from '../../ecm-product-details/ecm-product-detail.service'; import { EcmProductDetailService } from '../../ecm-product-details/ecm-product-detail.service';
import { Http} from '@angular/http' import { Http} from '@angular/http'
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import { Store } from '@ngrx/store';
import { EcmStoreModel } from '../../ecm-store/ecm-store.model';
import { REMOVE_WISLIST } from '../../ecm-store/ecm-store';
import { Observable } from 'rxjs/Observable';
@Component({ @Component({
...@@ -15,53 +19,40 @@ import { Router, ActivatedRoute } from '@angular/router'; ...@@ -15,53 +19,40 @@ import { Router, ActivatedRoute } from '@angular/router';
providers: [EcmProductDetailService] providers: [EcmProductDetailService]
}) })
export class EcmWishListComponent implements OnInit { export class EcmWishListComponent implements OnInit {
wishListItems: Item[]; // wishListDetail: Item;
wishListItems: Observable<Item[]>;
errorMessage: string; errorMessage: string;
cartCount = 0; cartCount = 0;
constructor(public subcategoryService: EcmProductDetailService,private route: ActivatedRoute,private router: Router,public snackBar: MdSnackBar,public wishListService: EcmWishListService, private http: Http) {} constructor( public subcategoryService: EcmProductDetailService, private route: ActivatedRoute, private router: Router, public snackBar: MdSnackBar, public wishListService: EcmWishListService, private http: Http, private store: Store<EcmStoreModel> ) { }
ngOnInit() { ngOnInit() {
this.getWishlistItems(); this.getWishlistItems();
} }
/* getWishlistItems() { getWishlistItems() {
this.wishListService.getWishlistItems().subscribe( this.wishListItems = this.store.select( 'wishlist' );
wishListItems => { this.store.select( 'wishlist' ).forEach(
this.wishListItems = wishListItems; value => {
console.log( 'comp recentItems[' + JSON.stringify( wishListItems ) + '] \n this.trendingItems[' + JSON.stringify( this.wishListItems ) + ']' ); console.log( 'wishlist Items----' );
}, console.log( value );
error => { }
this.errorMessage = <any>error; );
console.log( 'comp errorMessage[' + this.errorMessage + ']' );
});
} */
getWishlistItems(){
this.wishListService.getWishlistItems().subscribe(
wishListItems => {
this.wishListItems = wishListItems;
this.cartCount = this.wishListItems.length ;
console.log( 'comp wishListItems[' + this.wishListItems + '] \n this.wishListItems[' + this.wishListItems.length + ']' );
},
error => {
let errorMessage = <any>error;
console.log( 'comp errorMessage[' + errorMessage + ']' );
});
} }
userActionUrl = '/ecm/service/feeds/wishlist'; userActionUrl = '/ecm/service/feeds/wishlist';
deleteCartItem( itemCode ) { deletewishlistItem( item ) {
console.log( "deleteCartItem Called" ); this.store.dispatch( { type: REMOVE_WISLIST, payload: item });
this.http.delete( this.userActionUrl + '/' + itemCode, {})
this.http.delete( this.userActionUrl + '/' + item.itemCode, {})
.subscribe( data => { .subscribe( data => {
console.log( "deleted item in wishlist" ); console.log( "deleted item in wishlist" );
}, error => { }, error => {
console.log( error.json() ); console.log( error.json() );
}); });
this. getWishlistItems(); this.getWishlistItems();
this.openSnackBar('Item Removed from your wishlist' ); this.openSnackBar( 'Item Removed from your wishlist' );
} }
openSnackBar( message: string ) { openSnackBar( message: string ) {
...@@ -70,10 +61,8 @@ export class EcmWishListComponent implements OnInit { ...@@ -70,10 +61,8 @@ export class EcmWishListComponent implements OnInit {
}); });
} }
addToWishlist(data:Item) { addToWishlist( data: Item ) {
this.subcategoryService.addToWishlist( data );
// this.store.dispatch({ type: INCREMENT, payload: cartData });
this.subcategoryService.addToWishlist(data);
} }
viewItem( itemCode ) { viewItem( itemCode ) {
......
...@@ -3,19 +3,33 @@ import { Http, Response, Headers, RequestOptions } from '@angular/http'; ...@@ -3,19 +3,33 @@ import { Http, Response, Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import { Store } from '@ngrx/store';
import { ADD_TO_WISHLIST } from '../../ecm-store/ecm-store';
import { Item } from '../../ecm-model/product-model'; import { Item } from '../../ecm-model/product-model';
import { EcmStoreModel } from '../../ecm-store/ecm-store.model';
@Injectable() @Injectable()
export class EcmWishListService { export class EcmWishListService {
private wishListUrl = '/ecm/service/feeds/wishlist'; // URL to web service private wishListUrl = '/ecm/service/feeds/wishlist'; // URL to web service
wishListItems: Item[];
constructor( private http: Http, private store: Store<EcmStoreModel> ) { }
setWishlistItems() {
this.fetchWishlistItems().subscribe(
data => {
this.wishListItems = data;
if ( data && data != null ) {
this.wishListItems.forEach( item => {
this.store.dispatch( { type: ADD_TO_WISHLIST, payload: item });
})
}
});
}
constructor(private http: Http) { } fetchWishlistItems(): Observable<Item[]> {
getWishlistItems(): Observable<Item[]> {
let headers = new Headers( { 'Content-Type': 'application/json' }); let headers = new Headers( { 'Content-Type': 'application/json' });
let options = new RequestOptions( { headers: headers }); let options = new RequestOptions( { headers: headers });
...@@ -24,34 +38,23 @@ export class EcmWishListService { ...@@ -24,34 +38,23 @@ export class EcmWishListService {
.catch( this.handleError ); .catch( this.handleError );
} }
storeWishlistItem(itemCode) { private extractData( res: Response ) {
this.http.post(this.wishListUrl+'/'+itemCode, {})
.subscribe(data => {
console.log("Inserted in wishList");
}, error => {
console.log(error.json());
});
}
private extractData(res: Response) {
let body = res.json(); let body = res.json();
console.log('extractData[' + JSON.stringify(body) + ']'); console.log( 'extractData[' + JSON.stringify( body ) + ']' );
return body || { }; return body || {};
} }
private handleError (error: Response | any) { private handleError( error: Response | any ) {
// In a real world app, we might use a remote logging infrastructure // In a real world app, we might use a remote logging infrastructure
let errMsg: string; let errMsg: string;
if (error instanceof Response) { if ( error instanceof Response ) {
const body = error.json() || ''; const body = error.json() || '';
const err = body.error || JSON.stringify(body); const err = body.error || JSON.stringify( body );
errMsg = `${error.status} - ${error.statusText || ''} ${err}`; errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
} else { } else {
errMsg = error.message ? error.message : error.toString(); errMsg = error.message ? error.message : error.toString();
} }
console.error('Service handleError:' + errMsg); console.error( 'Service handleError:' + errMsg );
return Observable.throw(errMsg); return Observable.throw( errMsg );
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment