Skip to content

Commit

Permalink
exposure assessment sidebar expand and check at the same time (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethliporada authored Jan 31, 2024
1 parent 5679e2f commit 4e920a1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="p-5 w-full bg-sidebar shadow-md hover:shodow-lg rounded-lg mt-6">
<div class="flex cursor-pointer select-none">
<div class="flex cursor-pointer select-none" (click)="toggleExpanded($event)">
<label class="inline-flex items-center checkbox">
<input
type="checkbox"
Expand Down Expand Up @@ -123,7 +123,10 @@
</button>
</div>
</div>
<div [ngClass]="(expanded$ | async) ? ' pt-5 ' : ' hidden '">
<div
*ngIf="isExpanded"
[ngClass]="(expanded$ | async) ? ' pt-5 ' : ' hidden '"
>
<hr class="pb-4" />
<div class="pl-2">
<div class="items-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class RiskAssessmentGroupComponent implements OnInit {
expanded$: Observable<boolean>;
riskAssessmentPopuShown$: Observable<boolean>;
shown$: Observable<boolean>;

expandedValue: boolean = false;
initialRainOpacityValue: number = 80;
initialPopuOpacityValue: number = 80;

Expand All @@ -35,6 +35,10 @@ export class RiskAssessmentGroupComponent implements OnInit {

popuLegend = false;

get isExpanded(): boolean {
return this.expandedValue;
}

constructor(
private pgService: NoahPlaygroundService,
private modalService: ModalService
Expand Down Expand Up @@ -84,21 +88,34 @@ export class RiskAssessmentGroupComponent implements OnInit {
toggleExpanded(event: Event) {
event.stopPropagation();
event.stopImmediatePropagation();
this.pgService.toggleRiskAssessmentGroupProperty('expanded');
this.expandedValue = !this.expandedValue;
this.pgService.toggleRiskAssessmentGroupProperty(
'expanded',
this.expandedValue
);
}

toggleShown(event: Event) {
event.stopPropagation();
event.stopImmediatePropagation();
this.checkedShown = (event.target as HTMLInputElement).checked;
this.pgService.toggleRiskAssessmentGroupProperty('shown');
this.pgService.toggleRiskAssessmentGroupProperty('expanded');
this.updateButtonEnabled();

this.expandedValue = true;
if (!this.checkedShown) {
this.modalService.closeBtnRiskAssessment();
this.popuLegend = false;
this.pgService.toggleAffectedPopulationVisibilityFalse();
this.pgService.toggleRiskAssessmentGroupProperty('shown', false);
this.pgService.toggleRiskAssessmentGroupProperty(
'expanded',
(this.expandedValue = false)
);
} else {
this.pgService.toggleRiskAssessmentGroupProperty('shown', true);
this.pgService.toggleRiskAssessmentGroupProperty(
'expanded',
this.expandedValue
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,13 +521,17 @@ export class NoahPlaygroundService {
this.store.patch({ volcanoes }, `Volcanoes ${property}, ${!currentValue}`);
}

toggleRiskAssessmentGroupProperty(property: 'expanded' | 'shown') {
toggleRiskAssessmentGroupProperty(
property: 'expanded' | 'shown',
value: boolean
) {
const riskAssessment: RiskAssessmentGroupState = {
...this.store.state.riskAssessment,
};

const currentValue = riskAssessment[property];
riskAssessment[property] = !currentValue;
//riskAssessment[property] = !currentValue; remain this if ever we have changes
riskAssessment[property] = value;
this.store.patch(
{ riskAssessment },
`Risk Assessment ${property}, ${!currentValue}`
Expand Down

0 comments on commit 4e920a1

Please sign in to comment.