Commit eca66088 authored by prumde's avatar prumde

Updated


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@174455 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 90154d9b
...@@ -7,7 +7,7 @@ import {AppState} from '../ecm-store/reducers'; ...@@ -7,7 +7,7 @@ import {AppState} from '../ecm-store/reducers';
import { ECMCard } from '../ecm-model/card-model'; import { ECMCard } from '../ecm-model/card-model';
import { Category } from '../ecm-model/category-model'; import { Category } from '../ecm-model/category-model';
import { SubCategory } from '../ecm-model/subcategory-model'; import { SubCategory } from '../ecm-model/subcategory-model';
import { Item } from '../ecm-model/product-model'; import { ItemDetail } from '../ecm-model/product-detail-model';
import { Reviews } from '../ecm-model/product-review.model'; import { Reviews } from '../ecm-model/product-review.model';
import { EcmProductReviewService } from '../ecm-product-details/ecm-product-review.service'; import { EcmProductReviewService } from '../ecm-product-details/ecm-product-review.service';
...@@ -22,7 +22,7 @@ export class ECMCardComponent implements OnInit { ...@@ -22,7 +22,7 @@ export class ECMCardComponent implements OnInit {
@Input() card: ECMCard; @Input() card: ECMCard;
@Input() category: Category; @Input() category: Category;
@Input() subcategory: SubCategory; @Input() subcategory: SubCategory;
@Input() itemData: Item; @Input() itemData: ItemDetail;
@Input() extraParam: any; @Input() extraParam: any;
@Input() reviewsData: Reviews; @Input() reviewsData: Reviews;
......
...@@ -4,8 +4,8 @@ import { MdSnackBar } from '@angular/material'; ...@@ -4,8 +4,8 @@ import { MdSnackBar } from '@angular/material';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import {AppState} from '../ecm-store/reducers'; import { AppState } from '../ecm-store/reducers';
import {CartActions} from '../ecm-store/actions'; import { CartActions } from '../ecm-store/actions';
import { EcmProductDetailService } from './ecm-product-detail.service'; import { EcmProductDetailService } from './ecm-product-detail.service';
import { ScrollService } from '../scroll.service'; import { ScrollService } from '../scroll.service';
...@@ -23,7 +23,7 @@ import { ECMCart } from '../ecm-model/cart-model'; ...@@ -23,7 +23,7 @@ import { ECMCart } from '../ecm-model/cart-model';
import { Item } from '../ecm-model/product-model'; import { Item } from '../ecm-model/product-model';
import { ECMHeaderComponent } from '../ecm-header/ecm-header.component'; import { ECMHeaderComponent } from '../ecm-header/ecm-header.component';
import { Reviews } from '../ecm-model/product-review.model'; import { Reviews } from '../ecm-model/product-review.model';
import {MdDialog, MdDialogRef, MdDialogConfig, MD_DIALOG_DATA} from '@angular/material'; import { MdDialog, MdDialogRef, MdDialogConfig, MD_DIALOG_DATA } from '@angular/material';
import { ECMWriteReviewDialog } from './ecm-product-review.component'; import { ECMWriteReviewDialog } from './ecm-product-review.component';
export const ECM_TEMPLATES: any = { export const ECM_TEMPLATES: any = {
...@@ -46,7 +46,7 @@ export class EcmProductDetailsComponent implements OnInit { ...@@ -46,7 +46,7 @@ export class EcmProductDetailsComponent implements OnInit {
itemCode: string; itemCode: string;
ecmTemplate: EcmTemplateItem; ecmTemplate: EcmTemplateItem;
itemDetail: ItemDetail; itemDetail;
scatCode; scatCode;
noOfReviews; noOfReviews;
userReview: Reviews; userReview: Reviews;
...@@ -67,6 +67,31 @@ export class EcmProductDetailsComponent implements OnInit { ...@@ -67,6 +67,31 @@ export class EcmProductDetailsComponent implements OnInit {
} }
getItemDetail( itemCode: string ) { getItemDetail( itemCode: string ) {
this.store.select('item')
.subscribe( itemDetail => {
this.itemDetail = itemDetail
if ( this.itemDetail ) {
this.storeCatSubcat();
let ecmTemplateName = this.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( this.itemDetail );
}
else {
alert( "Sorry, the " + ecmTemplateName + " is not in the system yet!" );
}
}
});
/*
this.productDetailService.getItemDetail( itemCode ).subscribe( this.productDetailService.getItemDetail( itemCode ).subscribe(
itemDetail => { itemDetail => {
if( itemDetail ) console.log( 'comp itemCode[' + itemCode + '] itemDetail[' + itemDetail + '] \n this.itemDetail[' + JSON.stringify( itemDetail ) + ']' ); if( itemDetail ) console.log( 'comp itemCode[' + itemCode + '] itemDetail[' + itemDetail + '] \n this.itemDetail[' + JSON.stringify( itemDetail ) + ']' );
...@@ -95,6 +120,7 @@ export class EcmProductDetailsComponent implements OnInit { ...@@ -95,6 +120,7 @@ export class EcmProductDetailsComponent implements OnInit {
console.log( 'comp ecmTemplate[' + this.ecmTemplate + ']' ); console.log( 'comp ecmTemplate[' + this.ecmTemplate + ']' );
}, },
); );
*/
} }
scrollToReviews() { scrollToReviews() {
......
...@@ -22,5 +22,4 @@ export class SubCategoryEffects { ...@@ -22,5 +22,4 @@ export class SubCategoryEffects {
.ofType(SubCategoryActions.GET_SUBCATEGORY) .ofType(SubCategoryActions.GET_SUBCATEGORY)
.switchMap(scatCode => this.svc.getSubCategory(scatCode.payload)) .switchMap(scatCode => this.svc.getSubCategory(scatCode.payload))
.map(subcategory => this.subCategoryActions.getSubCategorySuccess(subcategory)); .map(subcategory => this.subCategoryActions.getSubCategorySuccess(subcategory));
} }
\ No newline at end of file
import {Action} from '@ngrx/store'; import {Action} from '@ngrx/store';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {Item} from '../../ecm-model/product-model'; import { ItemDetail } from '../../ecm-model/product-detail-model';
import {ItemActions} from '../actions'; import {ItemActions} from '../actions';
import * as _ from 'lodash'; import * as _ from 'lodash';
export type ItemListState = Item[]; export type ItemListState = ItemDetail[];
const initialState: ItemListState = []; const initialState: ItemListState = [];
......
...@@ -39,7 +39,7 @@ export class EcmCartComponent implements OnInit, AfterViewChecked { ...@@ -39,7 +39,7 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
@ViewChild('scrollMe') private myScrollContainer: ElementRef; @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 cartActions: CartActions) { } 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) { }
ngOnInit() { ngOnInit() {
this.getCartItem(); this.getCartItem();
...@@ -78,7 +78,7 @@ export class EcmCartComponent implements OnInit, AfterViewChecked { ...@@ -78,7 +78,7 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
console.log( error.json() ); console.log( error.json() );
}); });
*/ */
this.store.dispatch(this.cartActions.deleteCartItem(item)); this.store.dispatch(this.cartAction.deleteCartItem(item));
this.getCartItem(); this.getCartItem();
this.openSnackBar('Item Removed from your Cart' ); this.openSnackBar('Item Removed from your Cart' );
...@@ -98,7 +98,7 @@ export class EcmCartComponent implements OnInit, AfterViewChecked { ...@@ -98,7 +98,7 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
//cartData.costRate = item.itemHeader.itemDiscountedRate; //cartData.costRate = item.itemHeader.itemDiscountedRate;
//this.store.dispatch({ type: 'UPDATE_QUANTITY', payload: cartData }); //this.store.dispatch({ type: 'UPDATE_QUANTITY', payload: cartData });
this.store.dispatch(this.cartActions.updateCart(cartData)); this.store.dispatch(this.cartAction.updateCart(cartData));
this.openSnackBar( 'Quantity increased of ' + item.itemHeader.itemShDescr ); this.openSnackBar( 'Quantity increased of ' + item.itemHeader.itemShDescr );
//this.productDetailService.addToCart(cartData); //this.productDetailService.addToCart(cartData);
} }
...@@ -111,7 +111,7 @@ export class EcmCartComponent implements OnInit, AfterViewChecked { ...@@ -111,7 +111,7 @@ export class EcmCartComponent implements OnInit, AfterViewChecked {
// cartData.costRate = item.itemHeader.itemDiscountedRate; // cartData.costRate = item.itemHeader.itemDiscountedRate;
//this.store.dispatch({ type: 'UPDATE_QUANTITY', payload: cartData }); //this.store.dispatch({ type: 'UPDATE_QUANTITY', payload: cartData });
this.store.dispatch(this.cartActions.updateCart(cartData)); this.store.dispatch(this.cartAction.updateCart(cartData));
this.openSnackBar( 'Quantity decreased of ' + item.itemHeader.itemShDescr ); this.openSnackBar( 'Quantity decreased of ' + item.itemHeader.itemShDescr );
//this.productDetailService.addToCart(cartData); //this.productDetailService.addToCart(cartData);
} }
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
</span> </span>
</div> </div>
<!--<ecm-item-caption [itemData]="_item"></ecm-item-caption> --> <!--<ecm-item-caption [itemData]="_item"></ecm-item-caption> -->
<ecm-card [itemData]="_item" [extraParam]="extra_param"></ecm-card> <ecm-card (storeData)="storeItem(_item)" [itemData]="_item" [extraParam]="extra_param"></ecm-card>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -4,7 +4,7 @@ import { Observable } from 'rxjs/Observable'; ...@@ -4,7 +4,7 @@ import { Observable } from 'rxjs/Observable';
import { AppState } from '../../ecm-store/reducers'; import { AppState } from '../../ecm-store/reducers';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { ItemActions } from '../../ecm-store/actions'; import { ItemActions, CartActions } from '../../ecm-store/actions';
import { Category } from '../../ecm-model/category-model'; import { Category } from '../../ecm-model/category-model';
import { SubCategory } from '../../ecm-model/subcategory-model'; import { SubCategory } from '../../ecm-model/subcategory-model';
...@@ -36,7 +36,7 @@ export class EcmProductComponent implements OnInit { ...@@ -36,7 +36,7 @@ export class EcmProductComponent implements OnInit {
} }
Items = 0; Items = 0;
private items: Observable<Item[]>; private items: Observable<ItemDetail[]>;
private extra_param= { "catCode":'', "catShDesc":'',scatDesc:'' }; private extra_param= { "catCode":'', "catShDesc":'',scatDesc:'' };
private category : Category; private category : Category;
...@@ -46,7 +46,7 @@ export class EcmProductComponent implements OnInit { ...@@ -46,7 +46,7 @@ export class EcmProductComponent implements OnInit {
attribCode; 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) { } 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) { }
ngOnInit() { ngOnInit() {
window.scrollTo(0,0); window.scrollTo(0,0);
this.route.params.subscribe( params => { this.route.params.subscribe( params => {
...@@ -78,12 +78,12 @@ export class EcmProductComponent implements OnInit { ...@@ -78,12 +78,12 @@ export class EcmProductComponent implements OnInit {
*/ */
} }
storeCategory(selectedItem){ storeItem(selectedItem){
console.log(selectedItem); console.log(selectedItem);
//this.store.dispatch({type: 'CLEAR_SUB_CATEGORY', payload: selectedSubCategory}); //this.store.dispatch({type: 'CLEAR_SUB_CATEGORY', payload: selectedSubCategory});
//this.store.dispatch({type: 'SUB_CATEGORY', payload: selectedSubCategory}); //this.store.dispatch({type: 'SUB_CATEGORY', payload: selectedSubCategory});
this.store.dispatch( this.itemAction.getItem( selectedItem.itemCode ) ); this.store.dispatch( this.itemAction.getItemSuccess(selectedItem) );
} }
fetchStore( viewType: string){ fetchStore( viewType: string){
...@@ -106,25 +106,16 @@ export class EcmProductComponent implements OnInit { ...@@ -106,25 +106,16 @@ export class EcmProductComponent implements OnInit {
} }
} }
addToCart(items) { addToCart(item) {
let cartData = new Item; let cartData = new Item;
cartData.itemCode = items.itemCode; cartData.itemCode = item.itemCode;
cartData.itemQuantity = 1; 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.store.dispatch(this.cartAction.addToCartSuccess(item));
this.productDetailService.addToCart(cartData); this.productDetailService.addToCart(cartData);
//Check Store data //Check Store data
this.store.select('cart').forEach( this.store.select('cartItems').forEach(
value => { value => {
console.log('Cart Items----'); console.log('Cart Items----');
console.log(value); console.log(value);
......
...@@ -5,7 +5,7 @@ import 'rxjs/add/operator/catch'; ...@@ -5,7 +5,7 @@ import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { Item } from '../../ecm-model/product-model'; import { ItemDetail } from '../../ecm-model/product-detail-model';
@Injectable() @Injectable()
export class EcmProductService { export class EcmProductService {
...@@ -14,21 +14,70 @@ export class EcmProductService { ...@@ -14,21 +14,70 @@ export class EcmProductService {
constructor (private http: Http,) {} constructor (private http: Http,) {}
getItems (scatCode : string): Observable<Item[]> { getItems (scatCode : string): Observable<ItemDetail[]> {
let itemsUrl = this.SERVICE_URL + scatCode ; let itemsUrl = this.SERVICE_URL + scatCode ;
let headers = new Headers({ 'Content-Type': 'application/json' }); let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers }); let options = new RequestOptions({ headers: headers });
return this.http.get(itemsUrl, options) return this.http.get(itemsUrl, options)
.map(this.extractData) .map( (res) => this.extractData(res) )
.catch(this.handleError); .catch(this.handleError);
} }
private extractData(res: Response) { private extractData(res: Response) {
let body = res.json(); let respJson = res.json();
console.log('extractData[' + JSON.stringify(body) + ']'); console.log('extracData',respJson);
return body || { }; 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) { private handleError (error: Response | any) {
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<span *ngIf="category" class="ecm-section-info-subhead">{{category?.descr}}</span> <span *ngIf="category" class="ecm-section-info-subhead">{{category?.descr}}</span>
</div> </div>
<div class="small-12 medium-6 large-4 column end " *ngFor="let _subcategory of subcategories | async"> <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> <ecm-card (storeData)="storeSubCategory(_subcategory)" [subcategory]="_subcategory"></ecm-card>
</div> </div>
</div> </div>
</section> </section>
......
...@@ -79,7 +79,7 @@ export class EcmSubCategoryComponent implements OnInit { ...@@ -79,7 +79,7 @@ export class EcmSubCategoryComponent implements OnInit {
*/ */
} }
storeCategory( selectedSubCategory ) { storeSubCategory( selectedSubCategory ) {
//this.store.dispatch({type: 'CLEAR_SUB_CATEGORY', payload: selectedSubCategory}); //this.store.dispatch({type: 'CLEAR_SUB_CATEGORY', payload: selectedSubCategory});
//this.store.dispatch({type: 'SUB_CATEGORY', payload: selectedSubCategory}); //this.store.dispatch({type: 'SUB_CATEGORY', payload: selectedSubCategory});
......
...@@ -12,7 +12,7 @@ export class EcmSubCategoryService { ...@@ -12,7 +12,7 @@ export class EcmSubCategoryService {
private SERVICE_URL = '/ecm/service/category'; // URL to web service private SERVICE_URL = '/ecm/service/category'; // URL to web service
constructor (private http: Http,) {} constructor (private http: Http) {}
getSubCategories( catCode: string ): Observable<SubCategory[]> { getSubCategories( catCode: string ): Observable<SubCategory[]> {
......
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