From 371eaa6e83a3b24fad10adca9230997ca077aa76 Mon Sep 17 00:00:00 2001 From: Scott Berg <saberg3@wisc.edu> Date: Wed, 31 Jul 2019 11:15:58 -0500 Subject: [PATCH] Add name formatting pipe. --- src/app/dars/audit/audit.component.html | 4 ++-- src/app/dars/dars.module.ts | 2 ++ src/app/dars/pipes/name-format.pipe.ts | 12 ++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 src/app/dars/pipes/name-format.pipe.ts diff --git a/src/app/dars/audit/audit.component.html b/src/app/dars/audit/audit.component.html index 1e0e694..bcb0277 100644 --- a/src/app/dars/audit/audit.component.html +++ b/src/app/dars/audit/audit.component.html @@ -3,7 +3,7 @@ <div class="audit-metadata"> <div> <p>{{audit.header.preparedLabel}}: {{audit.header.preparedDate}}</p> - <p>{{audit.header.studentName}}</p> + <p>{{audit.header.studentName | auditFormatName}}</p> <p>{{audit.header.darsDegreeProgramCodeLabel}}: {{audit.header.darsDegreeProgramCode}}</p> </div> @@ -38,7 +38,7 @@ <h4>{{audit.topSection.advisorSection.advisorLabel}}:</h4> <ng-container *ngFor="let name of audit.topSection.advisorSection.advisorNames"> - <p class="audit-advisor-name">{{name}}</p> + <p class="audit-advisor-name">{{name | auditFormatName}}</p> </ng-container> </div> diff --git a/src/app/dars/dars.module.ts b/src/app/dars/dars.module.ts index fcccd4b..210611f 100644 --- a/src/app/dars/dars.module.ts +++ b/src/app/dars/dars.module.ts @@ -13,6 +13,7 @@ import { StoreModule } from '@ngrx/store'; import { darsReducer } from './store/reducer'; import { AuditLinePipe } from './pipes/audit-line.pipe'; import { SchoolOrCollegePipe } from './pipes/school-college.pipe'; +import { AuditNamePipe } from './pipes/name-format.pipe'; import { NewDegreeAuditDialogComponent } from './new-degree-audit-dialog/new-degree-audit-dialog.component'; import { NewWhatIfAuditDialogComponent } from './new-what-if-audit-dialog/new-what-if-audit-dialog.component'; import { AuditViewComponent } from './dars-audit-view/dars-audit-view.component'; @@ -30,6 +31,7 @@ import { RouterModule } from '@angular/router'; declarations: [ AuditLinePipe, SchoolOrCollegePipe, + AuditNamePipe, NewDegreeAuditDialogComponent, NewWhatIfAuditDialogComponent, DARSViewComponent, diff --git a/src/app/dars/pipes/name-format.pipe.ts b/src/app/dars/pipes/name-format.pipe.ts new file mode 100644 index 0000000..1f4578e --- /dev/null +++ b/src/app/dars/pipes/name-format.pipe.ts @@ -0,0 +1,12 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ name: 'auditFormatName' }) +export class AuditNamePipe implements PipeTransform { + transform(name: string): string { + // Regex to match commas with no spaces after + const regex = /(,(?=\S)|:)/; + name = name.replace(regex, ', '); + + return name; + } +} -- GitLab