-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove quote items from cart (#1029)
Co-authored-by: Luis Garcia <luis.miguel.garcia@evident.nl> Co-authored-by: Danilo Hoffmann <dhhyi@aol.com>
- Loading branch information
Showing
15 changed files
with
215 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...ensions/quoting/shared/quoting-basket-line-items/quoting-basket-line-items.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<ng-container *ngFor="let item of lineItems$ | async"> | ||
<div class="row" *ngIf="item[0] !== 'undefined'"> | ||
<div class="col-12 col-sm-10 my-auto"> | ||
<h2>{{ 'quote.basket_items.label' | translate: { quoteId: getName(item[0]) | async } }}</h2> | ||
</div> | ||
<div class="col-12 col-sm-2 my-auto text-right"> | ||
<a | ||
class="btn-tool" | ||
title="{{ 'shopping_cart.remove.item.button.label' | translate }}" | ||
(click)="onDeleteQuote(item[0])" | ||
> | ||
<fa-icon [icon]="['fas', 'trash-alt']"></fa-icon> | ||
</a> | ||
</div> | ||
</div> | ||
<ish-line-item-list [lineItems]="item[1]"></ish-line-item-list> | ||
</ng-container> |
43 changes: 43 additions & 0 deletions
43
...ions/quoting/shared/quoting-basket-line-items/quoting-basket-line-items.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { EMPTY } from 'rxjs'; | ||
import { instance, mock, when } from 'ts-mockito'; | ||
|
||
import { CheckoutFacade } from 'ish-core/facades/checkout.facade'; | ||
|
||
import { QuotingFacade } from '../../facades/quoting.facade'; | ||
|
||
import { QuotingBasketLineItemsComponent } from './quoting-basket-line-items.component'; | ||
|
||
describe('QuotingBasketLineItemsComponent', () => { | ||
let component: QuotingBasketLineItemsComponent; | ||
let fixture: ComponentFixture<QuotingBasketLineItemsComponent>; | ||
let element: HTMLElement; | ||
|
||
let checkoutFacade: CheckoutFacade; | ||
let quotingFacade: QuotingFacade; | ||
|
||
beforeEach(async () => { | ||
checkoutFacade = mock(CheckoutFacade); | ||
quotingFacade = mock(QuotingFacade); | ||
when(checkoutFacade.basket$).thenReturn(EMPTY); | ||
await TestBed.configureTestingModule({ | ||
declarations: [QuotingBasketLineItemsComponent], | ||
providers: [ | ||
{ provide: CheckoutFacade, useFactory: () => instance(checkoutFacade) }, | ||
{ provide: QuotingFacade, useFactory: () => instance(quotingFacade) }, | ||
], | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(QuotingBasketLineItemsComponent); | ||
component = fixture.componentInstance; | ||
element = fixture.nativeElement; | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
expect(element).toBeTruthy(); | ||
expect(() => fixture.detectChanges()).not.toThrow(); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
...xtensions/quoting/shared/quoting-basket-line-items/quoting-basket-line-items.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; | ||
import { groupBy } from 'lodash-es'; | ||
import { Observable, map } from 'rxjs'; | ||
|
||
import { CheckoutFacade } from 'ish-core/facades/checkout.facade'; | ||
import { LineItem } from 'ish-core/models/line-item/line-item.model'; | ||
import { GenerateLazyComponent } from 'ish-core/utils/module-loader/generate-lazy-component.decorator'; | ||
|
||
import { QuotingFacade } from '../../facades/quoting.facade'; | ||
|
||
@Component({ | ||
selector: 'ish-quoting-basket-line-items', | ||
templateUrl: './quoting-basket-line-items.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
@GenerateLazyComponent() | ||
export class QuotingBasketLineItemsComponent implements OnInit { | ||
lineItems$: Observable<[string, LineItem[]][]>; | ||
|
||
constructor(private checkoutFacade: CheckoutFacade, private quotingFacade: QuotingFacade) {} | ||
|
||
ngOnInit() { | ||
this.quotingFacade.loadQuoting(); | ||
this.lineItems$ = this.checkoutFacade.basket$.pipe( | ||
map(basket => Object.entries(groupBy(basket.lineItems, 'quote')).sort((a, _) => (a[0] === 'undefined' ? -1 : 0))) | ||
); | ||
} | ||
|
||
getName(quoteId: string) { | ||
return this.quotingFacade.name$(quoteId); | ||
} | ||
|
||
onDeleteQuote(quoteId: string) { | ||
this.quotingFacade.deleteQuoteFromBasket(quoteId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.