-
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.
feat: extend order list filter by buyer selection (#1697)
* requires ICM 12.1.0 with new permission APP_B2B_MANAGE_ORDERS
- Loading branch information
Showing
28 changed files
with
340 additions
and
71 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
12 changes: 12 additions & 0 deletions
12
...cts/organization-management/src/app/components/buyers-select/buyers-select.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,12 @@ | ||
<ng-container *ngIf="buyers$ | async as buyers"> | ||
<select [formControl]="control" class="form-control" data-testing-id="buyers-select-box"> | ||
<option value="all"> | ||
{{ 'account.order_history.filter.all_buyers' | translate }} | ||
</option> | ||
<ng-container *ngIf="buyers.length"> | ||
<ng-container *ngFor="let buyer of buyers"> | ||
<option [value]="buyer.businessPartnerNo">{{ buyer.firstName }} {{ buyer.lastName }}</option> | ||
</ng-container> | ||
</ng-container> | ||
</select> | ||
</ng-container> |
46 changes: 46 additions & 0 deletions
46
.../organization-management/src/app/components/buyers-select/buyers-select.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,46 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { FormControl, ReactiveFormsModule } from '@angular/forms'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { of } from 'rxjs'; | ||
import { instance, mock, when } from 'ts-mockito'; | ||
|
||
import { OrganizationManagementFacade } from '../../facades/organization-management.facade'; | ||
|
||
import { BuyersSelectComponent } from './buyers-select.component'; | ||
|
||
describe('Buyers Select Component', () => { | ||
let component: BuyersSelectComponent; | ||
let fixture: ComponentFixture<BuyersSelectComponent>; | ||
let element: HTMLElement; | ||
|
||
beforeEach(async () => { | ||
const organizationManagementFacade = mock(OrganizationManagementFacade); | ||
|
||
when(organizationManagementFacade.users$).thenReturn(of([])); | ||
await TestBed.configureTestingModule({ | ||
imports: [ReactiveFormsModule, TranslateModule.forRoot()], | ||
declarations: [BuyersSelectComponent], | ||
providers: [{ provide: OrganizationManagementFacade, useFactory: () => instance(organizationManagementFacade) }], | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(BuyersSelectComponent); | ||
component = fixture.componentInstance; | ||
element = fixture.nativeElement; | ||
|
||
component.control = new FormControl('test'); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
expect(element).toBeTruthy(); | ||
expect(() => fixture.detectChanges()).not.toThrow(); | ||
}); | ||
|
||
it('should display the buyers select box after creation', () => { | ||
fixture.detectChanges(); | ||
|
||
expect(element.querySelector('[data-testing-id=buyers-select-box]')).toBeTruthy(); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
projects/organization-management/src/app/components/buyers-select/buyers-select.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,24 @@ | ||
import { ChangeDetectionStrategy, Component, Input, OnInit, inject } from '@angular/core'; | ||
import { FormControl } from '@angular/forms'; | ||
|
||
import { GenerateLazyComponent } from 'ish-core/utils/module-loader/generate-lazy-component.decorator'; | ||
|
||
import { OrganizationManagementFacade } from '../../facades/organization-management.facade'; | ||
|
||
@Component({ | ||
selector: 'ish-buyers-select', | ||
templateUrl: './buyers-select.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
@GenerateLazyComponent() | ||
export class BuyersSelectComponent implements OnInit { | ||
@Input() control: FormControl; | ||
|
||
private organizationManagementFacade = inject(OrganizationManagementFacade); | ||
|
||
buyers$ = this.organizationManagementFacade.users$; | ||
|
||
ngOnInit() { | ||
this.organizationManagementFacade.fetchUsers(); | ||
} | ||
} |
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
5 changes: 3 additions & 2 deletions
5
projects/organization-management/src/app/exports/organization-management-exports.module.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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { LazyBudgetWidgetComponent } from './lazy-budget-widget/lazy-budget-widget.component'; | ||
import { LazyBuyersSelectComponent } from './lazy-buyers-select/lazy-buyers-select.component'; | ||
import { LazyCostCenterWidgetComponent } from './lazy-cost-center-widget/lazy-cost-center-widget.component'; | ||
|
||
@NgModule({ | ||
imports: [], | ||
declarations: [LazyBudgetWidgetComponent, LazyCostCenterWidgetComponent], | ||
exports: [LazyBudgetWidgetComponent, LazyCostCenterWidgetComponent], | ||
declarations: [LazyBudgetWidgetComponent, LazyBuyersSelectComponent, LazyCostCenterWidgetComponent], | ||
exports: [LazyBudgetWidgetComponent, LazyBuyersSelectComponent, LazyCostCenterWidgetComponent], | ||
}) | ||
export class OrganizationManagementExportsModule {} |
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
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.