Skip to content

Commit

Permalink
wfprev-219 fiscal info on project detail apge (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
yzlucas authored Feb 4, 2025
1 parent 8e03142 commit 1b02446
Show file tree
Hide file tree
Showing 21 changed files with 716 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,15 @@ describe('EditProjectComponent', () => {
expect(mockCanDeactivate).toHaveBeenCalled();
});

it('should call refreshFiscalData when switching back to Details tab', () => {
// Mock the ProjectDetailsComponent and its method
component.projectDetailsComponent = jasmine.createSpyObj('ProjectDetailsComponent', ['refreshFiscalData']);

// Simulate selecting the "Details" tab (index 0)
component.onTabChange({ index: 0 });

// Expect refreshFiscalData to have been called
expect(component.projectDetailsComponent.refreshFiscalData).toHaveBeenCalled();
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import { CanComponentDeactivate } from 'src/app/services/util/can-deactive.guard
export class EditProjectComponent implements CanComponentDeactivate {
projectName: string | null = null;
@ViewChild('fiscalsContainer', { read: ViewContainerRef }) fiscalsContainer!: ViewContainerRef;
@ViewChild(ProjectDetailsComponent) projectDetailsComponent!: ProjectDetailsComponent;

projectFiscalsComponentRef: ComponentRef<any> | null = null;

constructor() {}

onTabChange(event: any): void {
// Check if "Fiscal Years" tab is selected
if (event.index === 1 && !this.projectFiscalsComponentRef) {
Expand All @@ -29,6 +30,8 @@ export class EditProjectComponent implements CanComponentDeactivate {
this.projectFiscalsComponentRef.instance.loadProjectFiscals();
}
);
} else if (event.index === 0) {
this.projectDetailsComponent.refreshFiscalData();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<div>
<mat-expansion-panel #panel="matExpansionPanel">
<mat-expansion-panel-header class="expansion-panel-header">
<mat-panel-title class="project-title">
<div class="custom-indicator">
<img
*ngIf="!panel.expanded"
src="/assets/collapsed-indicator.svg"
alt="Collapsed Icon"
class="indicator-icon"
/>
<img
*ngIf="panel.expanded"
src="/assets/expanded-indicator.svg"
alt="Expanded Icon"
class="indicator-icon"
/>
</div>
<span>Fiscal Years</span>
</mat-panel-title>
</mat-expansion-panel-header>
<div class="fiscals-content" *ngIf="projectFiscals?.length; else emptyContent">
<div *ngFor="let fiscal of projectFiscals" class="fiscal-item">
<div class="fiscal-title-row">
<span class="section-1">{{fiscal.projectFiscalName}}</span>
<span class="section-2"> Fiscal Year:
<span class="fiscal-year">{{convertFiscalYear(fiscal.fiscalYear)}}</span>
</span>
<span class="section-3">
<img
[src]="'/assets/' + getStatusIcon(fiscal.planFiscalStatusCode)"
[alt]="getPlanFiscalStatus(fiscal.planFiscalStatusCode)"
class="status-icon"
/>
{{getPlanFiscalStatus(fiscal.planFiscalStatusCode)}}
</span>
</div>
<div class="fiscal-data" *ngIf="fiscal.planFiscalStatusCode != 'COMPLETE'; else completeFiscal">
<span class="data-title">Planned Ha:
<span class="data-value">{{ fiscal.fiscalPlannedProjectSizeHa | number }}</span>
</span>

<span class="data-title">Cost Estimate:
<span class="data-value">${{ fiscal.totalCostEstimateAmount | number }}</span>
</span>

<span class="data-title">Last Performance Update:
<span class="data-value">{{ fiscal.lastProgressUpdateTimestamp || 'N/A'}}</span>
</span>
</div>
<ng-template #completeFiscal>
<div class="fiscal-data">
<span class="data-title">Complete Ha:
<span class="data-value">{{ fiscal.fiscalPlannedProjectSizeHa | number }}</span>
</span>

<span class="data-title">Reported Spend:
<span class="data-value">${{ fiscal.fiscalReportedSpendAmount | number }}</span>
</span>

<span class="data-title">Actual Spend(CFS):
<span class="data-value">${{ fiscal.fiscalActualAmount | number }}</span>
</span>
<div class="complete-fiscal-last-performance-update">
<span class="data-title">Last Performance Update:
<span class="data-value">{{ fiscal.lastProgressUpdateTimestamp || 'N/A'}}</span>
</span>
</div>
</div>
</ng-template>
<div class="activities-content">
<div class="title">Activities</div>

<!-- Show Table 1 when status is COMPLETE -->
<table mat-table [dataSource]="activities" class="activities-table" *ngIf="fiscal.planFiscalStatusCode === 'COMPLETE'">
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef> Name </th>
<td mat-cell *matCellDef="let activity"> {{ activity.name }} </td>
</ng-container>

<ng-container matColumnDef="description">
<th mat-header-cell *matHeaderCellDef> Description </th>
<td mat-cell *matCellDef="let activity"> {{ activity.description }} </td>
</ng-container>

<ng-container matColumnDef="endDate">
<th mat-header-cell *matHeaderCellDef> End Date </th>
<td mat-cell *matCellDef="let activity"> {{ activity.endDate | date:'yyyy-MM-dd' }} </td>
</ng-container>

<ng-container matColumnDef="completedHectares">
<th mat-header-cell *matHeaderCellDef> Completed Hectares </th>
<td mat-cell *matCellDef="let activity"> {{ activity.completedHectares | number }} </td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="displayedColumnsComplete"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumnsComplete;"></tr>
</table>

<!-- Show Table 2 when status is NOT COMPLETE -->
<table mat-table [dataSource]="activities" class="activities-table" *ngIf="fiscal.planFiscalStatusCode !== 'COMPLETE'">
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef> Name </th>
<td mat-cell *matCellDef="let activity"> {{ activity.name }} </td>
</ng-container>

<ng-container matColumnDef="description">
<th mat-header-cell *matHeaderCellDef> Description </th>
<td mat-cell *matCellDef="let activity"> {{ activity.description }} </td>
</ng-container>

<ng-container matColumnDef="startDate">
<th mat-header-cell *matHeaderCellDef> Start Date </th>
<td mat-cell *matCellDef="let activity"> {{ activity.startDate | date:'yyyy-MM-dd' }} </td>
</ng-container>

<ng-container matColumnDef="endDate">
<th mat-header-cell *matHeaderCellDef> End Date </th>
<td mat-cell *matCellDef="let activity"> {{ activity.endDate | date:'yyyy-MM-dd' }} </td>
</ng-container>

<ng-container matColumnDef="plannedHectares">
<th mat-header-cell *matHeaderCellDef> Planned Hectares </th>
<td mat-cell *matCellDef="let activity"> {{ activity.plannedHectares | number }} </td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="displayedColumnsPlanned"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumnsPlanned;"></tr>
</table>
</div>


</div>
</div>
<ng-template #emptyContent>
<div class="fiscal-empty-content">
No Fiscal Years have been added.
</div>
</ng-template>
</mat-expansion-panel>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
mat-expansion-panel {
border-bottom: 1px solid #C6C8CB;
margin: 0px !important;
background-color: #FFF;

::ng-deep .mat-expansion-panel-body{
padding: 0;
}

.project-title {
background-color: inherit;
font-weight: bold;
display: flex;
color: #000;
font-size: 20px;
font-style: normal;
font-weight: 400;
line-height: normal;
gap:10px;
}
}
.fiscals-content{
padding: 0 10px;
border-top: 1px solid #D9D9D9;
.fiscal-item{
padding: 10px;
border-radius: 10px;
border: 1px solid #DFE0E2;
background: #FFF;
margin: 20px 0;
}
.fiscal-title-row{
display: flex;
.section-1 {
flex: 0 0 65%;
display: flex;
flex-shrink: 0;
color: #000;
font-size: 20px;
font-style: normal;
font-weight: 700;
line-height: normal;
}
.section-2{
flex:1;
color: #000;
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: normal;
.fiscal-year{
font-size: 16px;
font-weight: 700;
}
}
.section-3 {
gap: 3px;
color: #474543;
font-size: 16px;
font-style: normal;
font-weight: 700;
flex: 1;
.status-icon{
width: 25px;
height: 25px;
vertical-align: middle;
}
}
}

.fiscal-data{
padding-top: 16px;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
.data-title{
color: #000;
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: normal;
}
.data-value{
color: #282828;
font-size: 16px;
font-weight: 700;
}
span:nth-child(1) {
flex: 3; // 30% of the row
}

span:nth-child(2) {
flex: 3; // 30% of the row
}

span:nth-child(3) {
flex: 4; // 40% of the row
}
.complete-fiscal-last-performance-update{
flex: 1 1 100%;
padding-top: 10px;
}
}

.activities-content{
padding-top: 10px;
.title{
color: #000;
font-size: 16px;
font-style: normal;
font-weight: 400;
line-height: normal;
}
.activities-table {
width: 100%;
border-collapse: collapse;

th, td {
padding: 8px;
border-bottom: 1px solid #ddd;
}

th {
color: #000;
font-size: 12px;
font-style: normal;
font-weight: 400;
line-height: normal;
background-color: var(--colour-white);
}

tr:nth-child(odd) {
border: 1px solid #D9D9D9;
background: var(--colour-light-grey);
}

tr:nth-child(even) {
border: 1px solid #D9D9D9;
background-color: var(--colour-white);
}
}
}
}
.fiscal-empty-content{
color: #242424;
font-family: var(--wf-font-family-main);
font-size: 16px;
font-style: italic;
font-weight: 400;
line-height: normal;
padding: 20px;
}
Loading

0 comments on commit 1b02446

Please sign in to comment.