diff --git a/src/main/webapp/app/entities/customer/customer-detail.component.html b/src/main/webapp/app/entities/customer/customer-detail.component.html index fbf98ec0..330100e0 100644 --- a/src/main/webapp/app/entities/customer/customer-detail.component.html +++ b/src/main/webapp/app/entities/customer/customer-detail.component.html @@ -19,7 +19,7 @@
Contractual Address
- {{customer.contractualAddress}} +
Contractual Salutation
@@ -27,7 +27,7 @@
Billing Address
- {{customer.billingAddress}} +
Billing Salutation
diff --git a/src/main/webapp/app/entities/customer/customer-update.component.html b/src/main/webapp/app/entities/customer/customer-update.component.html index 559ce9d5..7be62c02 100644 --- a/src/main/webapp/app/entities/customer/customer-update.component.html +++ b/src/main/webapp/app/entities/customer/customer-update.component.html @@ -63,9 +63,10 @@
- - + +
@@ -90,8 +91,8 @@
- +
diff --git a/src/main/webapp/app/entities/customer/customer.component.html b/src/main/webapp/app/entities/customer/customer.component.html index 497341cd..8429a3f9 100644 --- a/src/main/webapp/app/entities/customer/customer.component.html +++ b/src/main/webapp/app/entities/customer/customer.component.html @@ -37,9 +37,9 @@ {{customer.number}} {{customer.prefix}} {{customer.name}} - {{customer.contractualAddress}} + {{customer.contractualAddress | linebreaks:' | '}} {{customer.contractualSalutation}} - {{customer.billingAddress}} + {{customer.billingAddress | linebreaks:' | '}} {{customer.billingSalutation}}
diff --git a/src/main/webapp/app/shared/shared-common.module.ts b/src/main/webapp/app/shared/shared-common.module.ts index 17b74c5a..9741c2d3 100644 --- a/src/main/webapp/app/shared/shared-common.module.ts +++ b/src/main/webapp/app/shared/shared-common.module.ts @@ -1,10 +1,11 @@ import { NgModule } from '@angular/core'; -import { HsadminNgSharedLibsModule, FindLanguageFromKeyPipe, JhiAlertComponent, JhiAlertErrorComponent } from './'; +import { FindLanguageFromKeyPipe, HsadminNgSharedLibsModule, JhiAlertComponent, JhiAlertErrorComponent } from './'; +import { LinebreaksPipe } from 'app/shared/util/linebreaks-pipe'; @NgModule({ imports: [HsadminNgSharedLibsModule], - declarations: [FindLanguageFromKeyPipe, JhiAlertComponent, JhiAlertErrorComponent], - exports: [HsadminNgSharedLibsModule, FindLanguageFromKeyPipe, JhiAlertComponent, JhiAlertErrorComponent] + declarations: [FindLanguageFromKeyPipe, LinebreaksPipe, JhiAlertComponent, JhiAlertErrorComponent], + exports: [HsadminNgSharedLibsModule, FindLanguageFromKeyPipe, LinebreaksPipe, JhiAlertComponent, JhiAlertErrorComponent] }) export class HsadminNgSharedCommonModule {} diff --git a/src/main/webapp/app/shared/util/linebreaks-pipe.ts b/src/main/webapp/app/shared/util/linebreaks-pipe.ts new file mode 100644 index 00000000..7cdab263 --- /dev/null +++ b/src/main/webapp/app/shared/util/linebreaks-pipe.ts @@ -0,0 +1,11 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ name: 'linebreaks' }) +export class LinebreaksPipe implements PipeTransform { + transform(text: string, as: string = '
'): string { + if (text == null) { + return null; + } + return text.replace(/\n/g, as); + } +} diff --git a/src/test/javascript/spec/app/shared/util/linebreaks-pipe.spec.ts b/src/test/javascript/spec/app/shared/util/linebreaks-pipe.spec.ts new file mode 100644 index 00000000..28e20578 --- /dev/null +++ b/src/test/javascript/spec/app/shared/util/linebreaks-pipe.spec.ts @@ -0,0 +1,37 @@ +import { LinebreaksPipe } from 'app/shared/util/linebreaks-pipe'; + +/* To run these tests in IntelliJ IDEA, you need a run configuration with + Configuration File: + ~/Projekte/Hostsharing/hsadmin-ng/src/test/javascript/jest.conf.js + and a Node Interpreter, e.g. if installed with nvm, this could be: + ~/.nvm/versions/node/v10.15.3/bin/node + */ +describe('LinebreaksPipe Tests', () => { + describe('LinebreaksPipe', () => { + let pipe: LinebreaksPipe; + + beforeEach(() => { + pipe = new LinebreaksPipe(); + }); + + it('converts null to null', () => { + expect(pipe.transform(null)).toBe(null); + }); + + it('converts empty string to empty string', () => { + expect(pipe.transform('')).toBe(''); + }); + + it('converts string not containing line breaks to identical string', () => { + expect(pipe.transform('no linebreak here')).toBe('no linebreak here'); + }); + + it('converts string containing line breaks to string containing
by default', () => { + expect(pipe.transform('some\nlinebreaks\nhere')).toBe('some
linebreaks
here'); + }); + + it('converts string containing line breaks string containing specified replacement', () => { + expect(pipe.transform('some\nlinebreaks\nhere', ' | ')).toBe('some | linebreaks | here'); + }); + }); +});