Skip to content

Commit

Permalink
Merge pull request #4307 from cisagov/feat/CSET-2859
Browse files Browse the repository at this point in the history
  • Loading branch information
jekuipers authored Dec 19, 2024
2 parents 658dcc6 + b0f0577 commit 58fc723
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class QuestionDetails


public bool IsDetailAndInfo { get; set; }

public bool? overRide { get; set; }


/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NPOI.SS.Formula.Functions;

namespace CSETWebCore.Business.Question
{
Expand Down Expand Up @@ -92,12 +93,21 @@ public QuestionDetails GetQuestionDetails(int? questionId, int assessmentId, str
bool IsQuestion = mode.IsQuestion;
// bool IsRequirement = IsComponent ? !IsComponent : mode.IsRequirement;
var newqp = _context.NEW_QUESTION.Where(q => q.Question_Id == questionId).FirstOrDefault();
var newAnswer = this._context.ANSWER.Where(a =>
var answer = this._context.ANSWER.Where(a =>
a.Question_Or_Requirement_Id == questionId
&& a.Assessment_Id == assessmentId
&& a.Question_Type == questionType).FirstOrDefault();


&& a.Question_Type == questionType).ToList();

if (answer.Count() > 1)
{
response.overRide = true;
}
else
{
response.overRide = false;
}
ANSWER newAnswer = answer.FirstOrDefault();

if (newAnswer == null)
{
newAnswer = new ANSWER()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
</div>
</div>
<div *ngIf="myQuestion.is_Component; else detailTab">
<div *ngIf=" !!extras && !!tab && mode == 'COMPONENT'" class="detail">
<div *ngIf=" !!extras && !!tab && mode == 'COMPONENT' && !extras.overRide" class="detail">
<table>
<tr>
<th class="pe-3">{{t('extras.component type')}}</th>
Expand All @@ -190,6 +190,7 @@
</tr>
</table>
</div>
<div *ngIf=" !!extras && !!tab && mode == 'COMPONENT' && extras.overRide" class="detail">{{t('extras.override details')}}</div>
<div *ngIf="!!extras && !!tab && mode == 'SUPP' && displayIcon('SUPP')" class="supplemental">

<div *ngIf="!!tab?.requirementsData?.supplementalInfo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,43 +164,44 @@ export class QuestionExtrasComponent implements OnInit {
})
}

async fetchDetails(): Promise<QuestionDetailsContentViewModel> {
const details = this.questionsSvc.getDetails(this.myQuestion.questionId, this.myQuestion.questionType).toPromise();
return details
}

/**
* Gets all of the extra content for the question from the API.
*/
show() {
async show() {
// we already have content - don't make another server call
if (this.tab != null) {
return;
}

// Call the API for content
this.questionsSvc.getDetails(this.myQuestion.questionId, this.myQuestion.questionType)
.subscribe((details) => {
this.extras = details;
this.extras.questionId = this.myQuestion.questionId;

// populate my details with the first "non-null" tab
this.tab = this.extras.listTabs?.find(t => t.requirementFrameworkTitle != null) ?? this.extras.listTabs[0];

// add questionIDs to related questions for debug if configured to do so
if (this.showQuestionIds) {
if (this.tab) {
if (this.tab.isComponent) {
} else {
if (!!this.tab.questionsList) {
this.tab.questionsList.forEach((q: any) => {
q.questionText += '<span class="debug-highlight">' + q.questionID + '</span>';
});
}
}
this.extras = await this.fetchDetails();
this.extras.questionId = this.myQuestion.questionId;

// populate my details with the first "non-null" tab
this.tab = this.extras.listTabs?.find(t => t.requirementFrameworkTitle != null) ?? this.extras.listTabs[0];

// add questionIDs to related questions for debug if configured to do so
if (this.showQuestionIds) {
if (this.tab) {
if (!this.tab.isComponent) {
if (!!this.tab.questionsList) {
this.tab.questionsList.forEach((q: any) => {
q.questionText += '<span class="debug-highlight">' + q.questionID + '</span>';
});
}
}
});

if (this.extras?.is_Component) {
this.myQuestion.is_Component = true;
this.toggleComponent = true;
}
}
if (this.extras.is_Component) {
this.myQuestion.is_Component = true;
this.toggleComponent = true;
this.mode = 'COMPONENT'
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions CSETWebNg/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,7 @@
"component type": "Component Type",
"override component answer": "Override Component Answer",
"override": "Override",
"override details": "The question currently displayed pertains to the specific component you previously selected to override.",
"none": "None",
"artifact title": "Artifact/Document Title",
"file name": "File Name",
Expand Down
1 change: 1 addition & 0 deletions CSETWebNg/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,7 @@
"component type": "Tipo de componente",
"override component answer": "Sobreescribir Respuesta",
"override": "Sobreescribir",
"override details": "La pregunta que se muestra actualmente pertenece al componente específico que usted seleccionó previamente para anular.",
"none": "No",
"artifact title": "Título del artefacto/documento",
"file name": "Nombre de archivo",
Expand Down
1 change: 1 addition & 0 deletions CSETWebNg/src/assets/i18n/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@
"component type": "Тип компоненту",
"override component answer": "Перевизначення відповіді компоненту",
"override": "Перевизначення",
"override details": "Запитання, яке зараз відображається, стосується конкретного компонента, який ви раніше вибрали для заміни.",
"none": "Жодного",
"artifact title": "Назва артефакту/документа",
"file name": "Ім'я файлу",
Expand Down

0 comments on commit 58fc723

Please sign in to comment.