Commit 30768fec authored by prumde's avatar prumde

Updated


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@174191 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 47d471d3
import { Component } from '@angular/core';
import {Location, LocationStrategy, PathLocationStrategy} from '@angular/common';
import { EcmCartService } from './ecm-view/ecm-cart/ecm-cart.service';
import {AppState} from './ecm-store/reducers';
import {CartActions} from './ecm-store/actions';
import {CategoryActions} from './ecm-store/actions';
import { Store } from '@ngrx/store';
@Component({
selector: 'ecm-root',
templateUrl: './app.component.html',
......@@ -11,7 +14,7 @@ import { EcmCartService } from './ecm-view/ecm-cart/ecm-cart.service';
export class AppComponent {
title = 'Proteus ECM';
location: Location;
constructor(location: Location, public cartService: EcmCartService) {
constructor(location: Location, private store: Store<AppState>, private cartActions: CartActions, private categoryAction: CategoryActions) {
this.location = location;
console.log( ' this.location.path(true)[' + this.location.path(true) + ']');
this.checkAppState();
......@@ -21,7 +24,8 @@ export class AppComponent {
this.setItem('appstate', this.get('app_stat'), true );
this.setItem('TOKEN_ID', this.get('TOKEN_ID'), true );
this.cartService.setCartItems();
this.store.dispatch(this.cartActions.loadCartItems());
this.store.dispatch(this.categoryAction.loadCategories());
}
get(name){
var retVal = 'undefined';
......
import { Component, OnInit, Input } from '@angular/core';
import { Location } from '@angular/common';
import { Store } from '@ngrx/store';
import { EcmStoreModel } from '../ecm-store/ecm-store.model';
import {AppState} from '../ecm-store/reducers';
import { ItemDetail } from '../ecm-model/product-detail-model';
import { Category } from '../ecm-model/category-model';
import { SubCategory } from '../ecm-model/subcategory-model';
......@@ -24,68 +24,38 @@ export class EcmBreadcrumbsComponent implements OnInit {
@Input() pageName;
breadcrumbs: IBreadcrumb[] = [];
category : Observable<Category>;
subcategory : Observable<SubCategory>;
category;
subcategory;
item : Observable<Item>;
constructor( private _location: Location, private store: Store<EcmStoreModel> ) { }
constructor( private _location: Location, private store: Store<AppState> ) { }
ngOnInit() {
if ( this.pageName == 'SUB_CATEGORY' ) {
let storeCategory;
let category_shDescr;
this.store.select( 'CATEGORY' ).forEach( value => storeCategory = value );
category_shDescr = storeCategory.shDescr
this.store.select('category')
.subscribe( category => this.category = category );
this.breadcrumbs = [];
this.breadcrumbs.push( {
label: 'Home',
url: '/home'
});
this.breadcrumbs.push( {
label: category_shDescr,
label: this.category.shDescr,
url: 'javascript:void(0)'
});
/*
this.category = this.store.select('CATEGORY');
this.category.subscribe( storeCategory => {
let category_shDescr = storeCategory!.shDescr;
console.log('>>>category_shDescr ::' + category_shDescr);
this.breadcrumbs = [];
this.breadcrumbs.push( {
label: 'Home',
url: '/home'
});
this.breadcrumbs.push( {
label: category_shDescr,
url: 'javascript:void(0)'
});
});
*/
}
if ( this.pageName == 'ITEMS' ) {
let storeCategory;
let storeSubCategory;
let catCode;
let catShDescr;
let subcatShDescr;
this.store.select( 'SUBCATEGORY' ).forEach( value => storeSubCategory = value );
if ( storeSubCategory ) {
catCode = storeSubCategory.catCode;
subcatShDescr = storeSubCategory.shDescr;
}
console.log( "Breadcrumbs==>" );
console.log( catCode );
this.store.select( 'CATEGORY' ).forEach( value => storeCategory = value );
if ( storeCategory ) {
catShDescr = storeCategory.shDescr;
}
this.store.select('category')
.subscribe( category => this.category = category );
this.store.select('subcategory')
.subscribe( subcategory => this.subcategory = subcategory );
this.breadcrumbs = [];
this.breadcrumbs.push( {
......@@ -93,45 +63,13 @@ export class EcmBreadcrumbsComponent implements OnInit {
url: '/home'
});
this.breadcrumbs.push( {
label: catShDescr,
url: '/categories/' + catCode
label: this.category.shDescr,
url: '/categories/' + this.subcategory.catCode
});
this.breadcrumbs.push( {
label: subcatShDescr,
label: this.subcategory.shDescr,
url: 'javascript:void(0)'
});
/*
this.category = this.store.select('CATEGORY');
this.category.subscribe( storeCategory => {
let catCode = storeCategory!.catCode;
let category_shDescr = storeCategory!.shDescr;
console.log('>>>catCode ::' + catCode);
console.log('>>>category_shDescr ::' + category_shDescr);
this.breadcrumbs = [];
this.breadcrumbs.push( {
label: 'Home',
url: '/home'
});
this.breadcrumbs.push( {
label: category_shDescr,
url: '/categories/' + catCode
});
this.subcategory = this.store.select('SUBCATEGORY');
this.subcategory.subscribe( storeSubCategory => {
let subcatShDescr = storeSubCategory!.shDescr;
this.breadcrumbs.push( {
label: subcatShDescr,
url: 'javascript:void(0)'
});
});
});
*/
}
if ( this.pageName == 'SEARCH' ) {
......@@ -208,8 +146,6 @@ export class EcmBreadcrumbsComponent implements OnInit {
});
}
}
backClicked() {
......
......@@ -147,6 +147,7 @@ p {
#ecm-item {
cursor: pointer;
height: 300px;
}
#ecm-item-info {
......
......@@ -179,12 +179,21 @@ ecm-search{
/*Fixed Header Menu*/
.fixed-header-nav{
top: 13px;
/* top: 13px;
left: 1.5rem;
position: fixed;
z-index: 4;
*/
/* height: 45px; */
/* top: 0;
left: 0;
position: fixed;
z-index: 4;*/
height: 100%;
top: 13px;
left: 1.5rem;
position: fixed;
z-index: 4;
/* height: 100%; */
height: 45px;
}
......
......@@ -15,7 +15,8 @@
.ecm-card > ecm-image > .ecm-image > img
{
height: 330px;
/* height: 330px; */
height: 230px;
}
.ecm-image-icon {
......
......@@ -15,8 +15,8 @@ a {
.container {
position: relative;
margin: 0;
width: 300px;
/* height: 534px; */
/*width: 300px;*/
height: 534px;
background-color: #533557;
background-color: transparent;
overflow: hidden;
......@@ -34,7 +34,6 @@ a {
}
#toggle:checked ~ .container {
background-color: blue;
width: 300px !important;
}
#toggle:checked ~ .toggle-container .button-toggle {
box-shadow: 0 0 0 700px rgba(0, 0, 0, 0.1), inset 0 0 0 20px
......@@ -102,11 +101,12 @@ a {
/* Toggle button */
.button-toggle {
top: 0;
position: absolute;
display: inline-block;
position: absolute;
/* display: inline-block; */
width: 20px;
height: 20px;
margin: 10px 15px 15px 5px;
margin: 10px 15px 15px 5px;
/* margin: 10px 15px 15px 25px; */
background-color: transparent;
border: none;
cursor: pointer;
......
......@@ -4,8 +4,8 @@ import { MdSnackBar } from '@angular/material';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import { EcmStoreModel } from '../ecm-store/ecm-store.model';
import { UPDATE_QUANTITY, ADD_TO_CART, REMOVE, ADD_TO_WISHLIST,REMOVE_WISLIST } from '../ecm-store/ecm-store';
import {AppState} from '../ecm-store/reducers';
import {CartActions} from '../ecm-store/actions';
import { EcmProductDetailService } from './ecm-product-detail.service';
import { ScrollService } from '../scroll.service';
......@@ -53,7 +53,7 @@ export class EcmProductDetailsComponent implements OnInit {
attribVal;
attribCode;
constructor(private route: ActivatedRoute, private router:Router, public productDetailService: EcmProductDetailService, public snackBar: MdSnackBar, private store: Store<EcmStoreModel>, private productreviewService: EcmProductReviewService, public dialog: MdDialog) { }
constructor(private route: ActivatedRoute, private router:Router, public productDetailService: EcmProductDetailService, public snackBar: MdSnackBar, private store: Store<AppState>, private productreviewService: EcmProductReviewService, public dialog: MdDialog, private cartActions: CartActions) { }
ngOnInit() {
this.route.params.subscribe( params => {
......@@ -114,7 +114,7 @@ export class EcmProductDetailsComponent implements OnInit {
this.router.navigate(['/cart']);
}
else { //ADD TO CART
this.addToCart(data.itemCode);
this.addToCart(data.item);
this.showSnackbar('Item Added to your Cart');
}
}
......@@ -174,13 +174,13 @@ export class EcmProductDetailsComponent implements OnInit {
}
}
addToCart(itemCode) {
this.getAttributeType(itemCode);
addToCart(item) {
//this.getAttributeType(itemCode);
let cartData = new Item;
cartData.itemCode = itemCode;
cartData.itemQuantity = 1;
cartData.costRate = this.itemDetail.itemHeader.itemCostRate;
//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"){
......@@ -189,13 +189,14 @@ export class EcmProductDetailsComponent implements OnInit {
else if(this.attribCode == "SIZE"){
cartData.phyAttribId1 = this.attribVal;
}
*/
this.store.dispatch({ type: ADD_TO_CART, payload: cartData });
this.productDetailService.addToCart(cartData);
this.store.dispatch(this.cartActions.addToCartSuccess(item));
//this.store.dispatch({ type: ADD_TO_CART, payload: cartData });
//this.productDetailService.addToCart(cartData);
//Check Store data
this.store.select('cart').forEach(
this.store.select('cartItems').forEach(
value => {
console.log('Cart Items----');
console.log(value);
......@@ -207,18 +208,18 @@ export class EcmProductDetailsComponent implements OnInit {
addToWishlist( itemCode ) {
let cartData = new Item;
cartData.itemCode = itemCode;
cartData.costRate = this.itemDetail.itemHeader.itemCostRate;
cartData.costRate = this.itemDetail.itemHeader.itemDiscountedRate;
cartData.descr = this.itemDetail.itemHeader.itemDescr;
cartData.shDescr = this.itemDetail.itemHeader.itemShDescr;
this.store.dispatch({ type: ADD_TO_WISHLIST, payload: cartData });
//this.store.dispatch({ type: ADD_TO_WISHLIST, payload: cartData });
this.productDetailService.addToWishlist( itemCode );
}
removeFromWishlist( itemCode ) {
let cartData = new Item;
cartData.itemCode = itemCode;
this.store.dispatch({ type: REMOVE_WISLIST, payload: cartData });
//this.store.dispatch({ type: REMOVE_WISLIST, payload: cartData });
this.productDetailService.removeFromWishlist( itemCode );
}
......
......@@ -308,6 +308,8 @@ md-card {
}
.submit-review-btn, .cancel-review-btn {
background: #fff;
color: mediumvioletred;
max-width: 190px;
height: 50px;
font-size: 15px;
......
......@@ -49,7 +49,7 @@
<div class="item-descount-rate-section">
<span class="item-descount-rate">
Rs. {{itemDetail.itemHeader.itemDiscountedRate}}
Rs. {{itemDetail.itemHeader.itemDiscountedRate}}
</span>
</div>
<div>
......@@ -139,7 +139,7 @@
<div [ngClass]="{'buy-cart-button': ( clientWidth > 640 ) , 'mobi-buy-cart-button': ( clientWidth < 639 ) }" >
<button md-button class="button medium-btn Add_to_cart"
(click)="doActivity.emit({activity:'ADD_CART', data: {'itemCode' : itemDetail.itemCode, 'isAddToCart' : isAddToCart}}); isAddToCart= true;">{{ isAddToCart ? 'Go to Cart' : 'Add to Cart' }}</button>
(click)="doActivity.emit({activity:'ADD_CART', data: {'item' : itemDetail, 'isAddToCart' : isAddToCart}}); isAddToCart= true;">{{ isAddToCart ? 'Go to Cart' : 'Add to Cart' }}</button>
<button md-button class="button medium-btn Buy_now" (click)="doActivity.emit({activity:'BUY_NOW', data: {'itemCode' : itemDetail.itemCode, 'isAddToCart' : isAddToCart} });">Buy
Now</button>
</div>
......
......@@ -5,12 +5,12 @@ import { Router, ActivatedRoute } from '@angular/router';
import { Http } from '@angular/http';
import { EcmCartComponent } from '../../ecm-view/ecm-cart/ecm-cart.component';
import { Item } from '../../ecm-model/product-model';
import {MdDialog, MdDialogRef, MdDialogConfig, MD_DIALOG_DATA} from '@angular/material';
import { MdDialog, MdDialogRef, MdDialogConfig, MD_DIALOG_DATA } from '@angular/material';
import { RESIZE_EVENT } from '../../ecm-store/ecm-resize';
import { Observable } from 'rxjs/Observable';
import { Store } from '@ngrx/store';
import { EcmStoreModel } from '../../ecm-store/ecm-store.model';
import { AppState } from '../../ecm-store/reducers';
import { EcmRecentViewComponent } from '../../ecm-view/ecm-recent-view/ecm-recent-view.component';
import { ECMWriteReviewDialog } from '../ecm-product-review.component';
......@@ -41,7 +41,7 @@ export class EcmHandicraftComponent implements OnInit, EcmTemplateInterface {
Overview = "Champions Yacht Club specializes in offering luxury boating and yachting experiences in Goa with a large fleet of Catamarans, Boats, Cruisers & Yachts in Goa. We do Rocking birthday parties, anniversary bashes, island excursions & barbeques, fishing expeditions, snorkeling, corporate parties and more. We ensure you have a luxury experience in yachts that will leave a memory of a lifetime";
constructor( private route: ActivatedRoute, private router: Router, private http: Http, public dialog: MdDialog, private store: Store<EcmStoreModel> ) { }
constructor( private route: ActivatedRoute, private router: Router, private http: Http, public dialog: MdDialog, private store: Store<AppState> ) { }
ngOnInit() {
......@@ -56,7 +56,7 @@ export class EcmHandicraftComponent implements OnInit, EcmTemplateInterface {
this.clientWidth = data;
});
this.cartItems = this.store.select('cart');
this.cartItems = this.store.select('cartItems');
this.cartItems.subscribe( cartItems => {
if(cartItems.find(x => x.itemCode === this.itemDetail.itemCode))
this.isAddToCart = true;
......
......@@ -3,13 +3,13 @@ import { Http, Headers,RequestOptions } from '@angular/http';
import { EcmLocation } from './ecm-location';
import { EventEmitter } from '@angular/core';
import { Store } from '@ngrx/store';
import { EcmStoreModel } from '../ecm-store/ecm-store.model';
import { AppState } from '../ecm-store/reducers';
import { LocationActions } from '../ecm-store/actions/location';
@Injectable()
export class EcmLocationService {
constructor( public http: Http, private store: Store<EcmStoreModel>) {}
constructor( public http: Http, private store: Store<AppState>, private locationAction:LocationActions) {}
find(nameKey, myArray){
for (var i=0; i < myArray.length; i++) {
......@@ -89,8 +89,8 @@ export class EcmLocationService {
ecmLocation.address = data.results[0].formatted_address;
}
this.store.dispatch({type: 'CLEAR_LOCATION'});
this.store.dispatch({type: 'ECMLOCATION', payload: ecmLocation});
//this.store.dispatch(this.locationAction.resetBlankLocation());
this.store.dispatch(this.locationAction.getLocationSuccess(ecmLocation));
//EmitterService.get("selectedLocation").emit(ecmLocation);
//localStorage.setItem('mycity',this.city);
......
......@@ -7,7 +7,7 @@
</md-autocomplete>
<span class="search-which-border">
<div class="locate-me">{{ userLocation ? userLocation.city : 'Locate Me' }}</div>
<div class="locate-me">{{ userLocation.city ? userLocation.city : 'Locate Me' }}</div>
<div class="locate-handle" (click)="loacteMe();" ></div>
<img class="img-locate" title="Locate Me" src="locate_20_20.png"/>
</span>
......@@ -25,7 +25,7 @@
<div md-ripple class="location" (click)="loacteMe();">
<img class="location-img-32" src="location_32_32.svg"/>
<span class="location-text">{{ userLocation ? userLocation.address : 'Locate Me' }}</span>
<span class="location-text">{{ userLocation.address ? userLocation.address : 'Locate Me' }}</span>
<i class="material-icons location-arrow">keyboard_arrow_down</i>
</div>
<input class="sb-search-submit" type="submit" (click)="search(myInput.value)">
......
......@@ -6,10 +6,9 @@ import { SearchService } from './ecm-search-result/search.service';
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { Store } from '@ngrx/store';
import { AppState } from '../ecm-store/reducers';
import { FormControl } from '@angular/forms';
import { EcmStoreModel } from '../ecm-store/ecm-store.model';
@Component({
selector: 'ecm-search',
templateUrl: './ecm-search.component.html',
......@@ -50,7 +49,7 @@ export class ECMSearchComponent implements OnInit {
search_key;
selectedPlace = 'Mumbai';
constructor(private locationService: EcmLocationService, private search_service: SearchService, private router: Router, private store: Store<EcmStoreModel>)
constructor(private locationService: EcmLocationService, private search_service: SearchService, private router: Router, private store: Store<AppState>)
{
this.stateCtrl.valueChanges.debounceTime(100).subscribe((val: any) => {
console.log("Selected Value[" +val+ "]");
......
......@@ -4,8 +4,8 @@ import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
import { Store } from '@ngrx/store';
import { EcmStoreModel } from '../ecm-store/ecm-store.model';
import { RESET,RESET_WISHLIST } from '../ecm-store/ecm-store';
import { AppState } from '../ecm-store/reducers';
import { CartActions } from '../ecm-store/actions';
import { ECMSigninService } from './ecm-signin.service';
import { EcmCartService } from '../ecm-view/ecm-cart/ecm-cart.service';
......@@ -31,7 +31,7 @@ export class EcmSigninComponent implements OnInit {
loginErrorMsg: string;
@Output() closePanel = new EventEmitter();
constructor(public signinService: ECMSigninService, private store: Store<EcmStoreModel>, public cartService: EcmCartService, public wishListService: EcmWishListService) { }
constructor(public signinService: ECMSigninService, private store: Store<AppState>, private cartActions:CartActions, public cartService: EcmCartService, public wishListService: EcmWishListService) { }
ngOnInit() {
}
......@@ -77,16 +77,13 @@ export class EcmSigninComponent implements OnInit {
this.userData = JSON.parse( result.Response.results );
this.userData.jti = this._username;
this.store.dispatch({ type: RESET });
this.store.dispatch({ type: RESET_WISHLIST });
//Fetch User Data and Store in cache
this.signinService.fetchUserData().subscribe(
response => {
console.log('response[' + response + ']');
if(response){
this.cartService.setCartItems();
this.wishListService.setWishlistItems();
this.store.dispatch(this.cartActions.loadCartItems());
//this.wishListService.setWishlistItems();
}
});
......
......@@ -3,8 +3,8 @@ import { ECMSigninService } from '../ecm-signin/ecm-signin.service';
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,RESET_WISHLIST } from '../ecm-store/ecm-store';
import { AppState } from '../ecm-store/reducers';
import { CartActions } from '../ecm-store/actions';
declare var getContentPlugin: any;
......@@ -25,7 +25,7 @@ export class EcmUserOptionComponent implements OnInit {
userData: any;
//profileImageLink : string;
constructor( public signinService: ECMSigninService, private store: Store<EcmStoreModel>, public cartService: EcmCartService ) { }
constructor( public signinService: ECMSigninService, private store: Store<AppState>, public cartService: EcmCartService, private cartAction: CartActions) { }
ngOnInit() {
var userInfo = localStorage.getItem( 'userInfo' );
......@@ -82,8 +82,7 @@ export class EcmUserOptionComponent implements OnInit {
logout() {
localStorage.removeItem( 'userInfo' );
this.store.dispatch({ type: RESET });
this.store.dispatch({ type: RESET_WISHLIST });
this.store.dispatch(this.cartAction.resetCart());
this.signinService.sendLogout( this.userData.jti, this.userData.TOKEN_ID ).subscribe(
result => {
......@@ -93,9 +92,8 @@ 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();
this.store.dispatch(this.cartAction.resetCart());
this.store.dispatch(this.cartAction.loadCartItems());
}
else if ( result.Response.status == 'error' ) {
this.userData = null;
......@@ -106,8 +104,7 @@ export class EcmUserOptionComponent implements OnInit {
console.log( 'comp errorMessage[' + errorMessage + ']' );
}
);
this.cartService.setCartItems();
this.store.dispatch(this.cartAction.loadCartItems());
}
}
......@@ -44,9 +44,9 @@
[refSer]="'M-ITEM'" [object]="'ITEM'" [isSingleImage]="true"
[isThumbnail]="true"></ecm-image></td>
<td class="itemdescription" (click)="closePanel.emit(viewItem(item.itemCode))">
<span class="item-descr-span">{{item.shDescr}}</span>
<span class="item-descr-span">{{item.itemHeader.itemShDescr}}</span>
</td>
<td style="padding: 10px;">Rs. {{item.costRate}}</td>
<td style="padding: 10px;">Rs. {{item.itemHeader.itemDiscountedRate}}</td>
<td (click)="confirmDialog(item)" style="cursor: pointer;"><span
class="delete-icon" md-ripple>x</span></td>
</tr>
......@@ -97,7 +97,7 @@
<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> <span
Handicarft</span> <span class="item-shDescr">{{item.itemHeader.itemShDescr}}</span> <span
class="item-seller">Sold by</span> <span class="item-sellerInfo">Handmade
Handicarfts</span>
</div>
......@@ -128,7 +128,7 @@
</button>
</div>
<div class="items-cost-rate">
<span>Rs. {{item.costRate}}</span>
<span>Rs. {{item.itemHeader.itemDiscountedRate}}</span>
</div>
<div class="wish-remove-dipslay">
<span class="wishList-items" (click)="wishList()">Add to
......
......@@ -7,9 +7,8 @@ import { EcmCategoryComponent } from '../ecm-category/ecm-category.component';
import { Observable } from 'rxjs/Observable';
import { Store } from '@ngrx/store';
import { EcmStoreModel } from '../../ecm-store/ecm-store.model';
import { UPDATE_QUANTITY, REMOVE } from '../../ecm-store/ecm-store';
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';
......@@ -25,12 +24,12 @@ import { Router, ActivatedRoute } from '@angular/router';
providers: [EcmProductDetailService]
})
export class EcmCartComponent implements OnInit, AfterViewChecked {
cartItemsDetail: Item[];
cartItemsDetail: ItemDetail[];
cartCount = 0;
catCode;
displayItem = 3;
totalPrice: number = 0;
cartItems : Observable<Item[]>;
cartItems : Observable<ItemDetail[]>;
disableScrollDown = false
......@@ -40,25 +39,25 @@ 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<EcmStoreModel> ) { }
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 cartActions: CartActions) { }
ngOnInit() {
this.getCartItem();
this.scrollToBottom();
}
ngAfterViewChecked() {
this.scrollToBottom();
ngAfterViewChecked() {
this.scrollToBottom();
}
getCartItem() {
this.cartItems = this.store.select('cart');
this.cartItems = this.store.select('cartItems');
this.cartItems.subscribe( cartItems => {
this.totalPrice = 0;
cartItems.forEach(
item => {
this.totalPrice = this.totalPrice + (parseFloat( item.costRate ) * item.itemQuantity);
this.totalPrice = this.totalPrice + (parseFloat( item.itemHeader.itemDiscountedRate ) * item.itemQuantity);
}
);
});
......@@ -68,7 +67,8 @@ 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, {})
......@@ -77,6 +77,9 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
}, error => {
console.log( error.json() );
});
*/
this.store.dispatch(this.cartActions.deleteCartItem(item));
this.getCartItem();
this.openSnackBar('Item Removed from your Cart' );
......@@ -86,32 +89,31 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
this.router.navigate( ['/cart'] );
}
increment(item : Item) {
increment(item : ItemDetail) {
item.itemQuantity++;
this.addToCart(item);
}
addToCart(data : Item) {
let cartData = new Item;
cartData.itemCode = data.itemCode;
cartData.itemQuantity = data.itemQuantity;
cartData.costRate = data.costRate;
cartData.itemCode = item.itemCode;
cartData.itemQuantity = item.itemQuantity;
//cartData.costRate = item.itemHeader.itemDiscountedRate;
this.store.dispatch({ type: 'UPDATE_QUANTITY', payload: cartData });
this.openSnackBar( 'Quantity increased of ' + data.shDescr );
this.productDetailService.addToCart(cartData);
//this.store.dispatch({ type: 'UPDATE_QUANTITY', payload: cartData });
this.store.dispatch(this.cartActions.updateCart(cartData));
this.openSnackBar( 'Quantity increased of ' + item.itemHeader.itemShDescr );
//this.productDetailService.addToCart(cartData);
}
decrement(data : Item) {
data.itemQuantity--;
decrement(item : ItemDetail) {
item.itemQuantity--;
let cartData = new Item;
cartData.itemCode = data.itemCode;
cartData.itemQuantity = data.itemQuantity;
cartData.costRate = data.costRate;
cartData.itemCode = item.itemCode;
cartData.itemQuantity = item.itemQuantity;
// cartData.costRate = item.itemHeader.itemDiscountedRate;
this.store.dispatch({ type: 'UPDATE_QUANTITY', payload: cartData });
this.openSnackBar( 'Quantity decreased of ' + data.shDescr );
this.productDetailService.addToCart(cartData);
//this.store.dispatch({ type: 'UPDATE_QUANTITY', payload: cartData });
this.store.dispatch(this.cartActions.updateCart(cartData));
this.openSnackBar( 'Quantity decreased of ' + item.itemHeader.itemShDescr );
//this.productDetailService.addToCart(cartData);
}
checkQantity(item) {
......
......@@ -3,20 +3,20 @@ import { Http, Response, Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
import { Item } from '../../ecm-model/product-model';
import { ItemDetail } from '../../ecm-model/product-detail-model';
import { Store } from '@ngrx/store';
import { ADD_TO_CART } from '../../ecm-store/ecm-store';
import { EcmStoreModel } from '../../ecm-store/ecm-store.model';
import {AppState} from '../../ecm-store/reducers';
import {CartActions} from '../../ecm-store/actions';
@Injectable()
export class EcmCartService {
private userActionUrl = '/ecm/service/feeds/cart';
public itemCode;
cartItems: Item[];
cartItems: ItemDetail[];
constructor(private http: Http, private store: Store<EcmStoreModel>) { }
constructor(private http: Http, private store: Store<AppState>, private cartActions: CartActions) { }
setCartItems(){
this.fetchCartItems().subscribe(
......@@ -24,28 +24,105 @@ 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({ type: ADD_TO_CART, payload: item });
this.store.dispatch(this.cartActions.addToCart(item));
})
}
});
}
fetchCartItems(): Observable<Item[]> {
fetchCartItems(): Observable<ItemDetail[]> {
let headers = new Headers( { 'Content-Type': 'application/json' });
let options = new RequestOptions( { headers: headers });
return this.http.get( this.userActionUrl, options )
.map( this.extractData )
.catch( this.handleError );
.map( (res) => this.extractData(res) );
}
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 });
return this.http.post( '/ecm/service/feeds/cart', JSON.stringify(cartData) , options)
.map( (res) => this.extractData(res) );
}
private extractData(res: Response) {
let body = res.json();
console.log('extractData[' + JSON.stringify(body) + ']');
return body || { };
updateCart( cartData ) {
console.log( "StoreInCart Called" );
console.log(JSON.stringify(cartData));
let headers = new Headers( { 'Content-Type': 'application/json' });
let options = new RequestOptions( { headers: headers });
return this.http.post( '/ecm/service/feeds/cart', JSON.stringify(cartData) , options)
.map( (res) => this.extractData(res) );
}
deleteCartItem( item ) {
console.log( "deleteCartItem Called" );
return this.http.delete( this.userActionUrl + '/' + item.itemCode, {})
.map(res => res.json());
}
private extractData(res: Response) {
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) {
// In a real world app, we might use a remote logging infrastructure
......
......@@ -5,7 +5,7 @@
<span class="ecm-section-info-title">Categories</span>
<span class="ecm-section-info-subhead">Explore top Authentic Regional Foods, Outings, Celebrations around {{selectedPlace}}</span>
</div>
<div class="small-12 medium-6 large-4 column end "*ngFor="let _category of categories">
<div class="small-12 medium-6 large-4 column end "*ngFor="let _category of categories | async">
<ecm-card (storeData)="storeCategory(_category)" [category]="_category"></ecm-card>
</div>
<div></div>
......
import { Component, OnInit, HostListener } from '@angular/core';
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 { EcmStoreModel } from '../../ecm-store/ecm-store.model';
import { Category } from '../../ecm-model/category-model';
import { Observable } from 'rxjs/Observable';
@Component({
selector: 'ecm-category',
templateUrl: './ecm-category.component.html',
......@@ -15,7 +18,7 @@ import { Category } from '../../ecm-model/category-model';
export class EcmCategoryComponent implements OnInit {
errorMessage: string;
selectedPlace = 'Mumbai';
categories: Category[];
categories: Observable<Category[]>;
position: any;;
@HostListener("window:scroll", [])
......@@ -23,38 +26,46 @@ export class EcmCategoryComponent implements OnInit {
this.position=window.pageYOffset;
}
constructor(public categoryService: EcmCategoryService, private scroll_service: ScrollService, private store: Store<EcmStoreModel>) { }
constructor(public categoryService: EcmCategoryService, private scroll_service: ScrollService, private store: Store<AppState>, private categoryAction:CategoryActions, private subCategoryAction: SubCategoryActions) { }
ngOnInit() {
this.getCategories();
}
ngOnDestroy(){
ngOnDestroy() {
this.scroll_service.setCatPos(this.position);
}
ngAfterViewInit(){
ngAfterViewInit() {
var pos=this.scroll_service.getCatPos();
window.scrollTo(0,pos);
console.log("AfterContenet Init of Category");
}
getCategories() {
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 + ']');
});
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){
storeCategory(selectedCategory) {
console.log(selectedCategory);
this.store.dispatch({type: 'CLEAR_CATEGORY', payload: selectedCategory});
this.store.dispatch({type: 'CATEGORY', payload: selectedCategory});
//this.store.dispatch({type: 'CLEAR_CATEGORY', payload: selectedCategory});
//this.store.dispatch({type: 'CATEGORY', payload: selectedCategory});
this.store.dispatch( this.subCategoryAction.loadSubCategories( selectedCategory.catCode ) );
this.store.dispatch(this.categoryAction.getCategorySuccess(selectedCategory));
}
}
......@@ -3,8 +3,9 @@ import { FormBuilder, Validators,NgForm } from '@angular/forms';
import { EcmCartService } from '../ecm-cart/ecm-cart.service';
import { Item } from '../../ecm-model/product-model';
import { Observable } from 'rxjs/Observable';
import { Store } from '@ngrx/store';
import { EcmStoreModel } from '../../ecm-store/ecm-store.model';
import {AppState} from '../../ecm-store/reducers';
@Component( {
selector: 'ecm-checkout',
......@@ -24,7 +25,7 @@ export class EcmCheckoutComponent implements OnInit {
years;
cartItems: Observable<Item[]>;
constructor(private formBuilder: FormBuilder, public cartService: EcmCartService, private store: Store<EcmStoreModel>) {
constructor(private formBuilder: FormBuilder, public cartService: EcmCartService, private store: Store<AppState>) {
this.countries = [
{ viewValue: 'India' },
{ viewValue: 'UAE' },
......@@ -66,7 +67,7 @@ export class EcmCheckoutComponent implements OnInit {
}
getCartItems() {
this.cartItems = this.store.select('cart');
this.cartItems = this.store.select('cartItems');
this.cartItems.subscribe( cartItems => {
this.totalPrice = 0;
......
......@@ -5,17 +5,22 @@
padding-top: 70px;
}
.ecm-section-info {
padding: 10px;
padding: 0 10px 15px 10px;
border-bottom: 1px solid #f2f2f2;
}
.ecm-section-info-title {
font-size: 26px;
/* font-size: 26px;
color: #444;
display: block;
display: block; */
font-size: 20px;
color: black;
display: inline;
}
.ecm-section-info-subhead {
font-size: 16px;
color: #888;
display: block;
/* display: block; */
display: inline
}
.end {
padding-top: 15px;
......@@ -112,4 +117,176 @@
color: mediumvioletred;
font-size: 20px;
}
/* loading section end */
\ No newline at end of file
/* loading section end */
.filter-pane{
position: relative;
width: 100%;
height: 100%;
display: inline-block;
min-height: 600px;
text-align: center;
}
.item-card {
position: relative;
}
.item-card:hover {
/* -webkit-filter: contrast(100%) brightness(95%); */
/* filter: contrast(100%) brightness(95%); */
}
.item-card-overlay {
display: none;
}
.item-card-overlay-action{
color: mediumvioletred;
line-height: 60px;
background: #fff;
padding: 10px;
border-radius: 2px;
font-size: 12px;
font-weight: 600;
}
.item-card-overlay-action > i {
vertical-align: sub;
font-size: 16px;
}
.item-card:hover > .item-card-overlay {
position: absolute;
z-index: 1;
display: block;
text-align: center;
width: calc( 100% - 30px);
height: 60px;
top: 120px;
cursor: pointer;
}
@media screen and (max-width: 750px){
.filter-pane{
min-height: 60px;
}
.ecm-items-details{
margin-top: 0px !important;
}
.ecm-filter-details{
margin-top: 0px !important;
}
.ecm-section-info{
border: 2px solid ghostwhite;
}
.ecm-item-card-detail{
border: 2px solid ghostwhite;
}
}
.ecm-total-items{
font-size: 14px;
color: dimgray;
}
.ecm-items-details{
/*margin-top: -39px;*/
border-left: 1px solid #f2f2f2;
}
.ecm-item-card-detail {
display: inline-block;
border-right: 0px;
border-bottom: 0px;
}
.ecm-filter-details{
/*margin-top: -24px;*/
padding: 0;
}
.ecm-items-section {
display: inline-block;
padding: 0;
}
.filter-header {
padding-top: 20px;
padding-bottom: 16px;
border-bottom: 1px solid #f2f2f2;
}
.filter-hader-title {
border-bottom: 3px solid #c71585;
padding-bottom: 16px;
}
.ecm-input-container {
padding-bottom: 20px;
}
.price-title {
padding-left: 25px;
padding-top: 10px;
padding-bottom: 10px;
text-align: left;
cursor: pointer;
/*Background Image*/
background-image: url("../../../assets/images/down_arrow.png");
background-position: right 14px;
background-repeat: no-repeat;
background-size: 16px 16px;
margin-right: 15px;
}
.price-slider {
height: 48px !important;
min-width: 250px !important;
}
.amount-range {
height: 35px;
}
.min-value {
float: left;
padding-left: 20px;
font-size: 0.8rem;
}
.max-value {
float: right;
padding-right: 20px;
font-size: 0.8rem;
}
.min-val-input {
width: 90px;
height: 35px;
margin-left: 20px;
display: inline-block;
padding-left: 10px;
}
.max-val-input {
width: 90px;
height: 35px;
margin-right: 20px;
padding-left: 10px;
}
.find-button {
padding: 0;
display: initial;
min-width: 45px;
color: mediumvioletred;
box-shadow: 0 0px 5px 1px rgba(0,0,0,.1);
border-radius: 3px;
margin-right: 5px;
}
.value-divider {
width: 20px;
height: 35px;
display: inline-block;
font-size: 22px;
line-height: 35px;
}
.container {
border-bottom: 1px solid #f2f2f2;
}
......@@ -19,15 +19,59 @@
<div *ngIf="items">
<section class="subcategories-section">
<div class="row row-subcategory">
<div class="ecm-section-info">
<span class="ecm-section-info-title">{{subcategory?.shDescr}}</span>
<span class="ecm-section-info-subhead">{{subcategory?.descr}}</span>
<div class="row">
<md-card class="ecm-items-section">
<div class="small-12 medium-3 large-3 column ecm-filter-details">
<div class = "filter-pane">
<div class="filter-header">
<span class="filter-hader-title">Filter By</span>
</div>
<div class="container">
<div class="price-title" (click)="showHide();">Price</div>
<div *ngIf="show">
<md-slider min="500" max="35000" class="price-slider" (input)="onInputChange($event);"></md-slider>
<div class="amount-range">
<span class="min-value">Rs. {{minVal}}</span>
<span class="max-value">Rs. {{maxVal}}</span>
</div>
<div class="ecm-input-container">
<input type="text" class="min-val-input" placeholder="500" [(ngModel)]="minVal">
<span class="value-divider">-</span>
<input type="text" class="max-val-input" placeholder="35000" [(ngModel)]="maxVal">
<button md-button class="find-button">Find</button>
</div>
</div>
</div>
</div>
<div class="small-12 medium-6 large-4 column end "*ngFor="let _item of items">
<!--<ecm-item-caption [itemData]="_item"></ecm-item-caption> -->
<ecm-card [itemData]="_item" [extraParam]="extra_param"></ecm-card>
</div>
<div class="small-12 medium-9 large-9 column end ecm-items-details">
<div class="row">
<div class="ecm-section-info">
<span class="ecm-section-info-title">{{subcategory?.shDescr}}</span>
<span class="ecm-total-items">( {{(items | async)?.length}} Items )</span>
<!-- <span class="ecm-section-info-subhead">{{subcategory?.descr}}</span> -->
</div>
<div class="ecm-item-card-detail">
<div class="small-12 medium-6 large-4 column end item-card"
*ngFor="let _item of items | async">
<div class="item-card-overlay" (click)="addToCart(_item)">
<span class="item-card-overlay-action" >
<i class="material-icons">shopping_cart</i>
{{ (_item.itemCode.indexOf('L2D014') == 0 ) ? 'Add to Cart' : 'Enroll Now'}}
</span>
</div>
<!--<ecm-item-caption [itemData]="_item"></ecm-item-caption> -->
<ecm-card [itemData]="_item" [extraParam]="extra_param"></ecm-card>
</div>
</div>
</div>
</div>
</md-card>
</div>
</section>
</div>
......
import { Component, OnInit,HostListener } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { AppState } from '../../ecm-store/reducers';
import { Store } from '@ngrx/store';
import { ItemActions } from '../../ecm-store/actions';
import { EcmProductService } from './ecm-product.service';
import { ScrollService } from '../../scroll.service';
import { EcmStoreModel } from '../../ecm-store/ecm-store.model';
import { Category } from '../../ecm-model/category-model';
import { SubCategory } from '../../ecm-model/subcategory-model';
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]
providers: [EcmProductService, EcmProductDetailService]
})
export class EcmProductComponent implements OnInit {
position=0;
isCatItems = 'false';
show = false;
minVal = 500;
maxVal = 35000;
@HostListener("window:scroll", [])
onWindowScroll() {
this.position=window.pageYOffset;
}
private items: Item[];
Items = 0;
private items: Observable<Item[]>;
private extra_param= { "catCode":'', "catShDesc":'',scatDesc:'' };
private category : Category;
private subcategory : SubCategory;
itemDetail: ItemDetail;
attribVal;
attribCode;
constructor(private route: ActivatedRoute, private router:Router,public subcategoryService: EcmProductService, private scroll_service: ScrollService, private store: Store<EcmStoreModel>) { }
constructor(private route: ActivatedRoute, private router:Router,public subcategoryService: EcmProductService,public productDetailService: EcmProductDetailService, private scroll_service: ScrollService, private store: Store<AppState>, private itemAction: ItemActions) { }
ngOnInit() {
window.scrollTo(0,0);
this.route.params.subscribe( params => {
......@@ -45,22 +59,31 @@ export class EcmProductComponent implements OnInit {
//this.getSubCategory( viewKey );
this.fetchStore('SubCategory');
this.getItems(scatCode);
});
}
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 ) + ']' );
},
);
*/
}
storeCategory(selectedSubCategory){
console.log(selectedSubCategory);
this.store.dispatch({type: 'CLEAR_SUB_CATEGORY', payload: selectedSubCategory});
this.store.dispatch({type: 'SUB_CATEGORY', payload: selectedSubCategory});
storeCategory(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.getItem( selectedItem.itemCode ) );
}
fetchStore( viewType: string){
......@@ -82,4 +105,42 @@ export class EcmProductComponent implements OnInit {
this.subcategory = storeSubCategory;
}
}
addToCart(items) {
let cartData = new Item;
cartData.itemCode = items.itemCode;
cartData.itemQuantity = 1;
cartData.costRate = items.costRate;
cartData.descr = items.itemDescr;
cartData.shDescr = items.shDescr;
if(this.attribCode == "COLOR"){
cartData.phyAttribId3 = this.attribVal;
}
else if(this.attribCode == "SIZE"){
cartData.phyAttribId1 = this.attribVal;
}
//this.store.dispatch({ type: ADD_TO_CART, payload: cartData });
this.productDetailService.addToCart(cartData);
//Check Store data
this.store.select('cart').forEach(
value => {
console.log('Cart Items----');
console.log(value);
}
);
}
showHide(){
if(this.show)
this.show = false;
else
this.show = true;
}
onInputChange(event: any){
this.maxVal = event.value;
}
}
......@@ -24,7 +24,7 @@
<span *ngIf="category" class="ecm-section-info-title">{{category?.shDescr}}</span>
<span *ngIf="category" class="ecm-section-info-subhead">{{category?.descr}}</span>
</div>
<div class="small-12 medium-6 large-4 column end " *ngFor="let _subcategory of subcategories">
<div class="small-12 medium-6 large-4 column end " *ngFor="let _subcategory of subcategories | async">
<ecm-card (storeData)="storeCategory(_subcategory)" [subcategory]="_subcategory"></ecm-card>
</div>
</div>
......
import { Component, OnInit,HostListener } from '@angular/core';
import { Component, OnInit, HostListener } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
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 { EcmStoreModel } from '../../ecm-store/ecm-store.model';
import { Category } from '../../ecm-model/category-model';
import { SubCategory } from '../../ecm-model/subcategory-model';
import { Item } from '../../ecm-model/product-model';
@Component({
selector: 'ecm-sub-category',
templateUrl: './ecm-sub-category.component.html',
styleUrls: ['./ecm-sub-category.component.css'],
providers: [EcmSubCategoryService]
import { Observable } from 'rxjs/Observable';
@Component( {
selector: 'ecm-sub-category',
templateUrl: './ecm-sub-category.component.html',
styleUrls: ['./ecm-sub-category.component.css'],
providers: [EcmSubCategoryService]
})
export class EcmSubCategoryComponent implements OnInit {
position=0;
position = 0;
isCatItems = 'false';
@HostListener("window:scroll", [])
onWindowScroll() {
this.position=window.pageYOffset;
}
@HostListener( "window:scroll", [] )
onWindowScroll() {
this.position = window.pageYOffset;
}
private subcategories: Observable<SubCategory[]>;
private extra_param = { "catCode": '', "catShDesc": '', scatDesc: '' };
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 ) { }
ngOnInit() {
window.scrollTo( 0, 0 );
this.route.params.subscribe( params => {
//let id: number = +params['id']; // (+) converts string 'id' to a number
// In a real app: dispatch action to load the details here.
let catCode = params['catCode'];
console.log( 'ngOnInit catCode[' + catCode + ']' );
console.log( "Subcat Listing..." );
console.log( window.location.pathname );
//this.fetchStore(catCode,'Category');
this.getSubCategories( catCode );
});
}
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 ) + ']' );
}
},
);
*/
}
storeCategory( selectedSubCategory ) {
//this.store.dispatch({type: 'CLEAR_SUB_CATEGORY', payload: selectedSubCategory});
//this.store.dispatch({type: 'SUB_CATEGORY', payload: selectedSubCategory});
this.store.dispatch( this.itemAction.loadItems( selectedSubCategory.scatCode ) );
this.store.dispatch( this.subCategoryAction.getSubCategorySuccess( selectedSubCategory ) );
}
private subcategories: SubCategory[];
private extra_param= { "catCode":'', "catShDesc":'',scatDesc:'' };
private category : Category;
private subcategory : SubCategory;
//private category: Observable<Array<Category>>;
fetchStore( viewKey: string, viewType: string ) {
if ( viewType == 'Category' ) {
let storeCategory;
this.store.select( 'CATEGORY' ).forEach(
value => storeCategory = value
);
this.category = storeCategory;
}
constructor(private route: ActivatedRoute, private router:Router,public subcategoryService: EcmSubCategoryService, private scroll_service: ScrollService, private store: Store<EcmStoreModel>) { }
ngOnInit() {
window.scrollTo(0,0);
this.route.params.subscribe( params => {
//let id: number = +params['id']; // (+) converts string 'id' to a number
// In a real app: dispatch action to load the details here.
let catCode = params['catCode'];
console.log( 'ngOnInit catCode[' + catCode + ']' );
console.log("Subcat Listing...");
console.log(window.location.pathname);
this.fetchStore(catCode,'Category');
this.getSubCategories(catCode);
});
}
getSubCategories( catCode: string ) {
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 ) + ']' );
}*/
},
);
}
storeCategory(selectedSubCategory){
console.log(selectedSubCategory);
this.store.dispatch({type: 'CLEAR_SUB_CATEGORY', payload: selectedSubCategory});
this.store.dispatch({type: 'SUB_CATEGORY', payload: selectedSubCategory});
}
fetchStore(viewKey: string, viewType: string){
if(viewType == 'Category')
{
let storeCategory;
this.store.select('CATEGORY').forEach(
value => storeCategory=value
);
this.category = storeCategory;
}
if(viewType == 'SubCategory')
{
let storeSubCategory;
this.store.select('SUBCATEGORY').forEach(
value => { storeSubCategory=value; console.log(value);}
);
this.subcategory = storeSubCategory;
}
if ( viewType == 'SubCategory' ) {
let storeSubCategory;
this.store.select( 'SUBCATEGORY' ).forEach(
value => { storeSubCategory = value; console.log( value ); }
);
this.subcategory = storeSubCategory;
}
}
}
......@@ -117,20 +117,24 @@
margin-bottom: 15px !important;
}
.counter-screen{
display: block !important;
display: inline-block !important;
float: none !important;
}
.items-cost-rate {
text-align: left !important;
padding-top: 40px !important;
}
.wish-remove-dipslay{
text-align: right !important;
padding-top: 100px !important;
padding-top: 0px !important;
padding-right: 0px !important;
}
.item-image {
.remove-items{
padding-left: 0px !important;
}
/* .item-image {
width: 16% !important;
bottom: 100px !important;
}
} */
.counter{
position: relative;
padding-top: 18px;
......@@ -230,10 +234,11 @@
/* width: 140px;
padding-top: 16px;
position: relative; */
width: 10%;
display: inline-block;
position: relative;
bottom: 96px;
vertical-align: top;
width: 110px;
top: 30px;
}
.change-color{
......
<div *ngIf="wishListItems | async">
<div *ngIf="(wishListItems | async)?.length == 0">
<ecm-header [isFixedHeader]=false> </ecm-header>
<ecm-breadcrumbs [pageName]="'WISHLIST'"></ecm-breadcrumbs>
<div class="row">
<div class="medium-12 large-12 columns" style="text-align: center; margin-top: 120px;">
<img class="empty-cart-img" src="/ecm/assets/images/svg/Empty Cart.svg">
<span class="empty-cart-title">Empty Wishlist</span> <span
class="border-line"></span> <span class="empty-cart-msg">Looks
like you haven't made your choice yet...</span>
</div>
</div>
<div style="margin-top: 155px;">
<ecm-footer></ecm-footer>
</div>
</div>
<div *ngIf="(wishListItems | async)?.length > 0">
<ecm-header [isFixedHeader]=false> </ecm-header>
<ecm-breadcrumbs [pageName]="'WISHLIST'"></ecm-breadcrumbs>
<div class="row details-of-Cart">
......@@ -28,7 +45,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)="deletewishlistItem(item) "><i class="material-icons" style="font-size: 24px;color: mediumvioletred;">delete</i></span>
<span class="remove-items" (click)="deletewishlistItem(item) ">Remove</span>
</div>
</div>
......@@ -40,4 +57,5 @@
</div>
</md-card>
</div>
<ecm-footer></ecm-footer>
</div>
......@@ -7,8 +7,7 @@ import { EcmProductDetailService } from '../../ecm-product-details/ecm-product-d
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 { AppState } from '../../ecm-store/reducers';
import { Observable } from 'rxjs/Observable';
......@@ -24,7 +23,7 @@ export class EcmWishListComponent implements OnInit {
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<EcmStoreModel> ) { }
constructor( public subcategoryService: EcmProductDetailService, private route: ActivatedRoute, private router: Router, public snackBar: MdSnackBar, public wishListService: EcmWishListService, private http: Http, private store: Store<AppState> ) { }
ngOnInit() {
this.getWishlistItems();
......@@ -43,7 +42,7 @@ export class EcmWishListComponent implements OnInit {
userActionUrl = '/ecm/service/feeds/wishlist';
deletewishlistItem( item ) {
this.store.dispatch( { type: REMOVE_WISLIST, payload: item });
//this.store.dispatch( { type: REMOVE_WISLIST, payload: item });
this.http.delete( this.userActionUrl + '/' + item.itemCode, {})
.subscribe( data => {
......
......@@ -4,10 +4,9 @@ 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 { AppState } from '../../ecm-store/reducers';
import { Item } from '../../ecm-model/product-model';
import { EcmStoreModel } from '../../ecm-store/ecm-store.model';
@Injectable()
export class EcmWishListService {
......@@ -15,7 +14,7 @@ export class EcmWishListService {
private wishListUrl = '/ecm/service/feeds/wishlist'; // URL to web service
wishListItems: Item[];
constructor( private http: Http, private store: Store<EcmStoreModel> ) { }
constructor( private http: Http, private store: Store<AppState> ) { }
setWishlistItems() {
this.fetchWishlistItems().subscribe(
......@@ -23,7 +22,7 @@ export class EcmWishListService {
this.wishListItems = data;
if ( data && data != null ) {
this.wishListItems.forEach( item => {
this.store.dispatch( { type: ADD_TO_WISHLIST, payload: item });
//this.store.dispatch( { type: ADD_TO_WISHLIST, payload: item });
})
}
});
......
......@@ -80,3 +80,8 @@ body {
button {
border: none;
}
input:-webkit-autofill
{
-webkit-box-shadow: 0 0 0 30px white inset !important;
}
\ No newline at end of file
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