Commit 6009b472 authored by prumde's avatar prumde

Updated


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@174443 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0f74d22d
......@@ -77,7 +77,7 @@ export class EcmProductDetailService {
addToWishlist(itemCode) {
console.log( "StoreInWishList Called" );
console.log(JSON.stringify(itemCode));
let headers = new Headers( { 'Content-Type': 'application/json' });
let options = new RequestOptions( { headers: headers });
......
......@@ -3,12 +3,12 @@
<ecm-breadcrumbs *ngIf="itemDetail" [pageName]="'DETAIL'" [itemDetail]='itemDetail'></ecm-breadcrumbs>
<div class="row">
<ecm-template *ngIf="ecmTemplate" [itemDetail] = "itemDetail" [ecmTemplate] = "ecmTemplate" (scrollToReviews)="scrollToReviews();" (showSignInPanel) = "showSignInPanel();" (doActivity) = "doActivity($event);">
<ecm-template *ngIf="ecmTemplate" [itemDetail] = "itemDetail" [ecmTemplate] = "ecmTemplate" (scrollToReviews)="scrollToReviews();" (doActivity) = "doActivity($event);">
</ecm-template>
</div>
<div class="row" *ngIf="noOfReviews != 0" #reviewsAndRating>
<ecm-product-review [itemDetail] = "itemDetail" (showSignInPanel) = "showSignInPanel();"></ecm-product-review>
<ecm-product-review [itemDetail] = "itemDetail" (doActivity) = "doActivity($event);"></ecm-product-review>
</div>
<ecm-related-items *ngIf="itemDetail" [scatCode]="scatCode"> </ecm-related-items>
......
......@@ -8,6 +8,7 @@ import { UPDATE_QUANTITY, ADD_TO_CART, REMOVE } from '../ecm-store/ecm-store';
import { EcmProductDetailService } from './ecm-product-detail.service';
import { ScrollService } from '../scroll.service';
import { EcmProductReviewService } from './ecm-product-review.service';
import { ItemDetail } from '../ecm-model/product-detail-model';
import { EcmTemplateItem,EcmTemplateComponent } from './ecm-template/ecm-template.component';
......@@ -20,6 +21,9 @@ import { EcmRelatedItemsComponent } from '../ecm-view/ecm-related-items/ecm-rela
import { ECMCart } from '../ecm-model/cart-model';
import { Item } from '../ecm-model/product-model';
import { ECMHeaderComponent } from '../ecm-header/ecm-header.component';
import { Reviews } from '../ecm-model/product-review.model';
import {MdDialog, MdDialogRef, MdDialogConfig, MD_DIALOG_DATA} from '@angular/material';
import { ECMWriteReviewDialog } from './ecm-product-review.component';
export const ECM_TEMPLATES: any = {
'ecm-outing' : new EcmTemplateItem(EcmOutingComponent),
......@@ -44,8 +48,9 @@ export class EcmProductDetailsComponent implements OnInit {
itemDetail: ItemDetail;
scatCode;
noOfReviews;
userReview: Reviews;
constructor(private route: ActivatedRoute, private router:Router, public productDetailService: EcmProductDetailService, public snackBar: MdSnackBar, private store: Store<EcmStoreModel>) { }
constructor(private route: ActivatedRoute, private router:Router, public productDetailService: EcmProductDetailService, public snackBar: MdSnackBar, private store: Store<EcmStoreModel>, private productreviewService: EcmProductReviewService, public dialog: MdDialog) { }
ngOnInit() {
this.route.params.subscribe( params => {
......@@ -111,9 +116,15 @@ export class EcmProductDetailsComponent implements OnInit {
}
}
else if( activity == 'ADD_WISHLIST' ) {
this.addToWishlist(data);
this.router.navigate(['/wishList']);
this.showSnackbar('Item Added to your Wishlist');
if(this.checkUser() !== 'undefined' && this.checkUser() !== null && this.checkUser() !== 'null')
{
this.addToWishlist(data.itemCode);
this.showSnackbar('Item Added to your Wishlist');
}
else
{
this.showSignInPanel();
}
}
else if( activity == 'BOOK_NOW' ) {
this.showSnackbar('Book Now - Redirect to Checkout');
......@@ -123,10 +134,35 @@ export class EcmProductDetailsComponent implements OnInit {
this.addToCart(data.itemCode);
this.showSnackbar('Item Added to your Cart');
}
//Redirect to Checkout
//this.showSnackbar('Buy Now - Redirect to Checkout');
this.router.navigate(['/checkout']);
}
else if( activity == 'WRITE_REVIEW') {
if(this.checkUser() !== 'undefined' && this.checkUser() !== null && this.checkUser() !== 'null')
{
if(data.firstReview)
{
let dialogRef = this.dialog.open( ECMWriteReviewDialog, {
data: {
detail: this.itemDetail,
userId: JSON.parse(this.checkUser()).LOGIN_CODE
}
});
}
else
{
this.productreviewService.getUserReview(this.itemDetail.itemCode).subscribe(
userReview => {
this.userReview = userReview;
if(this.userReview)
this.openReviewDialog(this.checkUser());
});
}
}
else
{
this.showSignInPanel();
}
}
}
addToCart(data:any) {
......@@ -150,9 +186,9 @@ export class EcmProductDetailsComponent implements OnInit {
);
}
addToWishlist(data:any) {
addToWishlist(itemCode) {
// this.store.dispatch({ type: INCREMENT, payload: cartData });
this.productDetailService.addToWishlist(data);
this.productDetailService.addToWishlist(itemCode);
}
showSnackbar(message) {
......@@ -177,5 +213,28 @@ export class EcmProductDetailsComponent implements OnInit {
console.log('showSignin');
this.header.userAction();
}
checkUser(){
var userInfo = localStorage.getItem( 'userInfo' );
if ( userInfo !== 'undefined' && userInfo !== null && userInfo !== 'null' )
{
return userInfo;
}
else
{
return userInfo;
}
}
openReviewDialog(userInfo){
console.log("Complete Fecth Review");
let dialogRef = this.dialog.open( ECMWriteReviewDialog, {
data: {
detail: this.itemDetail,
userReview: this.userReview,
userId: JSON.parse(userInfo).LOGIN_CODE
}
});
}
}
......@@ -20,7 +20,7 @@
<rating [ratingDetail]="itemDetail.itemRatings" (filterBy)="filter($event);"></rating>
</div>
<div class="large-3 columns ecm-write-review">
<button md-button class="write-review-button" (click)="checkUser();">
<button md-button class="write-review-button" (click)="doActivity.emit({activity:'WRITE_REVIEW', data: {} });">
<i class="material-icons edit">&#xE254;</i>
<span md-button class="write-review-text"> Write a Review </span>
</button>
......
......@@ -13,7 +13,7 @@ import { FormBuilder, Validators,NgForm } from '@angular/forms';
export class EcmProductReviewComponent implements OnChanges {
@Input() itemDetail: ItemDetail;
@Output() showSignInPanel = new EventEmitter();
@Output() doActivity = new EventEmitter();
solrUrl = '/ecm/service/solr/local2do/';
reviews: Reviews[];
tabSort: string = "reviewDate desc";
......@@ -150,34 +150,6 @@ export class EcmProductReviewComponent implements OnChanges {
this.fetchReviews();
}
checkUser() {
var userInfo = localStorage.getItem( 'userInfo' );
if ( userInfo !== 'undefined' && userInfo !== null && userInfo !== 'null' )
{
this.productreviewService.getUserReview(this.itemDetail.itemCode).subscribe(
userReview => {
this.userReview = userReview;
if(this.userReview)
this.openReviewDialog(userInfo);
});
}
else
{
this.showSignInPanel.emit();
}
}
openReviewDialog(userInfo){
console.log("Complete Fecth Review");
let dialogRef = this.dialog.open( ECMWriteReviewDialog, {
data: {
detail: this.itemDetail,
userReview: this.userReview,
userId: JSON.parse(userInfo).LOGIN_CODE
}
});
}
}
@Component( {
......
......@@ -15,7 +15,6 @@ export class EcmCelebrationComponent implements OnInit, EcmTemplateInterface {
@Input() itemDetail: ItemDetail;
@Output() scrollToReviews = new EventEmitter();
@Output() doActivity = new EventEmitter();
@Output() showSignInPanel = new EventEmitter();
@ViewChild( 'recentView' ) recentView: EcmRecentViewComponent;
userActionUrl = '/ecm/service/feeds/cart';
......
......@@ -18,7 +18,6 @@ export class EcmFoodComponent implements OnInit, EcmTemplateInterface {
@Input() itemDetail: ItemDetail;
@Output() scrollToReviews = new EventEmitter();
@Output() doActivity = new EventEmitter();
@Output() showSignInPanel = new EventEmitter();
@ViewChild( 'recentView' ) recentView: EcmRecentViewComponent;
userActionUrl = '/ecm/service/feeds/cart';
......
......@@ -5,9 +5,9 @@
<!-- ------------------------HANDICRAFT-IMAGE START HERE-------------------------------- -->
<div class="small-12 medium-6 large-6 columns image">
<div>
<md-button-toggle class="wishButton" #wish>
<md-icon style="color: mediumvioletred;" *ngIf="!wish.checked" (click)="checkWishlistUser();">favorite_border</md-icon>
<md-icon style="color: mediumvioletred;" *ngIf="wish.checked">favorite</md-icon>
<md-button-toggle class="wishButton">
<md-icon style="color: mediumvioletred;" *ngIf="!inWishlist" (click)="addToWishlist();">favorite_border</md-icon>
<md-icon style="color: mediumvioletred;" *ngIf="inWishlist">favorite</md-icon>
</md-button-toggle>
</div>
<div class="md-card-image">
......@@ -35,7 +35,7 @@
<span class="seller-name">{{itemDetail.itemDetail1.sellerInfo.name}}</span><br>
<a class="link-reviews">
<span *ngIf="itemDetail.itemRatings.AVG_RATING == 0 && itemDetail.itemRatings.NO_OF_REVIEWS == 0 " class="review-msg-title" (click)="checkUser();">
<span *ngIf="itemDetail.itemRatings.AVG_RATING == 0 && itemDetail.itemRatings.NO_OF_REVIEWS == 0 " class="review-msg-title" (click)="doActivity.emit({activity:'WRITE_REVIEW', data: {'firstReview': true} });">
Be the first to Review this product
</span>
......@@ -43,7 +43,7 @@
<rating [rate]="itemDetail.itemRatings.AVG_RATING"></rating>
<span class="ecm-itemAvgRating">{{itemDetail.itemRatings.AVG_RATING}} Ratings</span>
<span *ngIf="itemDetail.itemRatings.NO_OF_REVIEWS != 0" class="ecm-itemNumOfReviews">{{itemDetail.itemRatings.NO_OF_REVIEWS}} Reviews</span>
<span *ngIf="itemDetail.itemRatings.NO_OF_REVIEWS == 0" class="ecm-itemNumOfReviews" (click)="checkUser();">Be the first to Review this product</span>
<span *ngIf="itemDetail.itemRatings.NO_OF_REVIEWS == 0" class="ecm-itemNumOfReviews" (click)="doActivity.emit({activity:'WRITE_REVIEW', data: {'firstReview': true} });">Be the first to Review this product</span>
</span>
</a>
......
......@@ -21,12 +21,12 @@ export class EcmHandicraftComponent implements OnInit, EcmTemplateInterface {
@Input() itemDetail: ItemDetail;
@Output() scrollToReviews = new EventEmitter();
@Output() doActivity = new EventEmitter();
@Output() showSignInPanel = new EventEmitter();
@ViewChild( 'recentView' ) recentView: EcmRecentViewComponent;
@ViewChild('itemDetails') itemDetails: ElementRef;
@Input() isAddToCart: boolean = false;
clientWidth: any;
itemCode;
inWishlist;
//isCartItem = false;
//@Input() itemData: Item;
......@@ -56,6 +56,15 @@ export class EcmHandicraftComponent implements OnInit, EcmTemplateInterface {
{
this.isAddToCart = false;
}
if(this.itemDetail.productStatus.inWishlist == "Y")
{
this.inWishlist = true;
}
else if(this.itemDetail.productStatus.inWishlist == "N")
{
this.inWishlist = false;
}
}
ngAfterViewInit() {
......@@ -85,39 +94,8 @@ export class EcmHandicraftComponent implements OnInit, EcmTemplateInterface {
window.scrollTo(0, offsetTop + 60);
}
checkWishlistUser() {
var userInfo = localStorage.getItem( 'userInfo' );
if ( userInfo !== 'undefined' && userInfo !== null && userInfo !== 'null' )
{
this.doActivity.emit({activity:'ADD_WISHLIST', data: this.itemDetail.itemCode });
console.log("ITEM ADDED TO WISHLIST OF CART ITEMS "+this.itemDetail.itemCode );
}
else
{
console.log("checkUser-else");
this.showSignInPanel.emit();
}
addToWishlist() {
this.inWishlist = true;
this.doActivity.emit({activity:'ADD_WISHLIST', data: {'itemCode' : this.itemDetail.itemCode} });
}
checkUser() {
var userInfo = localStorage.getItem( 'userInfo' );
if ( userInfo !== 'undefined' && userInfo !== null && userInfo !== 'null' )
{
let dialogRef = this.dialog.open( ECMWriteReviewDialog, {
data: {
detail: this.itemDetail,
userId: JSON.parse(userInfo).LOGIN_CODE
}
});
}
else
{
console.log("checkUser-else");
this.showSignInPanel.emit();
}
}
}
}
\ No newline at end of file
......@@ -19,7 +19,6 @@ export class EcmOutingComponent implements OnInit, EcmTemplateInterface {
@Input() itemDetail: ItemDetail;
@Output() scrollToReviews = new EventEmitter();
@Output() doActivity = new EventEmitter();
@Output() showSignInPanel = new EventEmitter();
@ViewChild( 'recentView' ) recentView: EcmRecentViewComponent;
counterValue = 1;
......
......@@ -22,7 +22,6 @@ export interface EcmTemplateInterface {
itemDetail: ItemDetail;
scrollToReviews: any;
doActivity: any;
showSignInPanel: any;
}
@Component({
......@@ -34,7 +33,6 @@ export class EcmTemplateComponent implements OnChanges {
@Output() scrollToReviews = new EventEmitter();
@Output() doActivity = new EventEmitter();
@Output() showSignInPanel = new EventEmitter();
@Input('ecmTemplate') ecmTemplate: EcmTemplateItem;
@Input('itemDetail') itemDetail:ItemDetail;
......@@ -59,7 +57,6 @@ export class EcmTemplateComponent implements OnChanges {
(<EcmTemplateInterface>componentRef.instance).itemDetail = ecmTemplateItem.itemDetail;
(<EcmTemplateInterface>componentRef.instance).scrollToReviews = this.scrollToReviews;
(<EcmTemplateInterface>componentRef.instance).doActivity = this.doActivity;
(<EcmTemplateInterface>componentRef.instance).showSignInPanel = this.showSignInPanel;
}
ngOnChanges(){
......
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