Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(4as): exposure assessment sidebar expand and check at the same time #351

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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