Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed question formatting to use smart linefeed pipes when formatting text that may or may not have embedded HTML #4455

Merged
merged 3 commits into from
Feb 24, 2025
Merged
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
30 changes: 0 additions & 30 deletions CSETWebNg/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -1239,7 +1238,6 @@ import { UpgradeComponent } from './assessment/upgrade/upgrade.component';
FormsModule,
CommonModule,
AppRoutingModule,
// Material
A11yModule,
CdkAccordionModule,
ClipboardModule,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,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"
}
});
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';


/**
Expand Down Expand Up @@ -84,15 +84,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");


}

/**
Expand All @@ -116,12 +114,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) {
Expand Down
7 changes: 4 additions & 3 deletions CSETWebNg/src/app/helpers/linebreak.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
// SOFTWARE.
//
////////////////////////////////
import { Pipe, PipeTransform } from '@angular/core';
import { Injectable, Pipe, PipeTransform } from '@angular/core';

/**
* Converts linefeed characters to HTML '<br />' tags
*/

@Pipe({
name: 'linebreak',
standalone: false
name: 'linebreak', standalone: false
})
@Injectable({ providedIn: 'root' })
export class LinebreakPipe implements PipeTransform {
transform(text: string): string {
// if we detect HTML already in the string, do nothing
Expand Down
6 changes: 3 additions & 3 deletions CSETWebNg/src/app/helpers/linebreakplain.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
// SOFTWARE.
//
////////////////////////////////
import { Pipe, PipeTransform } from '@angular/core';
import { Injectable, Pipe, PipeTransform } from '@angular/core';

/**
* Converts linefeed characters to HTML '<br />' tags
* without trying to preserve any HTML in the string.
*/
@Pipe({
name: 'linebreakplain',
standalone: false
name: 'linebreakplain', standalone: false
})
@Injectable({ providedIn: 'root' })
export class LinebreakPlaintextPipe implements PipeTransform {
transform(text: string): string {
return text?.replace(/(?:\r\n|\r|\n)/g, '<br />');
Expand Down
2 changes: 1 addition & 1 deletion CSETWebNg/src/assets/settings/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"debug": {
"showCmmcConversion": true,
"showBuildTime": false,
"showQuestionAndRequirementIDs": true,
"showQuestionAndRequirementIDs": false,
"canDeleteCustomModules": true,
"showExportAllButton": false
},
Expand Down
Loading