Skip to content

Commit

Permalink
Added reset to default button
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkapok committed Aug 15, 2024
1 parent 0265b06 commit 3ad533e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<div class="row">
<div class="form-group mt-3">
<button type="button" class="btn btn-primary me-2" (click)="location.back()">Back</button>
<button type="button" class="btn btn-secondary me-2" (click)="resetToDefault()" >Reset to Default</button>
<button type="button" class="btn btn-secondary" (click)="use()" [hidden]="!settingsForm.valid">Use</button>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ describe('App settings component', () => {

// TODO AppSettings:
// * After changing units, also the range values need to be reloaded
// * Add save and load last form state. Do we want this? Or together with reset to default?


// TODO missing test cases:
Expand Down
13 changes: 10 additions & 3 deletions projects/planner/src/app/app-settings/app-settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import { faUserCog } from '@fortawesome/free-solid-svg-icons';
import { SettingsNormalizationService } from '../shared/settings-normalization.service';
import { RangeConstants, UnitConversion } from '../shared/UnitConversion';
import { SubViewStorage } from '../shared/subViewStorage';
import { DiveSchedules } from '../shared/dive.schedules';
import { ApplicationSettingsService } from '../shared/ApplicationSettings';
import { InputControls } from '../shared/inputcontrols';
import { ValidatorGroups } from '../shared/ValidatorGroups';
import { Precision } from 'scuba-physics';
import { Precision, GasDensity } from 'scuba-physics';

@Component({
selector: 'app-app-settings',
Expand All @@ -31,7 +30,6 @@ export class AppSettingsComponent implements OnInit {
constructor(
public units: UnitConversion,
private settingsNormalization: SettingsNormalizationService,
private schedules: DiveSchedules,
private views: SubViewStorage,
public appSettings: ApplicationSettingsService,
private formBuilder: NonNullableFormBuilder,
Expand Down Expand Up @@ -83,6 +81,15 @@ export class AppSettingsComponent implements OnInit {
this.cd.detectChanges();
}

public resetToDefault(): void {
this.settingsForm.patchValue({
imperialUnits: false,
maxDensity: GasDensity.recommendedMaximum
});

// don't apply yet, let the user to confirm
}

private reLoad(): void {
this.settingsForm.patchValue({
maxDensity: this.maxDensity
Expand Down
1 change: 0 additions & 1 deletion projects/planner/src/app/shared/ApplicationSettings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Injectable } from '@angular/core';
import { UnitConversion } from './UnitConversion';
import { AppSettings } from './models';
import { GasDensity } from "scuba-physics";

@Injectable()
export class ApplicationSettingsService {
Expand Down

0 comments on commit 3ad533e

Please sign in to comment.