Skip to content
Snippets Groups Projects
Commit 9ece5716 authored by Scott Berg's avatar Scott Berg Committed by Scott Berg
Browse files

Add tooltip to audit course notes. Refactor audit symbols

parent ce0ff341
No related branches found
No related tags found
No related merge requests found
...@@ -196,9 +196,9 @@ ...@@ -196,9 +196,9 @@
<p *ngIf="reqBody.contentType === 'okSubrequirementTLine' || reqBody.contentType === 'noSubrequirementTLine'"> <p *ngIf="reqBody.contentType === 'okSubrequirementTLine' || reqBody.contentType === 'noSubrequirementTLine'">
<ng-container *ngFor="let symbol of asLineBody(reqBody).lines | requirementSymbols"> <ng-container *ngFor="let symbol of asLineBody(reqBody).lines | requirementSymbols">
<ng-container [ngSwitch]="symbol.type"> <ng-container [ngSwitch]="symbol.type">
<span *ngSwitchCase="'text'" [matTooltip]="symbol.tooltip" matTooltipPosition="above">{{symbol.symbol}}</span> <span *ngSwitchCase="'text'" [matTooltip]="symbol.tooltip" matTooltipPosition="above">{{symbol.text}}</span>
<span *ngSwitchCase="'icon'" class="{{symbol.symbol}}"> <span *ngSwitchCase="'icon'" class="{{symbol.icon}}">
<mat-icon [matTooltip]="symbol.tooltip" matTooltipPosition="above">{{symbol.symbol}}</mat-icon> <mat-icon [matTooltip]="symbol.tooltip" matTooltipPosition="above">{{symbol.icon}}</mat-icon>
</span> </span>
</ng-container> </ng-container>
</ng-container> </ng-container>
...@@ -240,7 +240,11 @@ ...@@ -240,7 +240,11 @@
<ng-container matColumnDef="note"> <ng-container matColumnDef="note">
<th mat-header-cell *matHeaderCellDef scope="col">Course Note</th> <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> </ng-container>
</table> </table>
</ng-container> </ng-container>
......
...@@ -17,6 +17,7 @@ import { RequirementLinePipe } from './pipes/requirement-line.pipe'; ...@@ -17,6 +17,7 @@ import { RequirementLinePipe } from './pipes/requirement-line.pipe';
import { RequirementSymbolsPipe } from './pipes/requirement-symbols.pipe'; import { RequirementSymbolsPipe } from './pipes/requirement-symbols.pipe';
import { SchoolOrCollegePipe } from './pipes/school-college.pipe'; import { SchoolOrCollegePipe } from './pipes/school-college.pipe';
import { AuditNamePipe } from './pipes/name-format.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 { 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 { NewWhatIfAuditDialogComponent } from './new-what-if-audit-dialog/new-what-if-audit-dialog.component';
import { AuditViewComponent } from './dars-audit-view/dars-audit-view.component'; import { AuditViewComponent } from './dars-audit-view/dars-audit-view.component';
...@@ -38,6 +39,7 @@ import { RouterModule } from '@angular/router'; ...@@ -38,6 +39,7 @@ import { RouterModule } from '@angular/router';
RequirementSymbolsPipe, RequirementSymbolsPipe,
SchoolOrCollegePipe, SchoolOrCollegePipe,
AuditNamePipe, AuditNamePipe,
CourseNotePipe,
NewDegreeAuditDialogComponent, NewDegreeAuditDialogComponent,
NewWhatIfAuditDialogComponent, NewWhatIfAuditDialogComponent,
DARSViewComponent, DARSViewComponent,
......
export type AuditSymbol = AuditIconSymbol | AuditTextSymbol;
interface AuditIconSymbol {
type: 'icon';
text: string;
tooltip: string;
icon: string;
}
interface AuditTextSymbol {
type: 'text';
text: string;
tooltip: string;
}
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;
}, []);
}
}
import { Pipe, PipeTransform } from '@angular/core'; import { Pipe, PipeTransform } from '@angular/core';
import { AuditSymbol } from '../models/audit-symbols';
interface RequirementSymbolObject {
symbol: RequirementSymbol;
pattern: RegExp;
}
interface RequirementSymbol {
type: 'text' | 'icon';
symbol: string;
tooltip: string;
}
@Pipe({ name: 'requirementSymbols' }) @Pipe({ name: 'requirementSymbols' })
export class RequirementSymbolsPipe implements PipeTransform { export class RequirementSymbolsPipe implements PipeTransform {
transform(lines: string[]): RequirementSymbol[] { transform(lines: string[]): AuditSymbol[] {
const singleLine = lines.join(' ').trim(); const singleLine = lines.join(' ').trim();
const matches = singleLine.match(/^((IP)|(IN-P)|(PL)|(R)|(<>)|\+|\-|\*)+/g); const matches = singleLine.match(/^((IP)|(IN-P)|(PL)|(R)|(<>)|\+|\-|\*)+/g);
const symbols: RequirementSymbolObject[] = [ const symbols: AuditSymbol[] = [
{ symbol: { type: 'text', symbol: 'IP', tooltip: 'Requirement uses in-progress credit/courses' }, pattern: /IP/ }, { type: 'text', text: 'IP', tooltip: 'Requirement uses in-progress credit/courses' },
{ symbol: { type: 'text', symbol: 'IN-P', tooltip: 'Sub-requirement uses in progress credit/courses' }, pattern: /IN-P/ }, { type: 'text', text: 'IN-P', tooltip: 'Sub-requirement uses in progress credit/courses' },
{ symbol: { type: 'text', symbol: 'PL', tooltip: 'Requirement/sub-requirement uses planned course' }, pattern: /PL/ }, { type: 'text', text: 'PL', tooltip: 'Requirement/sub-requirement uses planned course' },
{ symbol: { type: 'text', symbol: 'R', tooltip: 'Required sub-requirement (mandatory)' }, pattern: /R/ }, { type: 'text', text: 'R', tooltip: 'Required sub-requirement (mandatory)' },
{ symbol: { type: 'text', symbol: '<>', tooltip: 'Optional/other requirement in OR\'d set complete' }, pattern: /<>/ }, { type: 'text', text: '<>', tooltip: 'Optional/other requirement in OR\'d set complete' },
{ symbol: { type: 'text', symbol: '*', tooltip: 'Optional sub-requirement, courses assigned' }, pattern: /\*}/ }, { type: 'text', text: '*', tooltip: 'Optional sub-requirement, courses assigned' },
{ symbol: { type: 'icon', symbol: 'check', tooltip: 'Sub-requirement complete' }, pattern: /\+/ }, { type: 'icon', text: '+', icon: 'check', tooltip: 'Sub-requirement complete' },
{ symbol: { type: 'icon', symbol: 'close', tooltip: 'Sub-requirement not complete' }, pattern: /\-/ }, { type: 'icon', text: '-', icon: 'close', tooltip: 'Sub-requirement not complete' }
]; ];
if (matches && matches.length > 0) { if (matches && matches.length > 0) {
const symbolString = singleLine.substr(0, matches[0].length); const symbolString = singleLine.substr(0, matches[0].length);
return symbols.reduce((acc, symbol) => { return symbols.reduce((acc, symbol) => {
return symbolString.match(symbol.pattern) !== null ? [...acc, symbol.symbol] : acc; return symbolString.includes(symbol.text) ? [...acc, symbol] : acc;
}, []); }, []);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment