Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/app/item-page/full/full-item-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@
<td>{{mdEntry.key}}</td>
<td>
<span *ngFor="let value of mdValue.value.split(SEPARATOR); let last=last;">
<span [innerHTML]="makeLinks(value) | dsReplace: [';', ' ']" ></span>
<span *ngIf="mdEntry.key === 'dc.contributor.author'; else otherField">
<span [innerHTML]="makeLinks(value | dsFormatAuthor) | dsReplace: [';', ' ']"></span>
</span>
Comment thread
Copilot marked this conversation as resolved.
<ng-template #otherField>
<span [innerHTML]="makeLinks(value) | dsReplace: [';', ' ']"></span>
</ng-template>
<span *ngIf="!last" [innerHTML]="' '"></span>
</span>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -349,7 +350,8 @@ const PIPES = [
CharToEndPipe,
ClarinSafeHtmlPipe,
ReplacePipe,
DsLangPipe
DsLangPipe,
FormatAuthorPipe
];

const COMPONENTS = [
Expand Down
28 changes: 28 additions & 0 deletions src/app/shared/utils/format-author.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
9 changes: 9 additions & 0 deletions src/app/shared/utils/format-author.pipe.ts
Original file line number Diff line number Diff line change
@@ -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*(?=\S)/g, ', ') || value;
}
}
Loading