-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
421 additions
and
185 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
10 changes: 5 additions & 5 deletions
10
src/app/shared/components/custom-fields/custom-fields-view/custom-fields-view.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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<div class="custom-fields-view"> | ||
<div *ngFor="let field of data$ | async"> | ||
<label [for]="'basket-custom-attribute-' + field.name">{{ field.displayName }}</label | ||
><span [class.no-value]="!field.value" [id]="'basket-custom-attribute-' + field.name">{{ | ||
field.value || ('checkout.custom-field.no-value' | translate) | ||
}}</span> | ||
<div *ngFor="let field of data$ | async" class="custom-field"> | ||
<label [for]="'basket-custom-attribute-' + field.name">{{ field.displayName }}</label> | ||
<span [class.no-value]="!field.value" [id]="'basket-custom-attribute-' + field.name"> | ||
{{ field.value || ('checkout.custom-field.no-value' | translate) }} | ||
</span> | ||
</div> | ||
</div> |
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
37 changes: 37 additions & 0 deletions
37
...pp/shared/components/line-item/line-item-edit-dialog/line-item-edit-dialog.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,37 @@ | ||
<div class="container line-item-edit-dialog"> | ||
<ish-loading *ngIf="loading$ | async" /> | ||
|
||
<div *ngIf="variation$ | async as variation" class="row"> | ||
<!-- right box --> | ||
<div class="col-12 col-md"> | ||
<div class="text-center"><ish-product-image imageType="M" /></div> | ||
</div> | ||
|
||
<!-- left box --> | ||
<div class="col-12 col-md product-info"> | ||
<!-- sku --> | ||
<ish-product-id /> | ||
|
||
<!-- price --> | ||
<div class="current-price">{{ variationSalePrice$ | async | ishPrice }}</div> | ||
|
||
<!-- Availability --> | ||
<ish-product-inventory /> | ||
|
||
<!-- select (variation) --> | ||
<div class="product-variation-container"> | ||
<ish-product-variation-select /> | ||
</div> | ||
|
||
<!-- input (quantity) --> | ||
<div class="form-group"> | ||
<div class="row"> | ||
<ish-product-quantity-label for="line-item-edit-quantity" class="col" /> | ||
<div class="col"> | ||
<ish-product-quantity elementId="line-item-edit-quantity" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
86 changes: 86 additions & 0 deletions
86
...shared/components/line-item/line-item-edit-dialog/line-item-edit-dialog.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,86 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { MockComponent, MockPipe } from 'ng-mocks'; | ||
import { EMPTY, of } from 'rxjs'; | ||
import { instance, mock, when } from 'ts-mockito'; | ||
|
||
import { ProductContextFacade } from 'ish-core/facades/product-context.facade'; | ||
import { PricePipe } from 'ish-core/models/price/price.pipe'; | ||
import { ProductView } from 'ish-core/models/product-view/product-view.model'; | ||
import { ProductCompletenessLevel } from 'ish-core/models/product/product.model'; | ||
import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils'; | ||
import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; | ||
import { ProductIdComponent } from 'ish-shared/components/product/product-id/product-id.component'; | ||
import { ProductImageComponent } from 'ish-shared/components/product/product-image/product-image.component'; | ||
import { ProductInventoryComponent } from 'ish-shared/components/product/product-inventory/product-inventory.component'; | ||
import { ProductQuantityLabelComponent } from 'ish-shared/components/product/product-quantity-label/product-quantity-label.component'; | ||
import { ProductQuantityComponent } from 'ish-shared/components/product/product-quantity/product-quantity.component'; | ||
import { ProductVariationSelectComponent } from 'ish-shared/components/product/product-variation-select/product-variation-select.component'; | ||
|
||
import { LineItemEditDialogComponent } from './line-item-edit-dialog.component'; | ||
|
||
describe('Line Item Edit Dialog Component', () => { | ||
let component: LineItemEditDialogComponent; | ||
let fixture: ComponentFixture<LineItemEditDialogComponent>; | ||
let element: HTMLElement; | ||
let context: ProductContextFacade; | ||
|
||
beforeEach(async () => { | ||
context = mock(ProductContextFacade); | ||
|
||
await TestBed.configureTestingModule({ | ||
declarations: [ | ||
LineItemEditDialogComponent, | ||
MockComponent(LoadingComponent), | ||
MockComponent(ProductIdComponent), | ||
MockComponent(ProductImageComponent), | ||
MockComponent(ProductInventoryComponent), | ||
MockComponent(ProductQuantityComponent), | ||
MockComponent(ProductQuantityLabelComponent), | ||
MockComponent(ProductVariationSelectComponent), | ||
MockPipe(PricePipe), | ||
], | ||
providers: [{ provide: ProductContextFacade, useFactory: () => instance(context) }], | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(LineItemEditDialogComponent); | ||
component = fixture.componentInstance; | ||
element = fixture.nativeElement; | ||
|
||
when(context.select('product')).thenReturn( | ||
of({ | ||
type: 'VariationProduct', | ||
sku: 'SKU', | ||
variableVariationAttributes: [], | ||
available: true, | ||
completenessLevel: ProductCompletenessLevel.List, | ||
} as ProductView) | ||
); | ||
when(context.select('prices')).thenReturn(EMPTY); | ||
|
||
when(context.select('loading')).thenReturn(of(false)); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
expect(element).toBeTruthy(); | ||
expect(() => fixture.detectChanges()).not.toThrow(); | ||
}); | ||
|
||
it('should give correct product id of variation to product id component', () => { | ||
fixture.detectChanges(); | ||
expect(element.querySelector('ish-product-id')).toMatchInlineSnapshot(`<ish-product-id></ish-product-id>`); | ||
}); | ||
|
||
it('should display ish-components on the container', () => { | ||
fixture.detectChanges(); | ||
expect(findAllCustomElements(element)).toIncludeAllMembers(['ish-product-quantity', 'ish-product-image']); | ||
}); | ||
|
||
it('should display loading-components on the container', () => { | ||
when(context.select('loading')).thenReturn(of(true)); | ||
fixture.detectChanges(); | ||
expect(findAllCustomElements(element)).toIncludeAllMembers(['ish-product-quantity', 'ish-loading']); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
src/app/shared/components/line-item/line-item-edit-dialog/line-item-edit-dialog.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,29 @@ | ||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; | ||
import { Observable, map } from 'rxjs'; | ||
|
||
import { ProductContextFacade } from 'ish-core/facades/product-context.facade'; | ||
import { Price } from 'ish-core/models/price/price.model'; | ||
import { ProductView } from 'ish-core/models/product-view/product-view.model'; | ||
|
||
/** | ||
* The Line Item Edit Dialog Component displays an edit-dialog of a line items to edit quantity and variation. | ||
*/ | ||
@Component({ | ||
selector: 'ish-line-item-edit-dialog', | ||
templateUrl: './line-item-edit-dialog.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class LineItemEditDialogComponent implements OnInit { | ||
variation$: Observable<ProductView>; | ||
variationSalePrice$: Observable<Price>; | ||
loading$: Observable<boolean>; | ||
|
||
constructor(private context: ProductContextFacade) {} | ||
|
||
ngOnInit() { | ||
this.variation$ = this.context.select('product'); | ||
this.variationSalePrice$ = this.context.select('prices').pipe(map(prices => prices?.salePrice)); | ||
|
||
this.loading$ = this.context.select('loading'); | ||
} | ||
} |
75 changes: 16 additions & 59 deletions
75
src/app/shared/components/line-item/line-item-edit/line-item-edit.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 |
---|---|---|
@@ -1,67 +1,24 @@ | ||
<ng-container *ngIf="select('visible') | async"> | ||
<ng-container *ngIf="product$ | async as product"> | ||
<button | ||
*ngIf="product.type === 'VariationProduct'" | ||
type="button" | ||
(click)="show()" | ||
class="line-item-edit-link btn btn-link btn-link-action btn-tool" | ||
class="line-item-edit-link btn btn-link btn-link-action" | ||
rel="nofollow" | ||
title="{{ 'checkout.variation.edit.button.label' | translate }}" | ||
> | ||
<fa-icon [icon]="['fas', 'pencil']" /> | ||
{{ 'checkout.variation.edit.button.label' | translate }} | ||
</button> | ||
</ng-container> | ||
|
||
<ish-modal-dialog | ||
#modalDialog | ||
[options]="{ | ||
confirmText: 'shopping_cart.variation.save.button.label' | translate, | ||
rejectText: 'shopping_cart.button.cancel' | translate, | ||
size: 'lg' | ||
}" | ||
> | ||
<ng-container *ngIf="select('visible') | async"> | ||
<div class="container line-item-edit-dialog"> | ||
<ish-loading *ngIf="select('loading') | async" /> | ||
|
||
<div class="row"> | ||
<!-- right box --> | ||
<div class="col-12 col-md"> | ||
<div class="text-center"><ish-product-image imageType="M" /></div> | ||
</div> | ||
|
||
<!-- left box --> | ||
<div class="col-12 col-md product-info"> | ||
<!-- sku --> | ||
<ish-product-id /> | ||
|
||
<!-- price --> | ||
<div class="current-price">{{ select('lineItem', 'singleBasePrice') | async | ishPrice }}</div> | ||
|
||
<!-- Availability --> | ||
<ish-product-inventory /> | ||
|
||
<!-- select (variation) --> | ||
<div class="product-variation-container"> | ||
<ish-product-variation-select | ||
*ngIf="(select('variationEditable') | async) === true; else variationDisplay" | ||
/> | ||
<ng-template #variationDisplay> | ||
<ish-product-variation-display /> | ||
</ng-template> | ||
</div> | ||
|
||
<!-- input (quantity) --> | ||
<div class="form-group"> | ||
<div class="row"> | ||
<ish-product-quantity-label for="line-item-edit-quantity" class="col" /> | ||
<div class="col"> | ||
<ish-product-quantity elementId="line-item-edit-quantity" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<ish-custom-fields-formly [form]="customFieldsForm" [fields]="select('customFields') | async" /> | ||
</div> | ||
</ng-container> | ||
</ish-modal-dialog> | ||
<ish-modal-dialog | ||
#modalDialog | ||
[options]="{ | ||
titleText: product.name, | ||
confirmText: 'shopping_cart.variation.save.button.label' | translate, | ||
rejectText: 'shopping_cart.button.cancel' | translate, | ||
size: 'lg' | ||
}" | ||
> | ||
<ish-line-item-edit-dialog /> | ||
</ish-modal-dialog> | ||
</ng-container> |
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.