Skip to content

Commit

Permalink
Merge pull request #3731 from cisagov/feature/acet768
Browse files Browse the repository at this point in the history
Feature/acet768
  • Loading branch information
Marcus-Goectau authored Feb 7, 2024
2 parents 368c036 + bad2b6e commit ffac551
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 110 deletions.
28 changes: 14 additions & 14 deletions CSETWebNg/src/app/assessment/questions/issues/issues.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ <h2 style="color: white;">Issues</h2>
<div class="form-group">
<label id="titleLabel" for="title" class="form-label font-weight-bold">Title</label>
<input id="title" type="text" autocomplete="off" class="form-control" [disabled]="true"
[(ngModel)]="finding.title">
[(ngModel)]="observation.title">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="issueType" class="form-label font-weight-bold">Issue Type</label>
<span style="color: red;">*</span><span style="color: red; font-size: 10px;" *ngIf="this.showRequiredHelper">
(required)</span>
<select name="issueType" id="issueType" class="form-control" [(ngModel)]="finding.type" required>
<select name="issueType" id="issueType" class="form-control" [(ngModel)]="observation.type" required>
<option value="Examiner Finding">Examiner Finding</option>
<option value="DOR">DOR</option>
<option value="Supplemental Fact">Supplemental Fact</option>
Expand All @@ -55,19 +55,19 @@ <h2 style="color: white;">Issues</h2>
</div>
</div>
</div>
<div class="row" *ngIf="finding.type !== 'Supplemental Fact'">
<div class="row" *ngIf="observation.type !== 'Supplemental Fact'">
<div class="col-6">
<div class="form-group">
<label for="riskArea" class="form-label font-weight-bold">Risk Area</label>
<input id="riskArea" type="text" autocomplete="off" class="form-control" [disabled]="true"
[(ngModel)]="finding.risk_Area">
[(ngModel)]="observation.risk_Area">
</div>
</div>
<div class="col-6">
<div class="form-group">
<label for="subriskArea" class="form-label font-weight-bold">Sub Risk</label>
<input id="subRisk" type="text" autocomplete="off" class="form-control" [disabled]="true"
[(ngModel)]="finding.sub_Risk">
[(ngModel)]="observation.sub_Risk">
</div>
</div>
</div>
Expand All @@ -76,32 +76,32 @@ <h2 style="color: white;">Issues</h2>
<div *ngIf="this.actionItems != null" class="form-group">
<label for="description" class="form-label font-weight-bold">Description</label>
<textarea id="description" type="text" rows="5" autocomplete="off" class="form-control"
[(ngModel)]="finding.description"></textarea>
[(ngModel)]="observation.description"></textarea>
</div>
</div>
</div>
<ng-container *ngIf="finding.type === 'Supplemental Fact'">
<ng-container *ngIf="observation.type === 'Supplemental Fact'">
<div class="row">
<div class="col-12">
<div class="form-group">
<label for="suppGuide" class="form-label font-weight-bold">Supplemental Fact</label>
<textarea id="suppGuide" type="text" rows="10" autocomplete="off" class="form-control"
[(ngModel)]="finding.supp_Guidance"></textarea>
[(ngModel)]="observation.supp_Guidance"></textarea>
</div>
</div>
</div>
</ng-container>
<ng-container *ngIf="finding.type !== 'Supplemental Fact'">
<div *ngIf="this.finding.auto_Generated === 0">
<ng-container *ngIf="observation.type !== 'Supplemental Fact'">
<div *ngIf="this.observation.auto_Generated === 0">
<div class="row">
<div class="col-12">
<label for="manual-actions" class="form-label font-weight-bold">Action Items</label>
<textarea id="manual-actions" type="text" rows="5" autocomplete="off" class="form-control"
[(ngModel)]="finding.actionItems"></textarea>
[(ngModel)]="observation.actionItems"></textarea>
</div>
</div>
</div>
<div *ngIf="this.finding.auto_Generated === 1">
<div *ngIf="this.observation.auto_Generated === 1">
<div class="mt-2 invalid-feedback d-block text-muted">
<p>Items marked in red indicate a higher level of risk</p>
</div>
Expand Down Expand Up @@ -146,7 +146,7 @@ <h2 style="color: white;">Issues</h2>
<div class="form-group">
<label for="additionalCitations" class="form-label font-weight-bold">Additional Citations</label>
<input id="additionalCitations" type="text" autocomplete="off" class="form-control"
[(ngModel)]="finding.citations">
[(ngModel)]="observation.citations">
</div>
</div>
</div>
Expand All @@ -155,7 +155,7 @@ <h2 style="color: white;">Issues</h2>
</mat-dialog-content>

<mat-dialog-actions class="p-3 mb-0">
<button style="margin-left: 0%;" [disabled]="finding.auto_Generated == 1 || !isIssueEmpty()" mat-button
<button style="margin-left: 0%;" [disabled]="observation.auto_Generated == 1 || !isIssueEmpty()" mat-button
class="btn btn-secondary" (click)="cancel()">Cancel</button>

