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

Rework of Primary Assessor/Assessment Owner #4119

Merged
merged 4 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,17 @@ public string GetOtherRemarks(int assessmentId)
return "";
}

/// <summary>
/// Gets the userID that created the current assessment
/// </summary>
/// <returns>userID</returns>
public int? GetAssessmentCreator(int assessmentId)
{
var assessment = _context.ASSESSMENTS.FirstOrDefault(x => x.Assessment_Id == assessmentId);
return assessment?.AssessmentCreatorId;
}



/// <summary>
/// Persists OTHER-REMARKS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public interface IAssessmentBusiness
IList<string> GetNames(int id1, int id2, int? id3, int? id4, int? id5, int? id6, int? id7, int? id8, int? id9, int? id10);

string GetOtherRemarks(int assessmentId);

int? GetAssessmentCreator(int assessmentId);
void SaveOtherRemarks(int assessmentId, string remark);
void clearFirstTime(int userid, int assessmentId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,5 +488,24 @@ public IActionResult GetAssessmentDocuments([FromQuery] int id1, [FromQuery] int

return Ok(this._assessmentBusiness.GetAssessmentDocuments(id1, id2, id3, id4, id5, id6, id7, id8, id9, id10));
}

[HttpGet]
[Route("api/assessmentCreator")]
public IActionResult AssessmentCreator()
{
try
{
int assessmentId = _tokenManager.AssessmentForUser();
var creatorId = this._assessmentBusiness.GetAssessmentCreator((assessmentId));

return Ok(creatorId);
}
catch (Exception exc)
{
NLog.LogManager.GetCurrentClassLogger().Error($"... {exc}");
}

return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
[ngClass]="!showControls() ? 'bgc-primary-50 c-gray-900 b-primary-200' : 'b-light'"
style="width: 100%; height: 125px; overflow: hidden;">
<div class="p-3 d-flex flex-column justify-content-center align-items-start" style="flex: 0 0 25%">
<span class="m-0 fs-base-1 fw-600">{{contact.firstName}} {{contact.lastName}}</span>
<span class="m-0 text-center fs-base-1 fw-600">{{contact.firstName}} {{contact.lastName}}</span>
<span class="fs-small fw-400 fst-italic" *ngIf="contact.assessmentRoleId === 2">
({{getRoleName(contact.assessmentRoleId)}})
</span>
Expand All @@ -53,8 +53,8 @@
</div>
<span class="d-flex align-items-center m-3 fw-600" style="text-align: center;"
*ngIf="contact.isSiteParticipant">Participated<br />in Site Visit</span>
<span class="d-flex align-items-center m-3 fw-600" style="text-align: center;"
*ngIf="contact.isPrimaryPoc">Primary<br />Point of Contact</span>
<span class="d-flex align-items-center m-3 fw-600" style="text-align: center;">
</span>

<span *ngIf="showControls()" class="d-flex align-items-center flex-00a">
<button type="button" class="p-0 m-2 btn icon-button d-flex flex-column align-items-center flex-00a"
Expand All @@ -74,7 +74,15 @@
</button>
</span>

<span class="pe-3 fw-600" *ngIf="!showControls()">{{ t('contact.assessment owner') }}</span>
<span class="pe-4 text-center fw-300" *ngIf="!showControls()">
<ul>
<ol *ngIf="contact.isPrimaryPoc">Primary Point of Contact</ol>
<ol> <div *ngIf="creatorId == contact.userId; else Editor"> Assessment Creator </div>
<ng-template #Editor> Assessment Editor </ng-template>
</ol>
</ul>

</span>
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { ConfigService } from "../../../../../services/config.service";
import { EmailService } from "../../../../../services/email.service";
import { LayoutService } from "../../../../../services/layout.service";
import { TranslocoService } from "@ngneat/transloco";
import { DemographicIodService } from "../../../../../services/demographic-iod.service";

@Component({
selector: "app-contact-item",
Expand Down Expand Up @@ -66,6 +67,7 @@ export class ContactItemComponent implements OnInit {
results: EditableUser[];
roles: Role[];
editMode: boolean;
creatorId: any;


constructor(
Expand All @@ -75,7 +77,8 @@ export class ContactItemComponent implements OnInit {
private assessSvc: AssessmentService,
private dialog: MatDialog,
public layoutSvc: LayoutService,
public tSvc: TranslocoService
public tSvc: TranslocoService,
public demoSvc: DemographicIodService
) {
this.editMode = true;
}
Expand All @@ -96,6 +99,7 @@ export class ContactItemComponent implements OnInit {
if (this.contact.evaluateCanEdit) {
this.editMode = this.contact.evaluateCanEdit();
}
this.assessmentCreator()
}

isEmailValid() {
Expand Down Expand Up @@ -267,4 +271,10 @@ export class ContactItemComponent implements OnInit {
scrollToTop() {
this.topScroll?.nativeElement.scrollIntoView({ behavior: 'smooth', alignToTop: true });
}
// Check if assessment was created by current user
assessmentCreator(){
this.assessSvc.getCreator().then((response: any) => {
this.creatorId = response
})
}
}
12 changes: 12 additions & 0 deletions CSETWebNg/src/app/services/assessment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export class AssessmentService {
*/
public isBrandNew = false;

public assessmentCreator: any;

/**
*
*/
Expand Down Expand Up @@ -237,6 +239,16 @@ export class AssessmentService {
});
}

getCreator(){
return this.http
.get(this.apiUrl + 'assessmentcreator')
.toPromise()
.then((response: any) => {
this.assessmentCreator = response;
return response;
});
}

/**
*
*/
Expand Down