Skip to content

Commit

Permalink
Took out extra date pipe, more date translations
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrwins committed Nov 6, 2023
1 parent 45a44ed commit 43313b1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ <h2 class="mt-0" *ngIf="sortedAssessments?.length == 0">
</th>
<th *ngIf="isTSA" style="width: 5%;">Source</th>
<th aria-label="{{ t('assessment type')}}" mat-sort-header="type" style="width:15%;">{{ t('assessment type')}}</th>
<th *ngIf="showColumn('ise-submitted')" aria-label="ise-submitted">{{ t('acet.submitted') }}</th>
<th *ngIf="showColumn('ise-submitted')" mat-sort-header="ise-submitted" aria-label="ise-submitted">{{ t('acet.submitted') }}</th>
<th aria-label="{{ t('last modified')}}" mat-sort-header="date" style="width:15%;">{{ t('last modified')}}</th>
<th *ngIf="showColumn('primary-assessor')" aria-label="assessor" mat-sort-header="assessor"
style="width:15%;">{{t('primary assessor')}}</th>
<th aria-label="{{t('status')}}" mat-sort-header="{{t('status')}}" style="width:15%;">{{t('status')}}</th>
<th aria-label="{{t('status')}}" mat-sort-header="status" style="width:15%;">{{t('status')}}</th>
<th aria-label="delete assessment" style="width:5%; min-width:25px;"></th>
<th aria-label="export assessment" style="width:5%;"></th>
<th aria-label="Analytics" style="width:5%;" *ngIf="showColumn('analytics')"></th>
Expand All @@ -210,10 +210,10 @@ <h2 class="mt-0" *ngIf="sortedAssessments?.length == 0">
'CSET' :
'TSA' }}</td>
<td>{{assessment.type}}</td>
<td *ngIf="!this.ncuaSvc.switchStatus">{{this.systemTimeTranslator(assessment.lastModifiedDate)
| date:'dd-MMM-yyyy'}}</td>
<td *ngIf="!this.ncuaSvc.switchStatus">{{reportSvc.translatedDate(assessment.lastModifiedDate)}}</td>
<td *ngIf="showColumn('ise-submitted')">
<ng-container *ngIf="assessment.iseSubmitted">{{ assessment.submittedDate | date: 'M/dd/yy' }}</ng-container>
<!-- <ng-container *ngIf="assessment.iseSubmitted">{{ assessment.submittedDate | date: 'M/dd/yy' }}</ng-container> -->
<ng-container *ngIf="assessment.iseSubmitted">{{ assessSvc.translatedDate(assessment.submittedDate, 'l') }}</ng-container>
</td>
<td *ngIf="this.ncuaSvc.switchStatus">{{systemTimeTranslator(assessment.lastModifiedDate)}}</td>

Expand Down Expand Up @@ -279,7 +279,7 @@ <h2 class="mt-0" *ngIf="sortedAssessments?.length == 0">
{{assessment.assessmentName}}
</button>
</td>
<td>{{assessment.lastModifiedDate | date:'dd-MMM-yyyy'}}</td>
<td>{{systemTimeTranslator(assessment.lastModifiedDate)}}</td>
<td class="text-nowrap pl-1">
<button tabindex="0" class="icon-link-button-dark btn bgc-trans my-0 mx-1 p-0"
(click)="removeAssessment(assessment, i)"
Expand Down Expand Up @@ -313,7 +313,7 @@ <h2 class="mt-0" *ngIf="sortedAssessments?.length == 0">
</button>
</td>
<td>{{assessment.type}}</td>
<td>{{assessment.lastModifiedDate | date:'medium'}}</td>
<td>{{systemTimeTranslator(assessment.lastModifiedDate)}}</td>
<td>
<div *ngIf="assessment.selectedMaturityModel != 'CIS'">
<span *ngIf="assessment.totalAvailableQuestionsCount > 0; else blankAssessment">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ export class MyAssessmentsComponent implements OnInit {
private ncuaSvc: NCUAService,
public layoutSvc: LayoutService,
public dateAdapter: DateAdapter<any>,
public datePipe: DatePipe
public datePipe: DatePipe,
public reportSvc: ReportService
) { }

ngOnInit() {
Expand Down
15 changes: 14 additions & 1 deletion CSETWebNg/src/app/services/assessment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import { Router } from '@angular/router';
import { NavigationService } from './navigation/navigation.service';
import { Observable } from 'rxjs';
import { DemographicExtendedService } from './demographic-extended.service';
import moment from 'moment';
import { TranslocoService } from '@ngneat/transloco';


export interface Role {
Expand Down Expand Up @@ -85,7 +87,8 @@ export class AssessmentService {
private http: HttpClient,
private configSvc: ConfigService,
private router: Router,
private extDemoSvc: DemographicExtendedService
private extDemoSvc: DemographicExtendedService,
private tSvc: TranslocoService
) {
if (!this.initialized) {
this.apiUrl = this.configSvc.apiUrl;
Expand Down Expand Up @@ -619,4 +622,14 @@ export class AssessmentService {
getEncryptPreference() {
return this.http.get(this.apiUrl + 'getPreventEncrypt');
}

/**
* changes a date into the active Transloco locale format
* @param date
* @returns
*/
translatedDate(date: string, format: string) {
moment.locale(this.tSvc.getActiveLang());
return moment(date).format(format);
}
}

0 comments on commit 43313b1

Please sign in to comment.