<button style="margin-left: auto;" mat-button class="btn btn-primary" (click)="update()">Done</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,27 +199,27 @@
<th style="width:5%;"></th>
<th style="width:5%;"></th>
</tr>
<tr *ngFor="let find of extras?.observations; let i = index"
<tr *ngFor="let obs of extras?.observations; let i = index"
style="box-sizing: content-box;height:20px;">
<td>
<div>Issue {{ i+1 }}</div>
</td>
<td style="height:20px">
<div>{{find.title}}</div>
<div>{{obs.title}}</div>
</td>
<td style="text-align: center">
<div *ngIf="find.auto_Generated === 1">Yes</div>
<div *ngIf="find.auto_Generated === 0"> - </div>
<div *ngIf="obs.auto_Generated === 1">Yes</div>
<div *ngIf="obs.auto_Generated === 0"> - </div>
</td>
<td>
<button class="icon-button fs-base cursor-pointer" aria-label="Edit"
(click)="addEditIssue(q.parentQuestionId, find.finding_Id)">
(click)="addEditIssue(q.parentQuestionId, obs.observation_Id)">
<span class="mr-1 cset-icons-pencil"></span>
</button>
</td>
<td>
<button class="icon-button fs-base cursor-pointer" aria-label="Delete"
(click)="deleteIssue(find.finding_Id, false)">
(click)="deleteIssue(obs.observation_Id, false)">
<span class="mr-1 cset-icons-trash-can"></span>
</button>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ export class QuestionBlockIseComponent implements OnInit {
this.extras = details;
this.extras.questionId = this.myGrouping.questions[0].questionId;

this.extras.observations.forEach(find => {
if (find.auto_Generated === 1) {
find.question_Id = this.myGrouping.questions[0].questionId;
this.extras.observations.forEach(obs => {
if (obs.auto_Generated === 1) {
obs.question_Id = this.myGrouping.questions[0].questionId;

// This is a check for post-merging ISE assessments.
// If an issue existed, but all answers were changed to "Yes" on merge, delete the issue.
if (this.ncuaSvc.questionCheck.get(find.question_Id) !== undefined) {
this.ncuaSvc.issueFindingId.set(find.question_Id, find.observation_Id);
if (this.ncuaSvc.questionCheck.get(obs.question_Id) !== undefined) {
this.ncuaSvc.issueObservationId.set(obs.question_Id, obs.observation_Id);
} else {
this.deleteIssue(find.observation_Id, true);
this.deleteIssue(obs.observation_Id, true);
}

}
Expand Down Expand Up @@ -225,15 +225,15 @@ export class QuestionBlockIseComponent implements OnInit {
});
}

deleteIssueMaps(findingId: number) {
const iterator = this.ncuaSvc.issueFindingId.entries();
deleteIssueMaps(observation: number) {
const iterator = this.ncuaSvc.issueObservationId.entries();
let parentKey = 0;

for (let value of iterator) {
if (value[1] === findingId) {
if (value[1] === observation) {
parentKey = value[0];
this.ncuaSvc.questionCheck.delete(parentKey);
this.ncuaSvc.issueFindingId.delete(parentKey);
this.ncuaSvc.issueObservationId.delete(parentKey);
this.ncuaSvc.deleteHistory.add(parentKey);
}
}
Expand Down Expand Up @@ -338,7 +338,7 @@ export class QuestionBlockIseComponent implements OnInit {
value++;
this.ncuaSvc.questionCheck.set(q.parentQuestionId, value);

if (value >= 1 && !this.ncuaSvc.issueFindingId.has(q.parentQuestionId)) {
if (value >= 1 && !this.ncuaSvc.issueObservationId.has(q.parentQuestionId)) {
if (!this.ncuaSvc.deleteHistory.has(q.parentQuestionId)) {
this.autoGenerateIssue(q.parentQuestionId, 0);
}
Expand All @@ -348,10 +348,10 @@ export class QuestionBlockIseComponent implements OnInit {
if (value < 1) {
this.ncuaSvc.questionCheck.delete(q.parentQuestionId);

if (this.ncuaSvc.issueFindingId.has(q.parentQuestionId)) {
let findId = this.ncuaSvc.issueFindingId.get(q.parentQuestionId);
this.ncuaSvc.issueFindingId.delete(q.parentQuestionId);
this.deleteIssue(findId, true);
if (this.ncuaSvc.issueObservationId.has(q.parentQuestionId)) {
let observationId = this.ncuaSvc.issueObservationId.get(q.parentQuestionId);
this.ncuaSvc.issueObservationId.delete(q.parentQuestionId);
this.deleteIssue(observationId, true);
}
} else {
this.ncuaSvc.questionCheck.set(q.parentQuestionId, value);
Expand Down Expand Up @@ -741,9 +741,9 @@ export class QuestionBlockIseComponent implements OnInit {

/**
*
* @param findid
* @param observationid
*/
addEditIssue(parentId, findid) {
addEditIssue(parentId, observationId) {
/*
* Per the customer's requests, an Issue's title should include the main
* grouping header text and the sub grouping header text.
Expand All @@ -758,11 +758,11 @@ export class QuestionBlockIseComponent implements OnInit {
name = ("Cybersecurity Controls, " + this.myGrouping.title);
}

const find: Observation = {
const observation: Observation = {
question_Id: parentId,
questionType: this.myGrouping.questions[0].questionType,
answer_Id: this.myGrouping.questions[0].answer_Id,
observation_Id: findid,
observation_Id: observationId,
summary: '',
observation_Contacts: null,
impact: '',
Expand All @@ -784,28 +784,28 @@ export class QuestionBlockIseComponent implements OnInit {
};

this.dialog.open(IssuesComponent, {
data: find,
data: observation,
disableClose: true,
}).afterClosed().subscribe(result => {
let stringResult = result.toString();
if (stringResult != 'true') {
find.observation_Id = result;
observation.observation_Id = result;

this.observationSvc.saveObservation(find, true).subscribe((r: any) => {
this.observationSvc.saveObservation(observation, true).subscribe((r: any) => {
this.myGrouping.questions[0].hasObservation = (this.extras.observations.length > 0);
this.myGrouping.questions[0].answer_Id = find.answer_Id;
this.myGrouping.questions[0].answer_Id = observation.answer_Id;
});

}
else {
const answerID = find.answer_Id;
const answerID = observation.answer_Id;
// if (result == true) {
this.observationSvc.getAllObservations(answerID).subscribe(

(response: Observation[]) => {
this.extras.observations = response;
this.myGrouping.questions[0].hasObservation = (this.extras.observations.length > 0);
this.myGrouping.questions[0].answer_Id = find.answer_Id;
this.myGrouping.questions[0].answer_Id = observation.answer_Id;
}
),

Expand All @@ -816,20 +816,19 @@ export class QuestionBlockIseComponent implements OnInit {

}

isIssueEmpty(finding: Observation) {
if (finding.actionItems == null
&& finding.citations == null
&& finding.description == null
&& finding.issue == null
&& finding.type == null) {
isIssueEmpty(observation: Observation) {
if (observation.actionItems == null
&& observation.citations == null
&& observation.description == null
&& observation.issue == null
&& observation.type == null) {
return true;
}
return false;
}

// ISE "issues" should be generated if an examiner answers 'No' to
// 2 or more important questions with no popup.
autoGenerateIssue(parentId, findId) {
autoGenerateIssue(parentId, observationId) {
let name = "";
let desc = "";

Expand All @@ -839,16 +838,16 @@ export class QuestionBlockIseComponent implements OnInit {
name = ("Cybersecurity Controls, " + this.myGrouping.title);
}

this.questionsSvc.getActionItems(parentId, findId).subscribe(
this.questionsSvc.getActionItems(parentId, observationId).subscribe(
(data: any) => {
// Used to generate a description for ISE reports even if a user doesn't open the issue.
desc = data[0]?.description;

const find: Observation = {
const obs: Observation = {
question_Id: parentId,
questionType: this.myGrouping.questions[0].questionType,
answer_Id: this.myGrouping.questions[0].answer_Id,
observation_Id: findId,
observation_Id: observationId,
summary: '',
observation_Contacts: null,
impact: '',
Expand All @@ -869,20 +868,20 @@ export class QuestionBlockIseComponent implements OnInit {
supp_Guidance: null
};

this.ncuaSvc.issueFindingId.set(parentId, findId);
this.ncuaSvc.issueObservationId.set(parentId, observationId);

this.observationSvc.saveObservation(find).subscribe(() => {
const answerID = find.answer_Id;
this.observationSvc.saveObservation(obs).subscribe(() => {
const answerID = obs.answer_Id;
this.observationSvc.getAllObservations(answerID).subscribe(
(response: Observation[]) => {
for (let i = 0; i < response.length; i++) {
if (response[i].auto_Generated === 1) {
this.ncuaSvc.issueFindingId.set(parentId, response[i].observation_Id);
this.ncuaSvc.issueObservationId.set(parentId, response[i].observation_Id);
}
}
this.extras.observations = response;
this.myGrouping.questions[0].hasObservation = (this.extras.observations.length > 0);
this.myGrouping.questions[0].answer_Id = find.answer_Id;
this.myGrouping.questions[0].answer_Id = obs.answer_Id;
},
error => console.log('Error updating observations | ' + (<Error>error).message)
);
Expand Down
Loading

0 comments on commit ffac551

Please sign in to comment.