-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scenario cards list (PLAN-1363) (#1666)
- Loading branch information
1 parent
186b9ad
commit 43840b4
Showing
16 changed files
with
215 additions
and
75 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
src/interface/src/app/plan/area-scrolling-notes/area-scrolling-notes.component.spec.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
4 changes: 2 additions & 2 deletions
4
src/interface/src/app/plan/area-scrolling-notes/area-scrolling-notes.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
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
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
12 changes: 12 additions & 0 deletions
12
...nterface/src/app/plan/plan-summary/scenarios-card-list/scenarios-card-list.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<sg-scenario-card | ||
*ngFor="let s of scenarios" | ||
[name]="s.name" | ||
[creator]="s.creator" | ||
[areas]="s.max_treatment_area" | ||
[created_at]="s.created_at" | ||
[budget]="s.max_budget" | ||
[treatmentPlansCount]="s.tx_plan_count" | ||
[status]="s.scenario_result?.status || 'PENDING'" | ||
(click)="handleClickedScenario(s)" | ||
[selected]="isSelected(s)"> | ||
</sg-scenario-card> |
10 changes: 10 additions & 0 deletions
10
...nterface/src/app/plan/plan-summary/scenarios-card-list/scenarios-card-list.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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@import 'mixins'; | ||
@import 'colors'; | ||
|
||
:host { | ||
display: flex; | ||
flex-wrap: wrap; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
gap: 20px; | ||
} |
22 changes: 22 additions & 0 deletions
22
...rface/src/app/plan/plan-summary/scenarios-card-list/scenarios-card-list.component.spec.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ScenariosCardListComponent } from './scenarios-card-list.component'; | ||
|
||
describe('ScenariosCardListComponent', () => { | ||
let component: ScenariosCardListComponent; | ||
let fixture: ComponentFixture<ScenariosCardListComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ScenariosCardListComponent], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ScenariosCardListComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
50 changes: 50 additions & 0 deletions
50
src/interface/src/app/plan/plan-summary/scenarios-card-list/scenarios-card-list.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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { NgFor } from '@angular/common'; | ||
|
||
import { ScenarioRow } from '../saved-scenarios/saved-scenarios.component'; | ||
import { Scenario, ScenarioResult } from '@types'; | ||
import { ScenarioCardComponent } from '../../../../styleguide/scenario-card/scenario-card.component'; | ||
import { | ||
parseResultsToProjectAreas, | ||
parseResultsToTotals, | ||
} from '../../plan-helpers'; | ||
|
||
@Component({ | ||
selector: 'app-scenarios-card-list', | ||
standalone: true, | ||
imports: [ScenarioCardComponent, NgFor], | ||
templateUrl: './scenarios-card-list.component.html', | ||
styleUrl: './scenarios-card-list.component.scss', | ||
}) | ||
export class ScenariosCardListComponent { | ||
selectedCard: ScenarioRow | null = null; | ||
@Input() scenarios: ScenarioRow[] = []; | ||
@Output() selectScenario = new EventEmitter<ScenarioRow>(); | ||
@Output() clickedScenario = new EventEmitter<ScenarioRow>(); | ||
|
||
hasResults(scenario: Scenario) { | ||
return ( | ||
!!scenario.scenario_result && | ||
scenario.scenario_result.result?.features?.length > 0 | ||
); | ||
} | ||
|
||
handleClickedScenario(row: ScenarioRow): void { | ||
if ( | ||
row.scenario_result?.status === 'FAILURE' || | ||
row.scenario_result?.status === 'SUCCESS' | ||
) { | ||
this.selectedCard = row; | ||
this.selectScenario.emit(row); | ||
} | ||
} | ||
|
||
calculateTotals(results: ScenarioResult) { | ||
const projectAreas = parseResultsToProjectAreas(results); | ||
return parseResultsToTotals(projectAreas); | ||
} | ||
|
||
isSelected(s: ScenarioRow): boolean { | ||
return this.selectedCard == s; | ||
} | ||
} |
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
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
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
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
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.