From 814527b843bf66dda1929e2cdd1a95d26dba71dd Mon Sep 17 00:00:00 2001 From: amadulhaxxani Date: Wed, 15 Jul 2026 10:28:34 +0200 Subject: [PATCH 1/4] feat(author): add FormatAuthorPipe for display with space after comma --- src/app/item-page/full/full-item-page.component.html | 7 ++++++- src/app/shared/shared.module.ts | 4 +++- src/app/shared/utils/format-author.pipe.ts | 9 +++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/app/shared/utils/format-author.pipe.ts diff --git a/src/app/item-page/full/full-item-page.component.html b/src/app/item-page/full/full-item-page.component.html index 6a6e1f31573..0778ea853f5 100644 --- a/src/app/item-page/full/full-item-page.component.html +++ b/src/app/item-page/full/full-item-page.component.html @@ -47,7 +47,12 @@ {{mdEntry.key}} - + + + + + + diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index d0ea3a1bd28..f1a253b85f7 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -301,6 +301,7 @@ import { ClarinDateService } from './clarin-date.service'; import { ItemIdentifierService } from './item-identifier.service'; import { ClarinLicenseRequiredInfoCheckedPipe } from './utils/clarin-license-required-info-checked.pipe'; import { DsLangPipe } from './utils/ds-lang.pipe'; +import { FormatAuthorPipe } from './utils/format-author.pipe'; const MODULES = [ CommonModule, @@ -349,7 +350,8 @@ const PIPES = [ CharToEndPipe, ClarinSafeHtmlPipe, ReplacePipe, - DsLangPipe + DsLangPipe, + FormatAuthorPipe ]; const COMPONENTS = [ diff --git a/src/app/shared/utils/format-author.pipe.ts b/src/app/shared/utils/format-author.pipe.ts new file mode 100644 index 00000000000..2ec996e9692 --- /dev/null +++ b/src/app/shared/utils/format-author.pipe.ts @@ -0,0 +1,9 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ name: 'dsFormatAuthor' }) +export class FormatAuthorPipe implements PipeTransform { + transform(value: string): string { + // Normalise comma followed by zero or more whitespace to a single comma + space + return value?.replace(/,\s*/g, ', ') || value; + } +} From 512dabfd5785bbd380442bca469094a094da757a Mon Sep 17 00:00:00 2001 From: amadulhaxxani Date: Wed, 15 Jul 2026 11:27:56 +0200 Subject: [PATCH 2/4] test(author): add unit tests for FormatAuthorPipe --- .../shared/utils/format-author.pipe.spec.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/app/shared/utils/format-author.pipe.spec.ts diff --git a/src/app/shared/utils/format-author.pipe.spec.ts b/src/app/shared/utils/format-author.pipe.spec.ts new file mode 100644 index 00000000000..822cd44da03 --- /dev/null +++ b/src/app/shared/utils/format-author.pipe.spec.ts @@ -0,0 +1,28 @@ +import { FormatAuthorPipe } from "./format-author.pipe"; + +describe('FormatAuthorPipe', () => { + let pipe: FormatAuthorPipe; + + beforeEach(() => { + pipe = new FormatAuthorPipe(); + }); + + it('should create', () => { + expect(pipe).toBeTruthy(); + }); + + it('should add single space after comma when missing', () => { + expect(pipe.transform('Doe,John')).toEqual('Doe, John'); + }); + + it('should keep single space after comma unchanged', () => { + expect(pipe.transform('Doe, John')).toEqual('Doe, John'); + }); + + it('should return value as-is when there is no comma', () => { + expect(pipe.transform('')).toEqual(''); + expect(pipe.transform(null as any)).toBeNull(); + expect(pipe.transform('John Doe')).toEqual('John Doe'); + expect(pipe.transform(undefined as any)).toBeUndefined(); + }); +}); From f1597a492c04e8e92ec73afed44c13ac58ec706b Mon Sep 17 00:00:00 2001 From: amadulhaxxani Date: Wed, 15 Jul 2026 14:08:13 +0200 Subject: [PATCH 3/4] fix(author): store author with comma-space and fix display pipe edge cases - Change clarin-name separator to ', ' for human-readable DB storage. - Apply FormatAuthorPipe before makeLinks to avoid breaking URLs. - Use positive lookahead in regex to prevent trailing space after comma. - Fix import quote style in pipe spec. --- src/app/item-page/full/full-item-page.component.html | 2 +- .../form/builder/ds-dynamic-form-ui/models/clarin-name.model.ts | 2 +- src/app/shared/utils/format-author.pipe.spec.ts | 2 +- src/app/shared/utils/format-author.pipe.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/item-page/full/full-item-page.component.html b/src/app/item-page/full/full-item-page.component.html index 0778ea853f5..4556077d5ce 100644 --- a/src/app/item-page/full/full-item-page.component.html +++ b/src/app/item-page/full/full-item-page.component.html @@ -48,7 +48,7 @@ - + diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/clarin-name.model.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/clarin-name.model.ts index 99b1c3fcee5..9b5c6cf3d06 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/clarin-name.model.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/clarin-name.model.ts @@ -38,7 +38,7 @@ export class DynamicClarinNameModel extends DynamicConcatModel { constructor(config: DynamicConcatModelConfig, layout?: DynamicFormControlLayout) { super(config, layout); - this.separator = ','; + this.separator = ', '; this.relationship = config.relationship; this.repeatable = config.repeatable; this.required = config.required; diff --git a/src/app/shared/utils/format-author.pipe.spec.ts b/src/app/shared/utils/format-author.pipe.spec.ts index 822cd44da03..8929d36564f 100644 --- a/src/app/shared/utils/format-author.pipe.spec.ts +++ b/src/app/shared/utils/format-author.pipe.spec.ts @@ -1,4 +1,4 @@ -import { FormatAuthorPipe } from "./format-author.pipe"; +import { FormatAuthorPipe } from './format-author.pipe'; describe('FormatAuthorPipe', () => { let pipe: FormatAuthorPipe; diff --git a/src/app/shared/utils/format-author.pipe.ts b/src/app/shared/utils/format-author.pipe.ts index 2ec996e9692..4ee47905f7a 100644 --- a/src/app/shared/utils/format-author.pipe.ts +++ b/src/app/shared/utils/format-author.pipe.ts @@ -4,6 +4,6 @@ import { Pipe, PipeTransform } from '@angular/core'; export class FormatAuthorPipe implements PipeTransform { transform(value: string): string { // Normalise comma followed by zero or more whitespace to a single comma + space - return value?.replace(/,\s*/g, ', ') || value; + return value?.replace(/,\s*(?=\S)/g, ', ') || value; } } From 2ec85541093caa0427dd427f5691b6e862035848 Mon Sep 17 00:00:00 2001 From: amadulhaxxani Date: Wed, 15 Jul 2026 14:32:40 +0200 Subject: [PATCH 4/4] fix(test): update separator expectation in clarin-name parser spec --- .../form/builder/parsers/clarin-name-field-parser.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/form/builder/parsers/clarin-name-field-parser.spec.ts b/src/app/shared/form/builder/parsers/clarin-name-field-parser.spec.ts index 3692c3e3c2e..a2b313ba69a 100644 --- a/src/app/shared/form/builder/parsers/clarin-name-field-parser.spec.ts +++ b/src/app/shared/form/builder/parsers/clarin-name-field-parser.spec.ts @@ -94,7 +94,7 @@ describe('ClarinNameFieldParser test suite', () => { const fieldModel = parser.parse(); - expect((fieldModel as DynamicConcatModel).separator).toBe(','); + expect((fieldModel as DynamicConcatModel).separator).toBe(', '); }); it('should set init value properly', () => {