From ef82e40d469311aef9f4d4bd48dfb443c6c5c4bc Mon Sep 17 00:00:00 2001 From: Randy Woods Date: Fri, 21 Feb 2025 12:36:37 -0700 Subject: [PATCH 1/2] Refactored linefeed for question text Moved a smarter linefeed handler to UI and out of API --- CSETWebNg/src/app/app.module.ts | 30 ------------------- .../assessment-info.component.ts | 3 +- .../question-block.component.ts | 14 ++++----- CSETWebNg/src/app/helpers/linebreak.pipe.ts | 3 +- .../src/app/helpers/linebreakplain.pipe.ts | 3 +- 5 files changed, 12 insertions(+), 41 deletions(-) diff --git a/CSETWebNg/src/app/app.module.ts b/CSETWebNg/src/app/app.module.ts index daefc5aa7d..2686e88559 100644 --- a/CSETWebNg/src/app/app.module.ts +++ b/CSETWebNg/src/app/app.module.ts @@ -637,7 +637,6 @@ import { MalcolmUploadErrorComponent } from './dialogs/malcolm/malcolm-upload-er import { FooterService } from './services/footer.service'; import { AssessmentConvertCfComponent } from './assessment/prepare/assessment-info/assessment-convert-cf/assessment-convert-cf.component'; import { IseWarningsComponent } from './assessment/results/reports/ise-warnings/ise-warnings.component'; -// import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core'; import { TrendCompareCompatibilityComponent } from './aggregation/trend-analytics/trend-compare-compatibility/trend-compare-compatibility.component'; import { QuestionBlockCieComponent } from './assessment/questions/question-block-cie/question-block-cie.component'; import { PrincipleSummaryComponent } from './assessment/questions/principle-summary/principle-summary.component'; @@ -1239,7 +1238,6 @@ import { UpgradeComponent } from './assessment/upgrade/upgrade.component'; FormsModule, CommonModule, AppRoutingModule, - // Material A11yModule, CdkAccordionModule, ClipboardModule, @@ -1285,36 +1283,8 @@ import { UpgradeComponent } from './assessment/upgrade/upgrade.component'; OverlayModule, PortalModule, ScrollingModule, - // AutosizeModule, - // NgChartsModule, - // MatButtonModule, - // MatToolbarModule, - // MatChipsModule, - // MatSlideToggleModule, - // MatInputModule, - // MatCardModule, - // MatSliderModule, - // MatDatepickerModule, - // MatNativeDateModule, - // MatFormFieldModule, - // MatSortModule, - // MatExpansionModule, - // MatAutocompleteModule, - // MatDialogModule, - // MatTooltipModule, - // MatSnackBarModule, - // MatSidenavModule, - // MatTreeModule, - // MatIconModule, - // MatDividerModule, - // MatProgressSpinnerModule, - // MatProgressBarModule, - // MatListModule, - // MatMenuModule, - // MatTabsModule, ReactiveFormsModule, NgxSliderModule, - // TextareaAutosizeModule, FileUploadModule, AngularEditorModule, RouterModule, diff --git a/CSETWebNg/src/app/assessment/prepare/assessment-info/assessment-info.component.ts b/CSETWebNg/src/app/assessment/prepare/assessment-info/assessment-info.component.ts index 7adc46759c..d334f39237 100644 --- a/CSETWebNg/src/app/assessment/prepare/assessment-info/assessment-info.component.ts +++ b/CSETWebNg/src/app/assessment/prepare/assessment-info/assessment-info.component.ts @@ -51,12 +51,11 @@ export class AssessmentInfoComponent implements OnInit { ngOnInit(): void { if (this.configSvc.config.debug.showCmmcConversion ?? false) { this.assessSvc.getAssessmentDetail().subscribe((data: AssessmentDetail) => { - if (data.maturityModel.modelName == "CMMC2") { + if (data.maturityModel?.modelName == "CMMC2") { this.showUpgrade = true; this.targetModel = "CMMC2F" } }); } - } } diff --git a/CSETWebNg/src/app/assessment/questions/question-block/question-block.component.ts b/CSETWebNg/src/app/assessment/questions/question-block/question-block.component.ts index 848fcede53..01d08517c2 100644 --- a/CSETWebNg/src/app/assessment/questions/question-block/question-block.component.ts +++ b/CSETWebNg/src/app/assessment/questions/question-block/question-block.component.ts @@ -31,8 +31,8 @@ import { AssessmentService } from '../../../services/assessment.service'; import { QuestionFilterService } from '../../../services/filtering/question-filter.service'; import { LayoutService } from '../../../services/layout.service'; import { CompletionService } from '../../../services/completion.service'; -import { ConversionService } from '../../../services/conversion.service'; import { MalcolmService } from '../../../services/malcolm.service'; +import { LinebreakPipe } from '../../../helpers/linebreak.pipe'; /** @@ -83,15 +83,13 @@ export class QuestionBlockComponent implements OnInit { public assessSvc: AssessmentService, public layoutSvc: LayoutService, public malcolmSvc: MalcolmService, - private convertSvc: ConversionService + public linebreakPipe: LinebreakPipe ) { this.matLevelMap.set("B", "Baseline"); this.matLevelMap.set("E", "Evolving"); this.matLevelMap.set("Int", "Intermediate"); this.matLevelMap.set("A", "Advanced"); this.matLevelMap.set("Inn", "Innovative"); - - } /** @@ -115,12 +113,14 @@ export class QuestionBlockComponent implements OnInit { * @param q */ applyTokensToText(q: Question) { + let text = q.questionText; + + text = this.linebreakPipe.transform(text); + if (!q.parmSubs) { - return q.questionText; + return text; } - let text = q.questionText; - q.parmSubs.forEach(t => { let s = t.substitution; if (s == null) { diff --git a/CSETWebNg/src/app/helpers/linebreak.pipe.ts b/CSETWebNg/src/app/helpers/linebreak.pipe.ts index 2fe8e2c77c..1f6465eaa7 100644 --- a/CSETWebNg/src/app/helpers/linebreak.pipe.ts +++ b/CSETWebNg/src/app/helpers/linebreak.pipe.ts @@ -21,12 +21,13 @@ // SOFTWARE. // //////////////////////////////// -import { Pipe, PipeTransform } from '@angular/core'; +import { Injectable, Pipe, PipeTransform } from '@angular/core'; /** * Converts linefeed characters to HTML '
' tags */ @Pipe({ name: 'linebreak' }) +@Injectable({ providedIn: 'root' }) export class LinebreakPipe implements PipeTransform { transform(text: string): string { // if we detect HTML already in the string, do nothing diff --git a/CSETWebNg/src/app/helpers/linebreakplain.pipe.ts b/CSETWebNg/src/app/helpers/linebreakplain.pipe.ts index cc5e68f9f2..f3491b0b10 100644 --- a/CSETWebNg/src/app/helpers/linebreakplain.pipe.ts +++ b/CSETWebNg/src/app/helpers/linebreakplain.pipe.ts @@ -21,13 +21,14 @@ // SOFTWARE. // //////////////////////////////// -import { Pipe, PipeTransform } from '@angular/core'; +import { Injectable, Pipe, PipeTransform } from '@angular/core'; /** * Converts linefeed characters to HTML '
' tags * without trying to preserve any HTML in the string. */ @Pipe({ name: 'linebreakplain' }) +@Injectable({ providedIn: 'root' }) export class LinebreakPlaintextPipe implements PipeTransform { transform(text: string): string { return text?.replace(/(?:\r\n|\r|\n)/g, '
'); From 910dc228487d845d45fb9ac76927f6143465802d Mon Sep 17 00:00:00 2001 From: Randy Woods Date: Mon, 24 Feb 2025 15:09:36 -0700 Subject: [PATCH 2/2] Turned off debug question ID display --- CSETWebNg/src/assets/settings/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CSETWebNg/src/assets/settings/config.json b/CSETWebNg/src/assets/settings/config.json index fa121c9f7f..d1b1d45715 100644 --- a/CSETWebNg/src/assets/settings/config.json +++ b/CSETWebNg/src/assets/settings/config.json @@ -30,7 +30,7 @@ "debug": { "showCmmcConversion": true, "showBuildTime": false, - "showQuestionAndRequirementIDs": true, + "showQuestionAndRequirementIDs": false, "canDeleteCustomModules": true, "showExportAllButton": false },