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 {
}
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 );
}
......
......@@ -4,7 +4,7 @@ import { EcmCartService } from '../ecm-view/ecm-cart/ecm-cart.service';
import { Store } from '@ngrx/store';
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;
......@@ -83,6 +83,7 @@ export class EcmUserOptionComponent implements OnInit {
localStorage.removeItem( 'userInfo' );
this.store.dispatch({ type: RESET });
this.store.dispatch({ type: RESET_WISHLIST });
this.signinService.sendLogout( this.userData.jti, this.userData.TOKEN_ID ).subscribe(
result => {
......@@ -93,6 +94,7 @@ export class EcmUserOptionComponent implements OnInit {
this.userData = null;
localStorage.removeItem( 'userInfo' );
this.store.dispatch({ type: RESET });
this.store.dispatch({ type: RESET_WISHLIST });
this.cartService.setCartItems();
}
else if ( result.Response.status == 'error' ) {
......
......@@ -104,6 +104,9 @@
.total-description {
width: 70%;
}
.deleteCart{
padding-left: 7px !important;
}
.ecm-productDetails{
padding: 0px !important;
}
......@@ -222,20 +225,19 @@
border-radius: 2px;
background: white;
color: mediumvioletred;
position: relative;
float: right;
/* position: relative; */
/* float: right; */
width: 100%;
margin-top: 15px;
margin-bottom: 15px;
}
.item-image{
/* width: 140px;
padding-top: 16px;
position: relative; */
width: 16%;
/* width: 16%; */
display: inline-block;
position: relative;
bottom: 16px;
vertical-align: top;
padding-top: 18px;
width: 120px;
}
.change-color{
......@@ -335,9 +337,10 @@
background-color: ghostwhite;
}
.delete-cartitems-button{
padding-bottom: 20px;
padding-top: 36px;
}
/* padding-bottom: 20px;
padding-top: 36px; */
padding-left: 8px;
}
.continue-shopping{
float: right;
......@@ -504,7 +507,7 @@
.total-description{
display: inline-block;
position: inherit;
padding-left: 15px;
}
.counter-screen{
display: inline-block;
......@@ -549,5 +552,9 @@
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 {
confirmDialog( item: any ) {
this.cartService.setItemCode( item.itemCode );
let dialogRef = this.dialog.open( ECMConfirmDialog,{
width:'250px',
height:'150px',
width:'300px',
height:'180px',
disableClose: true
});
dialogRef.componentInstance.dialogTitle = "Remove Item from cart?";
......
......@@ -18,18 +18,6 @@ private userActionUrl = '/ecm/service/feeds/cart';
constructor(private http: Http, private store: Store<EcmStoreModel>) { }
getCartItems() {
let cartItems;
this.store.select('cart').forEach(
value => {
cartItems=value;
}
);
return cartItems;
}
setCartItems(){
this.fetchCartItems().subscribe(
data => {
......
<!--
<div class="deleteCart">
<i class="material-icons" style="color: mediumvioletred;">remove_shopping_cart</i>
<span style="font-size: 16px;padding-left: 12px;position: relative;bottom: 6px;">Remove the item from the cart ?</span>
<i class="material-icons" style="color: mediumvioletred;font-size: 26px;padding-bottom: 22px;">remove_shopping_cart</i>
<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">
<button style="background-color: mediumvioletred;color: white;" md-button md-dialog-close="Option 1" ">Yes</button>
<button class="no-button" md-button md-dialog-close="Option 2">No</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="true">{{confirmText}}</button>
</div>
</div>
-->
<!--
<h1 md-dialog-title>{{dialogTitle}}</h1>
<div md-dialog-content>{{confirmMsg}}</div>
<div md-dialog-actions>
<button md-button md-dialog-close="false">{{cancelText}}</button>
<button md-button md-dialog-close="true">{{confirmText}}</button>
</div>
\ No newline at end of file
</div> -->
\ No newline at end of file
......@@ -233,7 +233,7 @@
width: 10%;
display: inline-block;
position: relative;
bottom: 38px;
bottom: 96px;
}
.change-color{
......
<div *ngIf="wishListItems">
<div *ngIf="wishListItems | async">
<ecm-header [isFixedHeader]=false> </ecm-header>
<ecm-breadcrumbs [pageName]="'WISHLIST'"></ecm-breadcrumbs>
<div class="row details-of-Cart">
<md-card class="medium-12 columns cartItemsDetails">
<div class="ecmdetailsItems">
<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 class="listItems" *ngFor="let item of wishListItems">
<div class="listItems" *ngFor="let item of wishListItems | async">
<div class="item-image">
<ecm-image [refId]='item.itemCode' [refSer]="'M-ITEM'"
[object]="'ITEM'" [isSingleImage]="true" [isThumbnail]="true"></ecm-image>
......@@ -28,7 +28,7 @@
<div class="counter-screen">
<div class="wish-remove-dipslay">
<!-- <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>
......
......@@ -6,6 +6,10 @@ import { ItemDetail } from '../../ecm-model/product-detail-model';
import { EcmProductDetailService } from '../../ecm-product-details/ecm-product-detail.service';
import { Http} from '@angular/http'
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({
......@@ -15,67 +19,52 @@ import { Router, ActivatedRoute } from '@angular/router';
providers: [EcmProductDetailService]
})
export class EcmWishListComponent implements OnInit {
wishListItems: Item[];
errorMessage: string;
cartCount = 0;
// wishListDetail: Item;
wishListItems: Observable<Item[]>;
errorMessage: string;
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() {
this.getWishlistItems();
}
/* getWishlistItems() {
this.wishListService.getWishlistItems().subscribe(
wishListItems => {
this.wishListItems = wishListItems;
console.log( 'comp recentItems[' + JSON.stringify( wishListItems ) + '] \n this.trendingItems[' + JSON.stringify( this.wishListItems ) + ']' );
},
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 + ']' );
});
ngOnInit() {
this.getWishlistItems();
}
getWishlistItems() {
this.wishListItems = this.store.select( 'wishlist' );
this.store.select( 'wishlist' ).forEach(
value => {
console.log( 'wishlist Items----' );
console.log( value );
}
);
}
userActionUrl = '/ecm/service/feeds/wishlist';
deleteCartItem( itemCode ) {
console.log( "deleteCartItem Called" );
this.http.delete( this.userActionUrl + '/' + itemCode, {})
deletewishlistItem( item ) {
this.store.dispatch( { type: REMOVE_WISLIST, payload: item });
this.http.delete( this.userActionUrl + '/' + item.itemCode, {})
.subscribe( data => {
console.log( "deleted item in wishlist" );
}, error => {
console.log( error.json() );
});
this. getWishlistItems();
this.openSnackBar('Item Removed from your wishlist' );
});
this.getWishlistItems();
this.openSnackBar( 'Item Removed from your wishlist' );
}
openSnackBar( message: string ) {
openSnackBar( message: string ) {
this.snackBar.open( message, '', {
duration: 2000,
});
}
addToWishlist(data:Item) {
// this.store.dispatch({ type: INCREMENT, payload: cartData });
this.subcategoryService.addToWishlist(data);
}
addToWishlist( data: Item ) {
this.subcategoryService.addToWishlist( data );
}
viewItem( itemCode ) {
this.router.navigate( ['/detail', itemCode] );
}
......
......@@ -3,19 +3,33 @@ import { Http, Response, Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
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 { EcmStoreModel } from '../../ecm-store/ecm-store.model';
@Injectable()
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) { }
getWishlistItems(): Observable<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 });
})
}
});
}
fetchWishlistItems(): Observable<Item[]> {
let headers = new Headers( { 'Content-Type': 'application/json' });
let options = new RequestOptions( { headers: headers });
......@@ -23,35 +37,24 @@ export class EcmWishListService {
.map( this.extractData )
.catch( this.handleError );
}
storeWishlistItem(itemCode) {
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();
console.log('extractData[' + JSON.stringify(body) + ']');
return body || { };
}
private handleError (error: Response | any) {
// In a real world app, we might use a remote logging infrastructure
let errMsg: string;
if (error instanceof Response) {
const body = error.json() || '';
const err = body.error || JSON.stringify(body);
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
} else {
errMsg = error.message ? error.message : error.toString();
}
console.error('Service handleError:' + errMsg);
return Observable.throw(errMsg);
private extractData( res: Response ) {
let body = res.json();
console.log( 'extractData[' + JSON.stringify( body ) + ']' );
return body || {};
}
private handleError( error: Response | any ) {
// In a real world app, we might use a remote logging infrastructure
let errMsg: string;
if ( error instanceof Response ) {
const body = error.json() || '';
const err = body.error || JSON.stringify( body );
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
} else {
errMsg = error.message ? error.message : error.toString();
}
console.error( 'Service handleError:' + 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