-
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: OCI punchout configuration (#1431)
- add a new page for the oci punchout configuration - configuration items, placeholders and available formatters are provided by the ICM server - the punchout administrator can navigate to the configuration page from the punchout oci tab --------- Co-authored-by: Dilara Gueler <D.Gueler@intershop.de> Co-authored-by: Susanne Schneider <s.schneider@intershop.de> Co-authored-by: Marcel Eisentraut <meisentraut@intershop.de> Co-authored-by: Silke Grüber <SGrueber@intershop.com>
- Loading branch information
1 parent
a8f0817
commit dfc19ac
Showing
48 changed files
with
1,580 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ crosssells | |
cxml | ||
cybersource | ||
datepicker | ||
decamelize | ||
directdebit | ||
dockerignore | ||
dockerized | ||
|
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
10 changes: 10 additions & 0 deletions
10
src/app/core/utils/http-error/update-oci-configuration.error-handler.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,10 @@ | ||
import { SpecialHttpErrorHandler } from 'ish-core/interceptors/icm-error-mapper.interceptor'; | ||
|
||
export const updateOciConfigurationErrorHandler: SpecialHttpErrorHandler = { | ||
test: (error, request) => error.url.endsWith('/oci5/configurations') && request.method === 'PUT', | ||
map: error => { | ||
if (error.status === 400) { | ||
return { message: error.error }; | ||
} | ||
}, | ||
}; |
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
9 changes: 9 additions & 0 deletions
9
src/app/extensions/punchout/models/oci-configuration-item/oci-configuration-item.model.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,9 @@ | ||
export interface OciConfigurationItem { | ||
field: string; | ||
transform: string; | ||
formatter: string; | ||
mappings?: { | ||
mapFromValue: string; | ||
mapToValue: string; | ||
}[]; | ||
} |
4 changes: 4 additions & 0 deletions
4
src/app/extensions/punchout/models/oci-options/oci-options.interface.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,4 @@ | ||
export interface OciOptionsData { | ||
availableFormatters: { id: string }[]; | ||
availablePlaceholders: { id: string }[]; | ||
} |
27 changes: 27 additions & 0 deletions
27
src/app/extensions/punchout/models/oci-options/oci-options.mapper.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,27 @@ | ||
import { OciOptionsData } from './oci-options.interface'; | ||
import { OciOptionsMapper } from './oci-options.mapper'; | ||
|
||
describe('Oci Options Mapper', () => { | ||
describe('fromData', () => { | ||
it(`should return Oci Options when getting OciOptionsData`, () => { | ||
const optionsData = { | ||
availableFormatters: [{ id: 'LowerCase' }, { id: 'UpperCase' }], | ||
availablePlaceholders: [{ id: 'Currency' }, { id: 'Price' }], | ||
} as OciOptionsData; | ||
const options = OciOptionsMapper.fromData(optionsData); | ||
|
||
expect(options).toMatchInlineSnapshot(` | ||
{ | ||
"availableFormatters": [ | ||
"LowerCase", | ||
"UpperCase", | ||
], | ||
"availablePlaceholders": [ | ||
"Currency", | ||
"Price", | ||
], | ||
} | ||
`); | ||
}); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
src/app/extensions/punchout/models/oci-options/oci-options.mapper.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,13 @@ | ||
import { OciOptionsData } from './oci-options.interface'; | ||
import { OciOptions } from './oci-options.model'; | ||
|
||
export class OciOptionsMapper { | ||
static fromData(payload: OciOptionsData): OciOptions { | ||
const { availableFormatters, availablePlaceholders } = payload; | ||
|
||
return { | ||
availableFormatters: availableFormatters?.map(formatter => formatter.id), | ||
availablePlaceholders: availablePlaceholders?.map(placeholder => placeholder.id), | ||
}; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/app/extensions/punchout/models/oci-options/oci-options.model.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,4 @@ | ||
export interface OciOptions { | ||
availableFormatters: string[]; | ||
availablePlaceholders: string[]; | ||
} |
5 changes: 5 additions & 0 deletions
5
...t/pages/account-punchout-configuration/account-punchout-configuration-page.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,5 @@ | ||
<h1>{{ 'account.punchout.configuration.heading' | translate }}</h1> | ||
|
||
<p>{{ 'account.punchout.configuration.description' | translate }}</p> | ||
|
||
<ish-oci-configuration-form></ish-oci-configuration-form> |
31 changes: 31 additions & 0 deletions
31
...ages/account-punchout-configuration/account-punchout-configuration-page.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,31 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { MockComponent } from 'ng-mocks'; | ||
|
||
import { AccountPunchoutConfigurationPageComponent } from './account-punchout-configuration-page.component'; | ||
import { OciConfigurationFormComponent } from './oci-configuration-form/oci-configuration-form.component'; | ||
|
||
describe('Account Punchout Configuration Page Component', () => { | ||
let component: AccountPunchoutConfigurationPageComponent; | ||
let fixture: ComponentFixture<AccountPunchoutConfigurationPageComponent>; | ||
let element: HTMLElement; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [TranslateModule.forRoot()], | ||
declarations: [AccountPunchoutConfigurationPageComponent, MockComponent(OciConfigurationFormComponent)], | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(AccountPunchoutConfigurationPageComponent); | ||
component = fixture.componentInstance; | ||
element = fixture.nativeElement; | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
expect(element).toBeTruthy(); | ||
expect(() => fixture.detectChanges()).not.toThrow(); | ||
}); | ||
}); |
8 changes: 8 additions & 0 deletions
8
...out/pages/account-punchout-configuration/account-punchout-configuration-page.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,8 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'ish-account-punchout-configuration-page', | ||
templateUrl: './account-punchout-configuration-page.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class AccountPunchoutConfigurationPageComponent {} |
60 changes: 60 additions & 0 deletions
60
...nchout/pages/account-punchout-configuration/account-punchout-configuration-page.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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule, Routes } from '@angular/router'; | ||
import { ConfigOption, FormlyModule } from '@ngx-formly/core'; | ||
|
||
import { PunchoutModule } from '../../punchout.module'; | ||
|
||
import { AccountPunchoutConfigurationPageComponent } from './account-punchout-configuration-page.component'; | ||
import { OciConfigurationMappingRepeatFieldComponent } from './formly/oci-configuration-mapping-repeat-field/oci-configuration-mapping-repeat-field.component'; | ||
import { OciConfigurationMappingWrapperComponent } from './formly/oci-configuration-mapping-wrapper/oci-configuration-mapping-wrapper.component'; | ||
import { OciConfigurationRepeatFieldComponent } from './formly/oci-configuration-repeat-field/oci-configuration-repeat-field.component'; | ||
import { OciConfigurationFormComponent } from './oci-configuration-form/oci-configuration-form.component'; | ||
|
||
const accountPunchoutConfigurationPageRoutes: Routes = [ | ||
{ | ||
path: '', | ||
data: { | ||
breadcrumbData: [ | ||
{ key: 'account.punchout.link', link: '/account/punchout' }, | ||
{ key: 'account.punchout.configuration.link' }, | ||
], | ||
}, | ||
component: AccountPunchoutConfigurationPageComponent, | ||
}, | ||
]; | ||
|
||
const ociConfigurationFormlyConfig: ConfigOption = { | ||
types: [ | ||
{ | ||
name: 'repeat-oci-config', | ||
component: OciConfigurationRepeatFieldComponent, | ||
}, | ||
{ | ||
name: 'repeat-oci-configuration-mapping', | ||
component: OciConfigurationMappingRepeatFieldComponent, | ||
}, | ||
], | ||
wrappers: [ | ||
{ | ||
name: 'oci-configuration-mapping-wrapper', | ||
component: OciConfigurationMappingWrapperComponent, | ||
}, | ||
], | ||
}; | ||
|
||
@NgModule({ | ||
imports: [ | ||
FormlyModule.forChild(ociConfigurationFormlyConfig), | ||
RouterModule.forChild(accountPunchoutConfigurationPageRoutes), | ||
PunchoutModule, | ||
], | ||
|
||
declarations: [ | ||
AccountPunchoutConfigurationPageComponent, | ||
OciConfigurationFormComponent, | ||
OciConfigurationMappingRepeatFieldComponent, | ||
OciConfigurationMappingWrapperComponent, | ||
OciConfigurationRepeatFieldComponent, | ||
], | ||
}) | ||
export class AccountPunchoutConfigurationPageModule {} |
6 changes: 6 additions & 0 deletions
6
...-configuration-mapping-repeat-field/oci-configuration-mapping-repeat-field.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,6 @@ | ||
<span *ngFor="let field of field?.fieldGroup; let i = index" [attr.data-testing-id]="'oci-config-mapping-line-' + i"> | ||
<formly-field [field]="field"></formly-field> | ||
</span> | ||
<a [routerLink]="[]" (click)="addRow()" data-testing-id="add-config-line">{{ | ||
'account.punchout.configuration.form.add_row.link' | translate | ||
}}</a> |
Oops, something went wrong.