Skip to content

Commit 5005482

Browse files
jessewashburnMutugiiidogi
authored
manager: smoother currency configuring (fixes #9064) (#9069)
Co-authored-by: mutugiii <[email protected]> Co-authored-by: dogi <[email protected]>
1 parent f1ad4a2 commit 5005482

10 files changed

+225
-122
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "planet",
33
"license": "AGPL-3.0",
4-
"version": "0.20.42",
4+
"version": "0.20.43",
55
"myplanet": {
66
"latest": "v0.33.66",
77
"min": "v0.32.66"

src/app/manager-dashboard/manager-aiservices.component.scss

Lines changed: 0 additions & 119 deletions
This file was deleted.

src/app/manager-dashboard/manager-aiservices.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { StateService } from '../shared/state.service';
1111

1212
@Component({
1313
templateUrl: './manager-aiservices.component.html',
14-
styleUrls: [ './manager-aiservices.component.scss' ],
14+
styleUrls: [ './manager-settings.shared.scss' ],
1515
})
1616
export class ManagerAIServicesComponent implements OnInit {
1717
configuration: any = {};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<mat-toolbar>
2+
<button mat-icon-button routerLink="/manager">
3+
<mat-icon>arrow_back</mat-icon>
4+
</button>
5+
<span i18n="@@currency.configuration.title">Currency Configuration</span>
6+
</mat-toolbar>
7+
8+
<form class="container" [formGroup]="form">
9+
<mat-card class="card">
10+
<mat-card-title i18n="@@currency.card.title">Currency</mat-card-title>
11+
<mat-card-content>
12+
<mat-list>
13+
<mat-list-item>
14+
<div class="list-item-content">
15+
<span i18n="@@currency.code.label">Code</span>
16+
<mat-form-field>
17+
<input matInput formControlName="code" (input)="form.get('code').setValue(form.get('code').value.toUpperCase())" placeholder="e.g. USD" i18n-placeholder>
18+
<mat-error><planet-form-error-messages [control]="form.controls.code"></planet-form-error-messages></mat-error>
19+
</mat-form-field>
20+
</div>
21+
</mat-list-item>
22+
<mat-list-item>
23+
<div class="list-item-content">
24+
<span i18n="@@currency.symbol.label">Symbol</span>
25+
<mat-form-field>
26+
<input matInput formControlName="symbol" placeholder="e.g. $" i18n-placeholder>
27+
<mat-error><planet-form-error-messages [control]="form.controls.symbol"></planet-form-error-messages></mat-error>
28+
</mat-form-field>
29+
</div>
30+
</mat-list-item>
31+
</mat-list>
32+
<div class="hint" i18n="@@currency.hint">Enter the ISO code (e.g., USD, EUR) and symbol used in financial reports.</div>
33+
</mat-card-content>
34+
</mat-card>
35+
<div class="update-button-container">
36+
<button [planetSubmit]="spinnerOn" mat-raised-button color="primary" (click)="save()" i18n="@@currency.save">Save Currency</button>
37+
</div>
38+
</form>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { FormControl, FormGroup, NonNullableFormBuilder, Validators } from '@angular/forms';
3+
import { Router } from '@angular/router';
4+
import { finalize } from 'rxjs/operators';
5+
import { ConfigurationService } from '../configuration/configuration.service';
6+
import { PlanetMessageService } from '../shared/planet-message.service';
7+
import { StateService } from '../shared/state.service';
8+
9+
@Component({
10+
templateUrl: './manager-currency.component.html',
11+
styleUrls: [ './manager-settings.shared.scss' ]
12+
})
13+
export class ManagerCurrencyComponent implements OnInit {
14+
form: FormGroup<{ code: FormControl<string>; symbol: FormControl<string> }>;
15+
configuration: any = {};
16+
spinnerOn = true;
17+
18+
constructor(
19+
private fb: NonNullableFormBuilder,
20+
private configurationService: ConfigurationService,
21+
private stateService: StateService,
22+
private planetMessageService: PlanetMessageService,
23+
private router: Router
24+
) {
25+
this.form = this.fb.group({
26+
code: this.fb.control('', { validators: [ Validators.required, Validators.maxLength(6) ] }),
27+
symbol: this.fb.control('', { validators: [ Validators.required, Validators.maxLength(5) ] })
28+
});
29+
}
30+
31+
ngOnInit() {
32+
this.configuration = this.stateService.configuration;
33+
if (this.configuration?.currency) {
34+
this.form.patchValue(this.configuration.currency);
35+
}
36+
}
37+
38+
save() {
39+
const spinnerOff = () => this.spinnerOn = false;
40+
if (this.form.invalid) {
41+
spinnerOff();
42+
return;
43+
}
44+
this.spinnerOn = true;
45+
const updatedConfig = { ...this.configuration, keys: this.stateService.keys, currency: { ...this.form.value } };
46+
this.configurationService.updateConfiguration(updatedConfig)
47+
.pipe(finalize(spinnerOff))
48+
.subscribe(
49+
() => {
50+
this.stateService.requestData('configurations', 'local');
51+
},
52+
(err) => {
53+
this.planetMessageService.showAlert($localize`There was an error updating the configuration`);
54+
},
55+
() => {
56+
this.router.navigate(['/manager']);
57+
this.planetMessageService.showMessage($localize`Currency Updated Successfully`);
58+
}
59+
);
60+
}
61+
}

src/app/manager-dashboard/manager-dashboard-router.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ManagerSyncComponent } from './manager-sync.component';
55
import { ManagerFetchComponent } from './manager-fetch.component';
66
import { ManagerAIServicesComponent } from './manager-aiservices.component';
77
import { ManagerDashboardConfigurationComponent } from './manager-dashboard-configuration.component';
8+
import { ManagerCurrencyComponent } from './manager-currency.component';
89
import { ReportsComponent } from './reports/reports.component';
910
import { ReportsDetailComponent } from './reports/reports-detail.component';
1011
import { ReportsPendingComponent } from './reports/reports-pending.component';
@@ -15,6 +16,7 @@ import { LogsMyPlanetComponent } from './reports/myplanet/logs-myplanet.componen
1516
const routes: Routes = [
1617
{ path: '', component: ManagerDashboardComponent },
1718
{ path: 'aiservices', component: ManagerAIServicesComponent },
19+
{ path: 'currency', component: ManagerCurrencyComponent },
1820
{ path: 'certifications', loadChildren: () => import('./certifications/certifications.module').then(m => m.CertificationsModule) },
1921
{ path: 'sync', component: ManagerSyncComponent },
2022
{ path: 'fetch', component: ManagerFetchComponent },

src/app/manager-dashboard/manager-dashboard.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
</ng-container>
2727
<a routerLink="/manager/users" i18n mat-raised-button>Members</a>
2828
<a routerLink="/manager/aiservices" i18n mat-raised-button>AI Configurations</a>
29+
<a routerLink="/manager/currency" i18n="@@currency.nav.link" mat-raised-button>Currency</a>
2930
<a routerLink="certifications" i18n mat-raised-button *planetBeta>Certifications</a>
3031
<button *ngIf="devMode"
3132
(click)="openDeleteCommunityDialog()" i18n mat-raised-button color = "warn">Delete Community</button>

src/app/manager-dashboard/manager-dashboard.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { ReportsMyPlanetComponent } from './reports/myplanet/reports-myplanet.co
2323
import { SharedComponentsModule } from '../shared/shared-components.module';
2424
import { ReportsDetailActivitiesComponent } from './reports/reports-detail-activities.component';
2525
import { ReportsHealthComponent } from './reports/reports-health.component';
26+
import { ManagerCurrencyComponent } from './manager-currency.component';
2627

2728
@NgModule({
2829
imports: [
@@ -53,7 +54,8 @@ import { ReportsHealthComponent } from './reports/reports-health.component';
5354
PendingTableComponent,
5455
ReportsMyPlanetComponent,
5556
ReportsDetailActivitiesComponent,
56-
ReportsHealthComponent
57+
ReportsHealthComponent,
58+
ManagerCurrencyComponent
5759
]
5860
})
5961
export class ManagerDashboardModule {}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
@import "../variables.scss";
2+
3+
.container {
4+
padding: 20px;
5+
display: flex;
6+
flex-direction: column;
7+
gap: 20px;
8+
align-items: center;
9+
}
10+
11+
.card {
12+
width: 95%;
13+
margin: 0 auto;
14+
}
15+
16+
.list-item-content {
17+
display: grid;
18+
grid-template-columns: 1.5fr 4fr;
19+
width: 100%;
20+
align-items: baseline;
21+
gap: 20px;
22+
}
23+
24+
.update-button-container {
25+
display: flex;
26+
justify-content: center;
27+
width: 100%;
28+
margin-top: 20px;
29+
margin-bottom: 20px;
30+
}
31+
32+
.update-button-container button {
33+
width: auto;
34+
margin-left: 0;
35+
}
36+
37+
.instructions {
38+
padding: 10px;
39+
border-bottom: 1px solid rgba(0, 0, 0, 0.12);
40+
font-size: 16px;
41+
line-height: 1.5;
42+
}
43+
44+
.hint {
45+
font-size: 12px;
46+
color: rgba(0, 0, 0, 0.6);
47+
margin-top: 8px;
48+
}
49+
50+
/* Tablet */
51+
@media (max-width: $screen-md) {
52+
.container { padding: 15px; }
53+
.card { width: 100%; margin: 0; }
54+
.list-item-content { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
55+
.list-item-content > span { flex-basis: 30%; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.5; }
56+
mat-form-field { flex-basis: 70%; }
57+
input { width: 100%; }
58+
}
59+
60+
/* Mobile */
61+
@media (max-width: $screen-sm) {
62+
.container { padding: 10px; }
63+
.card { width: 100%; margin: 0; }
64+
.list-item-content { display: flex; flex-direction: row; justify-content: flex-start; align-items: center; gap: 10px; max-width: 70%; overflow-x: hidden; }
65+
.list-item-content > span { flex-basis: 35%; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
66+
mat-form-field { flex-basis: 80%; min-width: 0; }
67+
.update-button-container { justify-content: flex-start; }
68+
}

0 commit comments

Comments
 (0)