Commit b0e1013a authored by prumde's avatar prumde

Updated


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@174471 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 87c844ea
......@@ -2,7 +2,7 @@ import { Component } from '@angular/core';
import {Location, LocationStrategy, PathLocationStrategy} from '@angular/common';
import {AppState} from './ecm-store/reducers';
import {CartActions, CategoryActions, MenuActions} from './ecm-store/actions';
import {CartActions, CategoryActions, MenuActions, WishListActions} from './ecm-store/actions';
import { Store } from '@ngrx/store';
@Component({
......@@ -14,7 +14,7 @@ import { Store } from '@ngrx/store';
export class AppComponent {
title = 'Proteus ECM';
location: Location;
constructor(location: Location, private store: Store<AppState>, private cartActions: CartActions, private categoryAction: CategoryActions, private menuAction:MenuActions) {
constructor(location: Location, private store: Store<AppState>, private cartAction: CartActions, private categoryAction: CategoryActions, private menuAction:MenuActions, private wishListAction: WishListActions) {
this.location = location;
console.log( ' this.location.path(true)[' + this.location.path(true) + ']');
this.checkAppState();
......@@ -24,7 +24,8 @@ export class AppComponent {
this.setItem('appstate', this.get('app_stat'), true );
this.setItem('TOKEN_ID', this.get('TOKEN_ID'), true );
this.store.dispatch(this.cartActions.loadCartItems());
this.store.dispatch(this.cartAction.loadCartItems());
this.store.dispatch(this.wishListAction.loadWishlistItems());
this.store.dispatch(this.categoryAction.loadCategories());
this.store.dispatch(this.menuAction.loadMenu());
......
......@@ -57,7 +57,7 @@ Overlay End -->
<ng-template #fixedHeaderLarge>
<md-toolbar color="primary">
<button [ngClass]="{onSelect: selectedOption === 'MENU'}" md-button (click)="menuAction();" class="square-button">
<button md-button (click)="menuAction();" class="square-button">
<span class="ecm-menu-icon ecm-menu-icon1"></span>
<span class="ecm-menu-icon ecm-menu-icon2"></span>
<span class="ecm-menu-icon ecm-menu-icon3"></span>
......@@ -66,7 +66,7 @@ Overlay End -->
<span class="siteHeading">{{siteHeading}}</span>
<ecm-search [compFadeState]="headerFadeState" [headerState]="'fixed'"></ecm-search>
<span (click)="cartAction();" >
<button [ngClass]="{onSelect: selectedOption === 'CART'}" md-button class="square-button">
<button md-button class="square-button">
<span *ngIf="(cartItems | async)?.length!=0" class="fixed-header-badge">{{(cartItems | async)?.length}}</span>
<img mdTooltip="Show Cart" [mdTooltipPosition]="'below'" class="fixed-header-cart img-cart-32" src="cart_32_32.svg"/>
<!-- <img *ngIf="cartItems == 0" class="fixed-header-cart img-cart-32 no-badge" /> -->
......@@ -74,7 +74,7 @@ Overlay End -->
</button>
</span>
<span (click)="userAction();" >
<button [ngClass]="{onSelect: selectedOption === 'USER'}" md-button class="square-button">
<button md-button class="square-button">
<img *ngIf="userData" mdTooltip="Click here to Manage Account" [mdTooltipPosition]="'below'" [src]="profileImageLink" onerror="this.src = '/ecm/assets/images/svg/user_32_32.svg'; this.className = 'fixed-header-no-user'" title="{{userData.name}}" [ngClass]="( userImage.src.indexOf('/ibase/') > 0 ) ? 'fixed-header-user' : 'fixed-header-no-user' " #userImage/>
<img *ngIf="!userData" mdTooltip="Click here for Login" [mdTooltipPosition]="'below'" class="fixed-header-no-user img-user-32" src="user_32_32.svg"/>
<!--<md-icon class="example-icon">account_circle</md-icon>-->
......
......@@ -10,7 +10,6 @@ import { RESIZE_EVENT } from '../ecm-store/ecm-resize';
import { EcmPanelComponent } from '../ecm-view/ecm-panel/ecm-panel.component';
import { ScrollService } from '../scroll.service';
import { EcmCartService } from '../ecm-view/ecm-cart/ecm-cart.service';
import 'rxjs/add/operator/filter';
//declare var initSearch: any;
......@@ -93,7 +92,7 @@ export class ECMHeaderComponent implements OnInit, OnDestroy {
cartCounter: number;
profileImageLink : string;
clientWidth: any;
constructor( @Inject( DOCUMENT ) private document: Document, private route: ActivatedRoute, private router: Router, private scroll_service: ScrollService, private store: Store<AppState>, public cartService: EcmCartService) { }
constructor( @Inject( DOCUMENT ) private document: Document, private route: ActivatedRoute, private router: Router, private scroll_service: ScrollService, private store: Store<AppState>) { }
ngOnInit() {
console.log( 'ECMHeaderComponent onInit' );
......@@ -176,32 +175,6 @@ export class ECMHeaderComponent implements OnInit, OnDestroy {
userAction() {
this.createUserData();
// if ( this.userData )
// this.ecmPanel.open('USER_OPT');
// else
// this.ecmPanel.open('SIGNIN_OPT');
//
// if( this.clientWidth < 640 )
// {
// //show overlay with user-option
// this.ecmPanel.updatePosition({ top:'0px', left: '0px' });
// this.ecmPanel.updateSize({ width:'100%', height: '100%' });
// }
// else
// {
// if ( this.userData )
// {
// //show sidepanel with user-option
// this.ecmPanel.updatePosition({ top:'65px', right: '20px' });
// this.ecmPanel.updateSize({ width:'300px', height: '400px' });
// }
// else {
// //show overlay with sign-in-option
// this.ecmPanel.updatePosition({ top:'100px', left: 'calc( 50% - 375px / 2 )' });
// this.ecmPanel.updateSize({ width:'375px', height: '535px' });
// }
// }
if( this.clientWidth < 640 )
{
//show overlay with user-option
......@@ -220,13 +193,6 @@ export class ECMHeaderComponent implements OnInit, OnDestroy {
{
//show sidepanel with user-option
this.ecmPanel.open({ type: 'inplace', option: 'USER_OPT', top:'65px', left: '', right: '20px', width:'300px', height: '400px' });
if(this.selectedOption){
this.selectedOption = null;
this.closeMenu();
}
else{
this.selectedOption = "USER";
}
}
else
{
......@@ -256,15 +222,7 @@ export class ECMHeaderComponent implements OnInit, OnDestroy {
}
else
{
this.ecmPanel.open({ type: 'inplace', option: 'CART_OPT', top:'65px', left: '', right: '75px', width:'360px', height: '500px' });
}
if(this.selectedOption){
this.selectedOption = null;
this.closeMenu();
}
else{
this.selectedOption = "CART";
this.ecmPanel.open({ type: 'inplace', option: 'CART_OPT', top:'65px', left: '', right: '75px', width:'360px', height: '' });
}
}
}
......@@ -281,14 +239,6 @@ export class ECMHeaderComponent implements OnInit, OnDestroy {
}
else {
this.ecmPanel.open({ type: 'inplace', option: 'MENU_OPT', hideClose: true , top:'60px', left: '16px', width:'280px', height: '70%' });
if(this.selectedOption){
this.selectedOption = null;
this.closeMenu();
}
else{
this.selectedOption = "MENU";
}
}
}
......
......@@ -60,47 +60,4 @@ export class EcmProductDetailService {
console.error('Service handleError:' + errMsg);
return Observable.throw(errMsg);
}
addToCart( cartData ) {
console.log( "StoreInCart Called" );
console.log(JSON.stringify(cartData));
let headers = new Headers( { 'Content-Type': 'application/json' });
let options = new RequestOptions( { headers: headers });
this.http.post( '/ecm/service/feeds/cart', JSON.stringify(cartData) , options)
.subscribe( data => {
console.log( "Inserted in Cart" );
}, error => {
console.log( error.json() );
});
}
addToWishlist(itemCode) {
console.log( "StoreInWishList Called" );
let headers = new Headers( { 'Content-Type': 'application/json' });
let options = new RequestOptions( { headers: headers });
this.http.post('/ecm/service/feeds/wishlist/'+itemCode, options)
.subscribe( data => {
console.log( "Inserted in wishList" );
}, error => {
console.log( error.json() );
});
}
removeFromWishlist(itemCode) {
console.log( "removeFromWishlist Called" );
let headers = new Headers( { 'Content-Type': 'application/json' });
let options = new RequestOptions( { headers: headers });
this.http.delete('/ecm/service/feeds/wishlist/'+itemCode, options)
.subscribe( data => {
console.log( "removed from wishList" );
}, error => {
console.log( error.json() );
});
}
}
......@@ -110,37 +110,6 @@ export class EcmProductDetailsComponent implements OnInit {
}
}
});
/*
this.productDetailService.getItemDetail( itemCode ).subscribe(
itemDetail => {
if( itemDetail ) console.log( 'comp itemCode[' + itemCode + '] itemDetail[' + itemDetail + '] \n this.itemDetail[' + JSON.stringify( itemDetail ) + ']' );
this.itemDetail = itemDetail;
if(this.itemDetail)
{
this.storeCatSubcat();
let ecmTemplateName = itemDetail.itemCategory.ecmTemplate;
console.log( "getItemDetail ecmTemplateName: " + ecmTemplateName )
this.ecmTemplate = ECM_TEMPLATES[ecmTemplateName];
this.scatCode = this.itemDetail.itemSubCategory.scatCode;
this.noOfReviews = this.itemDetail.itemRatings.NO_OF_REVIEWS;
console.log("Changed scatCode.."+this.scatCode);
if( this.ecmTemplate )
{
this.ecmTemplate.setItemDetail(itemDetail);
}
else
{
alert( "Sorry, the " + ecmTemplateName + " is not in the system yet!" );
}
}
console.log( 'comp ecmTemplate[' + this.ecmTemplate + ']' );
},
);
*/
}
scrollToReviews() {
......@@ -224,35 +193,16 @@ export class EcmProductDetailsComponent implements OnInit {
}
addToCart(item) {
//this.getAttributeType(itemCode);
//let cartData = new Item;
//cartData.itemCode = itemCode;
//cartData.itemQuantity = 1;
/*cartData.costRate = this.itemDetail.itemHeader.itemCostRate;
cartData.descr = this.itemDetail.itemHeader.itemDescr;
cartData.shDescr = this.itemDetail.itemHeader.itemShDescr;
if(this.attribCode == "COLOR"){
cartData.phyAttribId3 = this.attribVal;
}
else if(this.attribCode == "SIZE"){
cartData.phyAttribId1 = this.attribVal;
}
*/
item.itemQuantity = 1;
this.store.dispatch(this.cartActions.addToCartSuccess(item));
//this.store.dispatch({ type: ADD_TO_CART, payload: cartData });
//this.productDetailService.addToCart(cartData);
}
addToWishlist( item ) {
this.store.dispatch(this.wishListAction.addToWishlistSuccess(item));
this.productDetailService.addToWishlist( item.itemCode );
}
removeFromWishlist( item ) {
this.store.dispatch(this.wishListAction.deleteWishlistItemSuccess(item));
this.productDetailService.removeFromWishlist( item.itemCode );
}
showSnackbar( message ) {
......
......@@ -2,7 +2,7 @@ import { Component, Input, OnChanges, Inject, Output, EventEmitter, ViewChild }
import { Reviews } from '../ecm-model/product-review.model';
import { EcmProductReviewService } from './ecm-product-review.service';
import { ItemDetail } from '../ecm-model/product-detail-model';
import {MdDialog, MdDialogRef, MdDialogConfig, MD_DIALOG_DATA} from '@angular/material';
import { MdDialog, MdDialogRef, MdDialogConfig, MD_DIALOG_DATA } from '@angular/material';
import { FormBuilder, Validators,NgForm } from '@angular/forms';
@Component( {
......@@ -142,8 +142,7 @@ export class EcmProductReviewComponent implements OnChanges {
}
ngOnChanges(){
if(this.itemDetail)
{
if ( this.itemDetail ) {
this.itemCode = this.itemDetail.itemCode;
this.itemAvgRating = this.itemDetail.itemRatings.AVG_RATING;
}
......@@ -186,7 +185,6 @@ export class ECMWriteReviewDialog {
this.reviewData.productRating = this.userReview.rating;
this.reviewData.productRemarks = this.userReview.remarks;
this.reviewData.productComments = this.userReview.comments;
}
this.reviewData.item_code = this.detail.itemCode;
......
......@@ -8,8 +8,6 @@ import { AppState } from '../ecm-store/reducers';
import { CartActions, WishListActions } from '../ecm-store/actions';
import { ECMSigninService } from './ecm-signin.service';
import { EcmCartService } from '../ecm-view/ecm-cart/ecm-cart.service';
import { EcmWishListService } from '../ecm-view/ecm-wish-list/ecm-wish-list.service';
declare var encPwd: any;
......@@ -46,7 +44,7 @@ export class EcmSigninComponent implements OnInit {
statusPending: boolean = false;
statusErrorMsg: string;
constructor(public signinService: ECMSigninService, private store: Store<AppState>, public cartService: EcmCartService, public wishListService: EcmWishListService, private cartAction:CartActions, private wishListAction:WishListActions) { }
constructor(public signinService: ECMSigninService, private store: Store<AppState>, private cartAction:CartActions, private wishListAction:WishListActions) { }
activeForm: any = 'signInForm';
activeNGForm: NgForm;
......@@ -168,7 +166,6 @@ export class EcmSigninComponent implements OnInit {
console.log( 'comp errorMessage[' + errorMessage + ']' );
}
);
}
login(signinForm) {
......
......@@ -19,10 +19,9 @@ export class CartEffects {
.map(items => this.cartActions.loadCartItemsSuccess(items));
@Effect() addToCart$ = this.update$
.ofType(CartActions.ADD_TO_CART)
.ofType(CartActions.ADD_TO_CART_SUCCESS)
.map(action => action.payload)
.switchMap(item => this.svc.addToCart(item)
.map(item => this.cartActions.addToCartSuccess(item)));
.switchMap(item => this.svc.addToCart(item));
@Effect() updateCart$ = this.update$
.ofType(CartActions.UPDATE_CART)
......
......@@ -19,14 +19,12 @@ export class WishlistEffects {
.map(items => this.wishlistActions.loadWishlistItemsSuccess(items));
@Effect() addToWishlist$ = this.update$
.ofType(WishListActions.ADD_TO_WISHLIST)
.ofType(WishListActions.ADD_TO_WISHLIST_SUCCESS)
.map(action => action.payload)
.switchMap(item => this.svc.addToWishlist(item)
.map(item => this.wishlistActions.addToWishlistSuccess(item)));
.switchMap(item => this.svc.addToWishlist(item.itemCode));
@Effect() deleteFromWishlist$ = this.update$
.ofType(WishListActions.DELETE_WISHLIST_ITEM)
.ofType(WishListActions.DELETE_WISHLIST_ITEM_SUCCESS)
.map(action => action.payload)
.switchMap(item => this.svc.deleteWishlistItem(item))
.map(item => this.wishlistActions.deleteWishlistItemSuccess(item));
.switchMap(item => this.svc.deleteWishlistItem(item.itemCode));
}
......@@ -427,6 +427,13 @@ h6
height:20px;
}
.chg-password-header {
display: block;
text-align: center;
font-size: 22px;
padding-bottom: 20px;
}
.changePass-form {
padding: 0px 20px;
padding-top: 40px;
......
......@@ -59,7 +59,7 @@
<ng-template #changePwdScreen>
<div class="changePass-form">
<h4>Change Password</h4>
<span class="chg-password-header">Change Password</span>
<form #changePass="ngForm" (ngSubmit)="changePassword(changePass);" novalidate autocomplete="off">
<md-input-container class="password-input-container" [hideRequiredMarker] = "true">
<input mdInput class="username-input" placeholder="Current Password" required name="cpassword" [(ngModel)]="_current_password" #current_password="ngModel" (keydown)="clearTimer();" type = 'password'
......
......@@ -34,6 +34,7 @@ export class EcmUserOptionComponent implements OnInit {
_current_password: string;
_new_password: string;
_confirm_password: string;
timer : any;
constructor( public signinService: ECMSigninService, private store: Store<AppState>, public cartService: EcmCartService, private cartAction: CartActions, private locationService: EcmLocationService) { }
......@@ -150,4 +151,12 @@ export class EcmUserOptionComponent implements OnInit {
}
);
}
scrollIntoView(formChildElement){
console.log('formChildElement' , formChildElement);
clearTimeout(this.timer);
this.timer = setTimeout(() => {
formChildElement.scrollIntoView(true);
}, 500);
}
}
......@@ -525,7 +525,7 @@
}
.scrollMe{
overflow: hidden;
max-height: 350px;
max-height: 230px;
}
.scrollMe:hover {
overflow: auto;
......
......@@ -7,21 +7,19 @@ import { EcmCategoryComponent } from '../ecm-category/ecm-category.component';
import { Observable } from 'rxjs/Observable';
import { Store } from '@ngrx/store';
import {AppState} from '../../ecm-store/reducers';
import {CartActions} from '../../ecm-store/actions';
import { AppState } from '../../ecm-store/reducers';
import { CartActions } from '../../ecm-store/actions';
import { Item } from '../../ecm-model/product-model';
import { EcmCartService } from './ecm-cart.service';
import { ECMCart } from '../../ecm-model/cart-model';
import { EcmProductDetailService } from '../../ecm-product-details/ecm-product-detail.service';
import { Router, ActivatedRoute } from '@angular/router';
@Component( {
selector: 'ecm-cart',
templateUrl: './ecm-cart.component.html',
styleUrls: ['./ecm-cart.component.css'],
providers: [EcmProductDetailService]
styleUrls: ['./ecm-cart.component.css']
})
export class EcmCartComponent implements OnInit, AfterViewChecked {
cartItemsDetail: ItemDetail[];
......@@ -39,7 +37,7 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
@ViewChild('scrollMe') private myScrollContainer: ElementRef;
constructor( private route: ActivatedRoute, public dialog: MdDialog, private router: Router,public productDetailService: EcmProductDetailService, public cartService: EcmCartService, public snackBar: MdSnackBar, private http: Http, private store: Store<AppState>, private cartAction: CartActions) { }
constructor( private route: ActivatedRoute, public dialog: MdDialog, private router: Router, public cartService: EcmCartService, public snackBar: MdSnackBar, private http: Http, private store: Store<AppState>, private cartAction: CartActions) { }
ngOnInit() {
this.getCartItem();
......@@ -68,16 +66,6 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
deleteCartItem( item ) {
console.log( "deleteCartItem Called" );
/*
this.store.dispatch({ type: REMOVE, payload: item });
this.http.delete( this.userActionUrl + '/' + item.itemCode, {})
.subscribe( data => {
console.log( "deleted item in Cart" );
}, error => {
console.log( error.json() );
});
*/
this.store.dispatch(this.cartAction.deleteCartItem(item));
this.getCartItem();
......@@ -95,12 +83,9 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
let cartData = new Item;
cartData.itemCode = item.itemCode;
cartData.itemQuantity = item.itemQuantity;
//cartData.costRate = item.itemHeader.itemDiscountedRate;
//this.store.dispatch({ type: 'UPDATE_QUANTITY', payload: cartData });
this.store.dispatch(this.cartAction.updateCart(cartData));
this.openSnackBar( 'Quantity increased of ' + item.itemHeader.itemShDescr );
//this.productDetailService.addToCart(cartData);
}
decrement(item : ItemDetail) {
......@@ -108,12 +93,8 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
let cartData = new Item;
cartData.itemCode = item.itemCode;
cartData.itemQuantity = item.itemQuantity;
// cartData.costRate = item.itemHeader.itemDiscountedRate;
//this.store.dispatch({ type: 'UPDATE_QUANTITY', payload: cartData });
this.store.dispatch(this.cartAction.updateCart(cartData));
this.openSnackBar( 'Quantity decreased of ' + item.itemHeader.itemShDescr );
//this.productDetailService.addToCart(cartData);
}
checkQantity(item) {
......
......@@ -24,7 +24,6 @@ private userActionUrl = '/ecm/service/feeds/cart';
this.cartItems = data;
if ( data && data != null ) {
this.cartItems.forEach( item => {
//this.store.dispatch({ type: ADD_TO_CART, payload: item });
this.store.dispatch(this.cartActions.addToCart(item));
})
}
......
......@@ -3,7 +3,6 @@ import { Store } from '@ngrx/store';
import { AppState } from '../../ecm-store/reducers';
import { CategoryActions, SubCategoryActions } from '../../ecm-store/actions';
import { EcmCategoryService } from './ecm-category.service';
import { ScrollService } from '../../scroll.service';
import { Category } from '../../ecm-model/category-model';
......@@ -12,8 +11,7 @@ import { Observable } from 'rxjs/Observable';
@Component({
selector: 'ecm-category',
templateUrl: './ecm-category.component.html',
styleUrls: ['./ecm-category.component.css'],
providers: [EcmCategoryService]
styleUrls: ['./ecm-category.component.css']
})
export class EcmCategoryComponent implements OnInit {
errorMessage: string;
......@@ -26,7 +24,7 @@ export class EcmCategoryComponent implements OnInit {
this.position=window.pageYOffset;
}
constructor(public categoryService: EcmCategoryService, private scroll_service: ScrollService, private store: Store<AppState>, private categoryAction:CategoryActions, private subCategoryAction: SubCategoryActions) { }
constructor(private scroll_service: ScrollService, private store: Store<AppState>, private categoryAction:CategoryActions, private subCategoryAction: SubCategoryActions) { }
ngOnInit() {
this.getCategories();
......@@ -44,24 +42,9 @@ export class EcmCategoryComponent implements OnInit {
getCategories() {
this.categories = this.store.select('categories');
/*
this.categoryService.getCategories().subscribe(
categories => {
this.categories = categories;
console.log('comp categories[' + JSON.stringify( categories ) + '] \n this.categories[' + JSON.stringify( this.categories ) + ']');
},
error => {
this.errorMessage = <any>error;
console.log('comp errorMessage[' + this.errorMessage + ']');
});
*/
}
storeCategory(selectedCategory) {
console.log(selectedCategory);
//this.store.dispatch({type: 'CLEAR_CATEGORY', payload: selectedCategory});
//this.store.dispatch({type: 'CATEGORY', payload: selectedCategory});
this.store.dispatch( this.subCategoryAction.resetSubCategoryList() );
this.store.dispatch( this.subCategoryAction.loadSubCategories( selectedCategory.catCode ) );
this.store.dispatch(this.categoryAction.getCategorySuccess(selectedCategory));
......
import { Component, OnInit, ViewChild, ElementRef, Input, Output, EventEmitter } from '@angular/core';
import { FormBuilder, Validators,NgForm } from '@angular/forms';
import { EcmCartService } from '../ecm-cart/ecm-cart.service';
import { ItemDetail } from '../../ecm-model/product-detail-model';
import { Observable } from 'rxjs/Observable';
......@@ -25,7 +24,7 @@ export class EcmCheckoutComponent implements OnInit {
years;
cartItems: Observable<ItemDetail[]>;
constructor(private formBuilder: FormBuilder, public cartService: EcmCartService, private store: Store<AppState>) {
constructor(private formBuilder: FormBuilder, private store: Store<AppState>) {
this.countries = [
{ viewValue: 'India' },
{ viewValue: 'UAE' },
......
......@@ -42,16 +42,6 @@ export class EcmPanelComponent implements OnInit {
{
}
// this.dialogRef = this.dialog.open(ECMDialog,{
// data: {
// option: sideOption
// }
// });
// this.updatePosition({ top:'0px', left: '0px' });
//
// this.dialogRef.afterClosed().subscribe(result => {
//
// });
}
close(){
......@@ -89,18 +79,34 @@ export class EcmPanelComponent implements OnInit {
this.rightSlidePanel.nativeElement.style.borderRadius = "0px";
else
this.rightSlidePanel.nativeElement.style.borderRadius = "5px";
if(this.panelData.option == 'CART_OPT')
this.rightSlidePanel.nativeElement.style.maxHeight = "390px";
else
this.rightSlidePanel.nativeElement.style.maxHeight = "";
var el = document.querySelectorAll(".square-button");
if(this.panelData.option == 'MENU_OPT')
el[0].classList.add('onSelect');
if(this.panelData.option == 'CART_OPT')
el[1].classList.add('onSelect');
if(this.panelData.option == 'USER_OPT')
el[2].classList.add('onSelect');
disableScroll();
}
private hideSidePanel() {
this.rightSlidePanel.nativeElement.style.display = "none";
var el = document.querySelectorAll(".square-button");
console.log('Query-Selector',el);
if(this.panelData.option == 'MENU_OPT')
el[0].classList.remove('onSelect');
if(this.panelData.option == 'CART_OPT')
el[1].classList.remove('onSelect');
if(this.panelData.option == 'USER_OPT')
el[2].classList.remove('onSelect');
enableScroll();
}
private showOverlayPanel() {
......
......@@ -12,15 +12,11 @@ import { Item } from '../../ecm-model/product-model';
import { ItemDetail } from '../../ecm-model/product-detail-model';
import { ScrollService } from '../../scroll.service';
import { EcmProductService } from './ecm-product.service';
import { EcmProductDetailService } from '../../ecm-product-details/ecm-product-detail.service';
@Component({
selector: 'ecm-product',
templateUrl: './ecm-product.component.html',
styleUrls: ['./ecm-product.component.css'],
providers: [EcmProductService, EcmProductDetailService]
styleUrls: ['./ecm-product.component.css']
})
export class EcmProductComponent implements OnInit {
......@@ -46,7 +42,7 @@ export class EcmProductComponent implements OnInit {
attribCode;
constructor(private route: ActivatedRoute, private router:Router,public subcategoryService: EcmProductService,public productDetailService: EcmProductDetailService, private scroll_service: ScrollService, private store: Store<AppState>, private itemAction: ItemActions, private cartAction: CartActions) { }
constructor(private route: ActivatedRoute, private router:Router, private scroll_service: ScrollService, private store: Store<AppState>, private itemAction: ItemActions, private cartAction: CartActions) { }
ngOnInit() {
window.scrollTo(0,0);
this.route.params.subscribe( params => {
......@@ -64,25 +60,10 @@ export class EcmProductComponent implements OnInit {
}
getItems( scatCode: string ) {
this.items = this.store.select('items');
/*
this.subcategoryService.getItems( scatCode ).subscribe(
items => {
this.items = items;
this.Items = this.items.length;
console.log( 'comp scatCode[' + scatCode + '] \n this.items[' + JSON.stringify( this.items ) + ']' );
},
);
*/
}
storeItem(selectedItem){
console.log(selectedItem);
//this.store.dispatch({type: 'CLEAR_SUB_CATEGORY', payload: selectedSubCategory});
//this.store.dispatch({type: 'SUB_CATEGORY', payload: selectedSubCategory});
this.store.dispatch( this.itemAction.getItemSuccess(selectedItem) );
}
......@@ -106,15 +87,6 @@ export class EcmProductComponent implements OnInit {
cartData.itemQuantity = 1;
this.store.dispatch(this.cartAction.addToCartSuccess(item));
this.productDetailService.addToCart(cartData);
//Check Store data
this.store.select('cartItems').forEach(
value => {
console.log('Cart Items----');
console.log(value);
}
);
}
showHide(){
......
......@@ -4,7 +4,6 @@ import { Store } from '@ngrx/store';
import { AppState } from '../../ecm-store/reducers';
import { SubCategoryActions, ItemActions } from '../../ecm-store/actions';
import { EcmSubCategoryService } from './ecm-sub-category.service';
import { ScrollService } from '../../scroll.service';
import { Category } from '../../ecm-model/category-model';
import { SubCategory } from '../../ecm-model/subcategory-model';
......@@ -15,8 +14,7 @@ import { Observable } from 'rxjs/Observable';
@Component( {
selector: 'ecm-sub-category',
templateUrl: './ecm-sub-category.component.html',
styleUrls: ['./ecm-sub-category.component.css'],
providers: [EcmSubCategoryService]
styleUrls: ['./ecm-sub-category.component.css']
})
export class EcmSubCategoryComponent implements OnInit {
......@@ -34,7 +32,7 @@ export class EcmSubCategoryComponent implements OnInit {
private category: Category;
private subcategory: SubCategory;
constructor( private route: ActivatedRoute, private router: Router, public subcategoryService: EcmSubCategoryService, private scroll_service: ScrollService, private store: Store<AppState>, private subCategoryAction: SubCategoryActions, private itemAction:ItemActions ) { }
constructor( private route: ActivatedRoute, private router: Router, private scroll_service: ScrollService, private store: Store<AppState>, private subCategoryAction: SubCategoryActions, private itemAction:ItemActions ) { }
ngOnInit() {
window.scrollTo( 0, 0 );
this.route.params.subscribe( params => {
......@@ -50,39 +48,10 @@ export class EcmSubCategoryComponent implements OnInit {
}
getSubCategories( catCode: string ) {
this.subcategories = this.store.select( 'subcategories' );
/*
this.subcategoryService.getSubCategories( catCode ).subscribe(
subcategories => {
this.subcategories = subcategories;
console.log( 'comp catCode[' + catCode + '] \n this.subcategories[' + JSON.stringify( this.subcategories ) + ']' );
let subCatLen = subcategories.length ? subcategories.length : 0;
console.log( 'SubCatLen:: ' + subCatLen );
if( subCatLen == 0 )
{
this.isCatItems = 'true';
this.subcategories = null;
console.log( 'Calling items of Category ::: ' + catCode );
this.store.dispatch({type: 'CLEAR_SUB_CATEGORY', payload: null}); //Just Remove Previous Data
this.getItems(catCode);
}
else
{
this.subcategories = subcategories;
this.items = null;
console.log( 'comp catCode[' + catCode + '] \n this.subcategories[' + JSON.stringify( this.subcategories ) + ']' );
}
},
);
*/
}
storeSubCategory( selectedSubCategory ) {
//this.store.dispatch({type: 'CLEAR_SUB_CATEGORY', payload: selectedSubCategory});
//this.store.dispatch({type: 'SUB_CATEGORY', payload: selectedSubCategory});
this.store.dispatch( this.itemAction.resetItemList() );
this.store.dispatch( this.itemAction.loadItems( selectedSubCategory.scatCode ) );
this.store.dispatch( this.subCategoryAction.getSubCategorySuccess( selectedSubCategory ) );
......
......@@ -32,13 +32,13 @@
<div class="total-description">
<div class="items-desc">
<span class="item-title" (click)="viewItem(item.itemCode)">Handmade
Handicarft</span> <span class="item-shDescr">{{item.shDescr}}</span>
Handicarft</span> <span class="item-shDescr">{{item.itemHeader.itemShDescr}}</span>
<span class="item-shDescr">{{item.descr}}</span>
<span class="item-seller">Sold by</span> <span class="item-sellerInfo">Handmade
Handicarfts</span>
</div>
<div class="items-cost-rate">
<span>Rs. {{item.costRate}}</span>
<span>Rs. {{item.itemHeader.itemDiscountedRate}}</span>
</div>
</div>
......
......@@ -3,7 +3,6 @@ import { EcmWishListService } from './ecm-wish-list.service';
import { MdSnackBar } from '@angular/material';
import { Item } from '../../ecm-model/product-model';
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';
......@@ -16,16 +15,13 @@ import { Observable } from 'rxjs/Observable';
@Component({
selector: 'app-ecm-wish-list',
templateUrl: './ecm-wish-list.component.html',
styleUrls: ['./ecm-wish-list.component.css'],
providers: [EcmProductDetailService]
styleUrls: ['./ecm-wish-list.component.css']
})
export class EcmWishListComponent implements OnInit {
// wishListDetail: Item;
wishListItems: Observable<ItemDetail[]>;
errorMessage: string;
cartCount = 0;
constructor( public subcategoryService: EcmProductDetailService, private route: ActivatedRoute, private router: Router, public snackBar: MdSnackBar, public wishListService: EcmWishListService, private http: Http, private store: Store<AppState>, private wishListAction: WishListActions) { }
constructor( private route: ActivatedRoute, private router: Router, public snackBar: MdSnackBar, public wishListService: EcmWishListService, private http: Http, private store: Store<AppState>, private wishListAction: WishListActions) { }
ngOnInit() {
this.getWishlistItems();
......@@ -33,26 +29,10 @@ export class EcmWishListComponent implements OnInit {
getWishlistItems() {
this.wishListItems = this.store.select( 'wishlistItems' );
this.store.select( 'wishlist' ).forEach(
value => {
console.log( 'wishlist Items----' );
console.log( value );
}
);
}
userActionUrl = '/ecm/service/feeds/wishlist';
deletewishlistItem( item ) {
this.store.dispatch(this.wishListAction.deleteWishlistItemSuccess(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' );
}
......@@ -62,10 +42,6 @@ export class EcmWishListComponent implements OnInit {
});
}
addToWishlist( data: Item ) {
this.subcategoryService.addToWishlist( data );
}
viewItem( itemCode ) {
this.router.navigate( ['/detail', itemCode] );
}
......
......@@ -33,7 +33,7 @@ export class EcmWishListService {
let options = new RequestOptions( { headers: headers });
return this.http.get( this.wishListUrl, options )
.map( this.extractData )
.map( (res) => this.extractData(res) )
.catch( this.handleError );
}
......@@ -54,9 +54,50 @@ export class EcmWishListService {
}
private extractData( res: Response ) {
let body = res.json();
console.log( 'extractData[' + JSON.stringify( body ) + ']' );
return body || {};
let respJson = res.json();
console.log( 'extracData', respJson );
if ( respJson != null ) {
for ( let key of Object.keys( respJson ) ) {
console.log( "getItemDetail itemDetail ==> key: " + key )
let data = respJson[key];
try {
respJson[key] = JSON.parse( data );
console.log( "getItemDetail itemDetail try : " + respJson[key] );
}
catch ( e ) {
console.log( "getItemDetail itemDetail ==> key: ", data, typeof data === 'object' )
if ( typeof data === 'object' )
respJson[key] = this.formatObject( data );
else
respJson[key] = data;
console.log( "getItemDetail itemDetail catch : " + respJson[key] );
}
}
console.log( 'extractData[' + JSON.stringify( respJson ) + ']' );
}
return respJson || {};
}
formatObject( respJson: any ) {
console.log( 'formatObject', respJson );
if ( respJson != null ) {
for ( let key of Object.keys( respJson ) ) {
console.log( "formatObject itemDetail ==> key: " + key )
let data = respJson[key];
try {
respJson[key] = JSON.parse( data );
console.log( "formatObject itemDetail try : " + respJson[key] );
}
catch ( e ) {
respJson[key] = data;
console.log( "formatObject itemDetail catch : " + respJson[key] );
}
}
console.log( 'formatObject[' + JSON.stringify( respJson ) + ']' );
}
return respJson || {};
}
private handleError( error: Response | any ) {
......
......@@ -21,15 +21,12 @@ export class RatingComponent implements OnInit {
constructor() { }
ngOnInit() {
console.log('Rating: ' +this.rate);
if(this.ratingDetail)
{
this.overallRatings.forEach(( rating, i ) => {
this.totalRatings = this.totalRatings + rating;
});
}
}
update(value) {
......
......@@ -296,19 +296,25 @@ function preventDefaultForScrollKeys(e) {
}
function disableScroll() {
/*
if (window.addEventListener) // older FF
window.addEventListener('DOMMouseScroll', preventDefault, false);
window.onwheel = preventDefault; // modern standard
window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE
window.ontouchmove = preventDefault; // mobile
document.onkeydown = preventDefaultForScrollKeys;
*/
document.body.style.overflow = 'hidden';
}
function enableScroll() {
/*
if (window.removeEventListener)
window.removeEventListener('DOMMouseScroll', preventDefault, false);
window.onmousewheel = document.onmousewheel = null;
window.onwheel = null;
window.ontouchmove = null;
document.onkeydown = null;
*/
document.body.style.overflow = 'visible';
}
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