-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'P2-903-Tracking-of-outcomes-achievements-against-target…
…s' into dev
- Loading branch information
Showing
58 changed files
with
1,811 additions
and
204 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
onecgiar-pr-client/src/app/pages/outcome-indicator/outcome-indicator.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,27 @@ | ||
<div class="local_container section_container"> | ||
<div class="filters"> | ||
<app-pr-select | ||
[options]="this.api.rolesSE.isAdmin ? this.allInitiatives : this.api.dataControlSE.myInitiativesList" | ||
label="Initiative" | ||
[required]="false" | ||
[isStatic]="true" | ||
optionLabel="full_name" | ||
optionValue="official_code" | ||
placeholder="Select Initiative" | ||
labelDescInlineStyles="color: #5569dd" | ||
[(ngModel)]="this.outcomeIService.initiativeIdFilter" | ||
(ngModelChange)="handleInitiativeChange()"> | ||
</app-pr-select> | ||
|
||
<div class="filters_phase"> | ||
<p class="filters_phase_title">Phase:</p> | ||
<p class="filters_phase_text"> | ||
{{ this.api.dataControlSE.reportingCurrentPhase.phaseName }} | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<div class="separator_line"></div> | ||
|
||
<router-outlet></router-outlet> | ||
</div> |
40 changes: 40 additions & 0 deletions
40
onecgiar-pr-client/src/app/pages/outcome-indicator/outcome-indicator.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,46 @@ | ||
.local_container { | ||
margin-top: 20px !important; | ||
margin-bottom: 20px !important; | ||
padding: 0px 40px; | ||
padding-top: 15px !important; | ||
padding-bottom: 50px; | ||
} | ||
|
||
p { | ||
margin: 0; | ||
} | ||
|
||
.filters { | ||
display: grid; | ||
grid-template-columns: 1fr 300px; | ||
gap: 2rem; | ||
padding: 0; | ||
|
||
.filters_phase { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
justify-content: flex-start; | ||
|
||
.filters_phase_title { | ||
margin-top: 20px; | ||
margin-bottom: 7px; | ||
text-align: left; | ||
font-size: 1.1em; | ||
font-weight: 500; | ||
color: #5569dd; | ||
} | ||
|
||
.filters_phase_text { | ||
padding: 6px 0; | ||
font-size: 15px; | ||
} | ||
} | ||
} | ||
|
||
.separator_line { | ||
margin-top: 20px; | ||
margin-bottom: 20px; | ||
border-top: 2px solid #5569dd; | ||
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 81 additions & 3 deletions
84
onecgiar-pr-client/src/app/pages/outcome-indicator/outcome-indicator.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,86 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { ApiService } from '../../shared/services/api/api.service'; | ||
import { OutcomeIndicatorService } from './services/outcome-indicator.service'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
|
||
@Component({ | ||
selector: 'app-outcome-indicator-module', | ||
templateUrl: './outcome-indicator.component.html', | ||
styleUrl: './outcome-indicator.component.scss' | ||
styleUrls: ['./outcome-indicator.component.scss'] | ||
}) | ||
export class OutcomeIndicatorComponent {} | ||
export class OutcomeIndicatorComponent implements OnInit { | ||
readonly QUERY_PARAM_INITIATIVE = 'init'; | ||
allInitiatives: any[] = []; | ||
|
||
constructor( | ||
public api: ApiService, | ||
public outcomeIService: OutcomeIndicatorService, | ||
public activatedRoute: ActivatedRoute, | ||
public router: Router | ||
) {} | ||
|
||
ngOnInit(): void { | ||
this.initializeComponent(); | ||
} | ||
|
||
async initializeComponent(): Promise<void> { | ||
this.api.dataControlSE.getCurrentPhases(); | ||
|
||
if (this.api.rolesSE.isAdmin) { | ||
await this.loadAllInitiatives(); | ||
} else { | ||
this.api.updateUserData(() => this.setDefaultInitiativeForNonAdmin()); | ||
} | ||
} | ||
|
||
handleInitiativeChange() { | ||
this.updateQueryParams(); | ||
this.outcomeIService.getEOIsData(); | ||
this.outcomeIService.getWorkPackagesData(); | ||
this.outcomeIService.searchText.set(''); | ||
} | ||
|
||
setDefaultInitiativeForNonAdmin(): void { | ||
const defaultInitiative = this.api.dataControlSE.myInitiativesList[0]?.official_code; | ||
const initParam = this.activatedRoute.snapshot.queryParams[this.QUERY_PARAM_INITIATIVE]; | ||
|
||
this.outcomeIService.initiativeIdFilter = this.api.dataControlSE.myInitiativesList.some(init => init.official_code === initParam?.toUpperCase()) | ||
? initParam | ||
: defaultInitiative; | ||
|
||
this.updateQueryParams(); | ||
this.outcomeIService.getEOIsData(); | ||
this.outcomeIService.getWorkPackagesData(); | ||
} | ||
|
||
async loadAllInitiatives(): Promise<void> { | ||
this.api.resultsSE.GET_AllInitiatives().subscribe({ | ||
next: ({ response }) => { | ||
this.allInitiatives = response; | ||
this.handleInitiativeQueryParam(); | ||
}, | ||
error: error => console.error('Error loading initiatives:', error) | ||
}); | ||
} | ||
|
||
handleInitiativeQueryParam(): void { | ||
const initParam = this.activatedRoute.snapshot.queryParams[this.QUERY_PARAM_INITIATIVE]; | ||
|
||
if (initParam) { | ||
this.outcomeIService.initiativeIdFilter = initParam.toUpperCase(); | ||
} else if (this.allInitiatives.length > 0) { | ||
this.outcomeIService.initiativeIdFilter = this.allInitiatives[0].official_code; | ||
this.updateQueryParams(); | ||
} | ||
this.outcomeIService.getEOIsData(); | ||
this.outcomeIService.getWorkPackagesData(); | ||
} | ||
|
||
updateQueryParams(): void { | ||
this.router.navigate([], { | ||
relativeTo: this.activatedRoute, | ||
queryParams: { [this.QUERY_PARAM_INITIATIVE]: this.outcomeIService.initiativeIdFilter }, | ||
queryParamsHandling: 'merge' | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.