Loading src/app/p_product/marketplace/preview-market-place-item/preview-market-place-item.component.ts +29 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ import { ProductSpecificationService } from 'src/app/openApis/productCatalogMana import { fadeIn } from 'src/app/shared/animations/animations'; import { AuthService } from 'src/app/shared/services/auth.service'; import { ThemingService } from 'src/app/theming/theming.service'; import { ProductRequesterService } from '../../orderCheckout/services/product-requester.service'; import { ToastrService } from 'ngx-toastr'; @Component({ selector: 'app-preview-market-place-item', Loading @@ -24,7 +26,9 @@ export class PreviewMarketPlaceItemComponent implements OnInit { private dialogRef: MatDialogRef<PreviewMarketPlaceItemComponent>, private specService: ProductSpecificationService, private themingService: ThemingService, public authService: AuthService public authService: AuthService, private productRequesterService: ProductRequesterService, private toastr: ToastrService ) { } productOffering: ProductOffering Loading Loading @@ -72,7 +76,30 @@ export class PreviewMarketPlaceItemComponent implements OnInit { ) } placeInOrderList() {} placeInOrderList() { if (!this.productRequesterService.orderedProductSpecsList.some(el => el.id === this.productOffering.id)) { // this.requesterService.serviceSpecsCart.push(this.spec) this.productRequesterService.orderedProductSpecsList.push(this.productOffering) this.saveOrderToLocalStorage(this.productOffering.id) // this.requesterService.serviceConfigurationList.push({ // spec: this.spec, // checked: false, // specCharacteristics: this.initCharacteristicsValue() // }) this.dialogRef.close("added_to_order_list") } else { this.toastr.warning("This Product is already in your Product Order List") } } saveOrderToLocalStorage(specId) { let orderArray = [] orderArray = JSON.parse(localStorage.getItem('orderedProductSpecsList')) || [] orderArray.push(specId) localStorage.setItem('orderedProductSpecsList', JSON.stringify(orderArray)) } closeDialog() { this.dialogRef.close() Loading src/app/p_product/orderCheckout/services/product-requester.service.ts +23 −23 Original line number Diff line number Diff line Loading @@ -8,31 +8,31 @@ import { ProductOfferingService } from 'src/app/openApis/productCatalogManagemen }) export class ProductRequesterService { // orderedProductSpecsList: ProductOffering[] = [] orderedProductSpecsList: ProductOffering[] = [] // orderListUpdated$ = new Subject<boolean>() orderListUpdated$ = new Subject<boolean>() // constructor( // private specService: ProductOfferingService // ) { // const orderList: string[] = JSON.parse(localStorage.getItem('orderedSpecsList')) // if (orderList && (this.orderedProductSpecsList.length === 0 || orderList.length !== this.orderedProductSpecsList.length)) { // orderList.forEach(specId => { // if (!this.orderedProductSpecsList.some(el => el.id === specId)) { // this.specService.retrieveProductOffering({id: specId}).subscribe( // data => { // this.orderedProductSpecsList.push(data) // this.orderListUpdated$.next(true) // }, // error => { // this.orderedProductSpecsList = [] // localStorage.removeItem('orderedProductSpecsList') // } // ) // } // }); // } // } constructor( private specService: ProductOfferingService ) { const orderList: string[] = JSON.parse(localStorage.getItem('orderedProductSpecsList')) if (orderList && (this.orderedProductSpecsList.length === 0 || orderList.length !== this.orderedProductSpecsList.length)) { orderList.forEach(specId => { if (!this.orderedProductSpecsList.some(el => el.id === specId)) { this.specService.retrieveProductOffering({id: specId}).subscribe( data => { this.orderedProductSpecsList.push(data) this.orderListUpdated$.next(true) }, error => { this.orderedProductSpecsList = [] localStorage.removeItem('orderedProductSpecsList') } ) } }); } } } export interface productSpecConfigurationListItem { Loading src/app/shared/navbar/navbar.component.html +2 −2 Original line number Diff line number Diff line Loading @@ -271,9 +271,9 @@ <li class="nav-item" [@fadeIn] *ngIf="appService.portalDomain === 'products'"> <a class="nav-link d-flex align-items-center" routerLink="/{{appService.portalDomain}}/product_order_checkout"> <span class="badge badge-danger mr-1"> {{requesterService.orderedSpecsList.length}} </span> <span class="badge badge-danger mr-1"> {{productRequesterService.orderedProductSpecsList.length}} </span> <i class="fas fa-shopping-cart mr-1"></i> <span> Order List </span> <span> Product Order List </span> </a> </li> Loading src/app/shared/navbar/navbar.component.ts +2 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import { MatDialog } from '@angular/material/dialog'; import { ToastrService } from 'ngx-toastr'; import { AuthService } from 'src/app/shared/services/auth.service'; import { RequesterService } from 'src/app/p_services/orderCheckout/services/requester.service'; import { ProductRequesterService } from 'src/app/p_product/orderCheckout/services/product-requester.service'; import { trigger } from '@angular/animations'; import { fadeIn } from 'src/app/shared/animations/animations'; import { ThemingService } from 'src/app/theming/theming.service'; Loading @@ -26,6 +27,7 @@ export class NavbarComponent implements OnInit { private toast: ToastrService, public authService: AuthService, public requesterService: RequesterService, public productRequesterService: ProductRequesterService, private themingService: ThemingService, public appService: AppService ) { } Loading Loading
src/app/p_product/marketplace/preview-market-place-item/preview-market-place-item.component.ts +29 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ import { ProductSpecificationService } from 'src/app/openApis/productCatalogMana import { fadeIn } from 'src/app/shared/animations/animations'; import { AuthService } from 'src/app/shared/services/auth.service'; import { ThemingService } from 'src/app/theming/theming.service'; import { ProductRequesterService } from '../../orderCheckout/services/product-requester.service'; import { ToastrService } from 'ngx-toastr'; @Component({ selector: 'app-preview-market-place-item', Loading @@ -24,7 +26,9 @@ export class PreviewMarketPlaceItemComponent implements OnInit { private dialogRef: MatDialogRef<PreviewMarketPlaceItemComponent>, private specService: ProductSpecificationService, private themingService: ThemingService, public authService: AuthService public authService: AuthService, private productRequesterService: ProductRequesterService, private toastr: ToastrService ) { } productOffering: ProductOffering Loading Loading @@ -72,7 +76,30 @@ export class PreviewMarketPlaceItemComponent implements OnInit { ) } placeInOrderList() {} placeInOrderList() { if (!this.productRequesterService.orderedProductSpecsList.some(el => el.id === this.productOffering.id)) { // this.requesterService.serviceSpecsCart.push(this.spec) this.productRequesterService.orderedProductSpecsList.push(this.productOffering) this.saveOrderToLocalStorage(this.productOffering.id) // this.requesterService.serviceConfigurationList.push({ // spec: this.spec, // checked: false, // specCharacteristics: this.initCharacteristicsValue() // }) this.dialogRef.close("added_to_order_list") } else { this.toastr.warning("This Product is already in your Product Order List") } } saveOrderToLocalStorage(specId) { let orderArray = [] orderArray = JSON.parse(localStorage.getItem('orderedProductSpecsList')) || [] orderArray.push(specId) localStorage.setItem('orderedProductSpecsList', JSON.stringify(orderArray)) } closeDialog() { this.dialogRef.close() Loading
src/app/p_product/orderCheckout/services/product-requester.service.ts +23 −23 Original line number Diff line number Diff line Loading @@ -8,31 +8,31 @@ import { ProductOfferingService } from 'src/app/openApis/productCatalogManagemen }) export class ProductRequesterService { // orderedProductSpecsList: ProductOffering[] = [] orderedProductSpecsList: ProductOffering[] = [] // orderListUpdated$ = new Subject<boolean>() orderListUpdated$ = new Subject<boolean>() // constructor( // private specService: ProductOfferingService // ) { // const orderList: string[] = JSON.parse(localStorage.getItem('orderedSpecsList')) // if (orderList && (this.orderedProductSpecsList.length === 0 || orderList.length !== this.orderedProductSpecsList.length)) { // orderList.forEach(specId => { // if (!this.orderedProductSpecsList.some(el => el.id === specId)) { // this.specService.retrieveProductOffering({id: specId}).subscribe( // data => { // this.orderedProductSpecsList.push(data) // this.orderListUpdated$.next(true) // }, // error => { // this.orderedProductSpecsList = [] // localStorage.removeItem('orderedProductSpecsList') // } // ) // } // }); // } // } constructor( private specService: ProductOfferingService ) { const orderList: string[] = JSON.parse(localStorage.getItem('orderedProductSpecsList')) if (orderList && (this.orderedProductSpecsList.length === 0 || orderList.length !== this.orderedProductSpecsList.length)) { orderList.forEach(specId => { if (!this.orderedProductSpecsList.some(el => el.id === specId)) { this.specService.retrieveProductOffering({id: specId}).subscribe( data => { this.orderedProductSpecsList.push(data) this.orderListUpdated$.next(true) }, error => { this.orderedProductSpecsList = [] localStorage.removeItem('orderedProductSpecsList') } ) } }); } } } export interface productSpecConfigurationListItem { Loading
src/app/shared/navbar/navbar.component.html +2 −2 Original line number Diff line number Diff line Loading @@ -271,9 +271,9 @@ <li class="nav-item" [@fadeIn] *ngIf="appService.portalDomain === 'products'"> <a class="nav-link d-flex align-items-center" routerLink="/{{appService.portalDomain}}/product_order_checkout"> <span class="badge badge-danger mr-1"> {{requesterService.orderedSpecsList.length}} </span> <span class="badge badge-danger mr-1"> {{productRequesterService.orderedProductSpecsList.length}} </span> <i class="fas fa-shopping-cart mr-1"></i> <span> Order List </span> <span> Product Order List </span> </a> </li> Loading
src/app/shared/navbar/navbar.component.ts +2 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import { MatDialog } from '@angular/material/dialog'; import { ToastrService } from 'ngx-toastr'; import { AuthService } from 'src/app/shared/services/auth.service'; import { RequesterService } from 'src/app/p_services/orderCheckout/services/requester.service'; import { ProductRequesterService } from 'src/app/p_product/orderCheckout/services/product-requester.service'; import { trigger } from '@angular/animations'; import { fadeIn } from 'src/app/shared/animations/animations'; import { ThemingService } from 'src/app/theming/theming.service'; Loading @@ -26,6 +27,7 @@ export class NavbarComponent implements OnInit { private toast: ToastrService, public authService: AuthService, public requesterService: RequesterService, public productRequesterService: ProductRequesterService, private themingService: ThemingService, public appService: AppService ) { } Loading