From 42c2816e58eb467a337b5ca39a20ca47004fd4dc Mon Sep 17 00:00:00 2001 From: Natalie Hergesheimer Date: Thu, 19 Dec 2024 16:34:36 -0700 Subject: [PATCH 1/2] Don't display override options if the question itself is an override question --- .../Question/QuestionDetails.cs | 2 + .../Question/QuestionDetailsBusiness.cs | 18 +++++-- .../question-extras.component.html | 3 +- .../question-extras.component.ts | 51 ++++++++++--------- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Question/QuestionDetails.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Question/QuestionDetails.cs index e4efbbf7f4..ec06dc629b 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Question/QuestionDetails.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Question/QuestionDetails.cs @@ -39,6 +39,8 @@ public class QuestionDetails public bool IsDetailAndInfo { get; set; } + + public bool? overRide { get; set; } /// diff --git a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Question/QuestionDetailsBusiness.cs b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Question/QuestionDetailsBusiness.cs index 5ebee9e387..02dfdb0f04 100644 --- a/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Question/QuestionDetailsBusiness.cs +++ b/CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Question/QuestionDetailsBusiness.cs @@ -18,6 +18,7 @@ using System; using System.Collections.Generic; using System.Linq; +using NPOI.SS.Formula.Functions; namespace CSETWebCore.Business.Question { @@ -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() diff --git a/CSETWebNg/src/app/assessment/questions/question-extras/question-extras.component.html b/CSETWebNg/src/app/assessment/questions/question-extras/question-extras.component.html index 0ba79cc477..ab6300f48f 100644 --- a/CSETWebNg/src/app/assessment/questions/question-extras/question-extras.component.html +++ b/CSETWebNg/src/app/assessment/questions/question-extras/question-extras.component.html @@ -169,7 +169,7 @@
-
+
@@ -190,6 +190,7 @@
{{t('extras.component type')}}
+
{{t('extras.override details')}}
{ + 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 += '' + q.questionID + ''; - }); - } - } + 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 += '' + q.questionID + ''; + }); } } - }); - - 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' + } } /** From b0f05772963abe3ee43dd87409cc7a56d7abab98 Mon Sep 17 00:00:00 2001 From: Natalie Hergesheimer Date: Thu, 19 Dec 2024 16:34:49 -0700 Subject: [PATCH 2/2] Translation text --- CSETWebNg/src/assets/i18n/en.json | 1 + CSETWebNg/src/assets/i18n/es.json | 1 + CSETWebNg/src/assets/i18n/uk.json | 1 + 3 files changed, 3 insertions(+) diff --git a/CSETWebNg/src/assets/i18n/en.json b/CSETWebNg/src/assets/i18n/en.json index a1535dabcc..d6724e8137 100644 --- a/CSETWebNg/src/assets/i18n/en.json +++ b/CSETWebNg/src/assets/i18n/en.json @@ -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", diff --git a/CSETWebNg/src/assets/i18n/es.json b/CSETWebNg/src/assets/i18n/es.json index d1319b1bfc..f036491d1e 100644 --- a/CSETWebNg/src/assets/i18n/es.json +++ b/CSETWebNg/src/assets/i18n/es.json @@ -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", diff --git a/CSETWebNg/src/assets/i18n/uk.json b/CSETWebNg/src/assets/i18n/uk.json index 6d2ce7f85d..ae960f71d3 100644 --- a/CSETWebNg/src/assets/i18n/uk.json +++ b/CSETWebNg/src/assets/i18n/uk.json @@ -983,6 +983,7 @@ "component type": "Тип компоненту", "override component answer": "Перевизначення відповіді компоненту", "override": "Перевизначення", + "override details": "Запитання, яке зараз відображається, стосується конкретного компонента, який ви раніше вибрали для заміни.", "none": "Жодного", "artifact title": "Назва артефакту/документа", "file name": "Ім'я файлу",