diff --git a/src/app/dars/audit/audit.component.html b/src/app/dars/audit/audit.component.html index 3cdedf5879ee9ea04c0c3062a1ea8c5a0889fcd9..70fda64691ff434ad9678fd34b3ca3d8f1a4904c 100644 --- a/src/app/dars/audit/audit.component.html +++ b/src/app/dars/audit/audit.component.html @@ -196,9 +196,9 @@ <p *ngIf="reqBody.contentType === 'okSubrequirementTLine' || reqBody.contentType === 'noSubrequirementTLine'"> <ng-container *ngFor="let symbol of asLineBody(reqBody).lines | requirementSymbols"> <ng-container [ngSwitch]="symbol.type"> - <span *ngSwitchCase="'text'" [matTooltip]="symbol.tooltip" matTooltipPosition="above">{{symbol.symbol}}</span> - <span *ngSwitchCase="'icon'" class="{{symbol.symbol}}"> - <mat-icon [matTooltip]="symbol.tooltip" matTooltipPosition="above">{{symbol.symbol}}</mat-icon> + <span *ngSwitchCase="'text'" [matTooltip]="symbol.tooltip" matTooltipPosition="above">{{symbol.text}}</span> + <span *ngSwitchCase="'icon'" class="{{symbol.icon}}"> + <mat-icon [matTooltip]="symbol.tooltip" matTooltipPosition="above">{{symbol.icon}}</mat-icon> </span> </ng-container> </ng-container> @@ -240,7 +240,11 @@ <ng-container matColumnDef="note"> <th mat-header-cell *matHeaderCellDef scope="col">Course Note</th> - <td mat-cell *matCellDef="let course">{{course.courseNote}}</td> + <td mat-cell *matCellDef="let course"> + <span *ngFor="let note of course.courseNote | courseNote" [matTooltip]="note.tooltip" matTooltipPosition="above"> + {{note.text}} + </span> + </td> </ng-container> </table> </ng-container> diff --git a/src/app/dars/dars.module.ts b/src/app/dars/dars.module.ts index 64988473e457fb9db49ecdc2095a3d17a510deb0..c4fe7788814a9b5494c3adef63de633a30e5968a 100644 --- a/src/app/dars/dars.module.ts +++ b/src/app/dars/dars.module.ts @@ -17,6 +17,7 @@ import { RequirementLinePipe } from './pipes/requirement-line.pipe'; import { RequirementSymbolsPipe } from './pipes/requirement-symbols.pipe'; import { SchoolOrCollegePipe } from './pipes/school-college.pipe'; import { AuditNamePipe } from './pipes/name-format.pipe'; +import { CourseNotePipe } from './pipes/course-note.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'; @@ -38,6 +39,7 @@ import { RouterModule } from '@angular/router'; RequirementSymbolsPipe, SchoolOrCollegePipe, AuditNamePipe, + CourseNotePipe, NewDegreeAuditDialogComponent, NewWhatIfAuditDialogComponent, DARSViewComponent, diff --git a/src/app/dars/models/audit-symbols.ts b/src/app/dars/models/audit-symbols.ts new file mode 100644 index 0000000000000000000000000000000000000000..34fdab98a08c5929db761a7717d962ba7d9711c0 --- /dev/null +++ b/src/app/dars/models/audit-symbols.ts @@ -0,0 +1,14 @@ +export type AuditSymbol = AuditIconSymbol | AuditTextSymbol; + +interface AuditIconSymbol { + type: 'icon'; + text: string; + tooltip: string; + icon: string; +} + +interface AuditTextSymbol { + type: 'text'; + text: string; + tooltip: string; +} diff --git a/src/app/dars/pipes/course-note.pipe.ts b/src/app/dars/pipes/course-note.pipe.ts new file mode 100644 index 0000000000000000000000000000000000000000..2e5c84ea835c048f54896947e6a514b6764b0eb3 --- /dev/null +++ b/src/app/dars/pipes/course-note.pipe.ts @@ -0,0 +1,24 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { AuditSymbol } from '../models/audit-symbols'; + +@Pipe({ name: 'courseNote' }) +export class CourseNotePipe implements PipeTransform { + transform(notes: string | null): AuditSymbol[] { + if (notes === null) { + return []; + } + + const symbols: AuditSymbol[] = [ + { type: 'text', text: '>D', tooltip: 'Duplicate course - retains GPA effect' }, + { type: 'text', text: '>R', tooltip: 'Repeatable course' }, + { type: 'text', text: '>S', tooltip: 'Credit split between requirements' }, + { type: 'text', text: '>X', tooltip: 'Repeated course - no course credit or GPA effect' }, + { type: 'text', text: '(R)', tooltip: 'Required course' }, + { type: 'text', text: '(X)', tooltip: 'Original course value' }, + ]; + + return symbols.reduce((acc, symbol) => { + return notes.includes(symbol.text) ? [...acc, symbol] : acc; + }, []); + } +} diff --git a/src/app/dars/pipes/requirement-symbols.pipe.ts b/src/app/dars/pipes/requirement-symbols.pipe.ts index c84d2cfccdd36e52b091e2ec982a3074471218af..12f9538da7492b7117b69c7f315ef831c84d2162 100644 --- a/src/app/dars/pipes/requirement-symbols.pipe.ts +++ b/src/app/dars/pipes/requirement-symbols.pipe.ts @@ -1,36 +1,26 @@ import { Pipe, PipeTransform } from '@angular/core'; - -interface RequirementSymbolObject { - symbol: RequirementSymbol; - pattern: RegExp; -} - -interface RequirementSymbol { - type: 'text' | 'icon'; - symbol: string; - tooltip: string; -} +import { AuditSymbol } from '../models/audit-symbols'; @Pipe({ name: 'requirementSymbols' }) export class RequirementSymbolsPipe implements PipeTransform { - transform(lines: string[]): RequirementSymbol[] { + transform(lines: string[]): AuditSymbol[] { const singleLine = lines.join(' ').trim(); const matches = singleLine.match(/^((IP)|(IN-P)|(PL)|(R)|(<>)|\+|\-|\*)+/g); - const symbols: RequirementSymbolObject[] = [ - { symbol: { type: 'text', symbol: 'IP', tooltip: 'Requirement uses in-progress credit/courses' }, pattern: /IP/ }, - { symbol: { type: 'text', symbol: 'IN-P', tooltip: 'Sub-requirement uses in progress credit/courses' }, pattern: /IN-P/ }, - { symbol: { type: 'text', symbol: 'PL', tooltip: 'Requirement/sub-requirement uses planned course' }, pattern: /PL/ }, - { symbol: { type: 'text', symbol: 'R', tooltip: 'Required sub-requirement (mandatory)' }, pattern: /R/ }, - { symbol: { type: 'text', symbol: '<>', tooltip: 'Optional/other requirement in OR\'d set complete' }, pattern: /<>/ }, - { symbol: { type: 'text', symbol: '*', tooltip: 'Optional sub-requirement, courses assigned' }, pattern: /\*}/ }, - { symbol: { type: 'icon', symbol: 'check', tooltip: 'Sub-requirement complete' }, pattern: /\+/ }, - { symbol: { type: 'icon', symbol: 'close', tooltip: 'Sub-requirement not complete' }, pattern: /\-/ }, + const symbols: AuditSymbol[] = [ + { type: 'text', text: 'IP', tooltip: 'Requirement uses in-progress credit/courses' }, + { type: 'text', text: 'IN-P', tooltip: 'Sub-requirement uses in progress credit/courses' }, + { type: 'text', text: 'PL', tooltip: 'Requirement/sub-requirement uses planned course' }, + { type: 'text', text: 'R', tooltip: 'Required sub-requirement (mandatory)' }, + { type: 'text', text: '<>', tooltip: 'Optional/other requirement in OR\'d set complete' }, + { type: 'text', text: '*', tooltip: 'Optional sub-requirement, courses assigned' }, + { type: 'icon', text: '+', icon: 'check', tooltip: 'Sub-requirement complete' }, + { type: 'icon', text: '-', icon: 'close', tooltip: 'Sub-requirement not complete' } ]; if (matches && matches.length > 0) { const symbolString = singleLine.substr(0, matches[0].length); return symbols.reduce((acc, symbol) => { - return symbolString.match(symbol.pattern) !== null ? [...acc, symbol.symbol] : acc; + return symbolString.includes(symbol.text) ? [...acc, symbol] : acc; }, []); }