From ba345d59a84cd90547d120a5486265f084cc74ba Mon Sep 17 00:00:00 2001 From: Geomitron <22552797+Geomitron@users.noreply.github.com> Date: Fri, 12 Jul 2024 17:03:49 -0500 Subject: [PATCH] Report UI improvements --- .../chart-sidebar-menu.component.html | 22 +++++++++++++++++-- .../chart-sidebar-menu.component.ts | 11 +++++----- .../status-bar/status-bar.component.html | 2 +- src-angular/main.ts | 11 ++++++---- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.html b/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.html index 3fc013c..0159116 100644 --- a/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.html +++ b/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.html @@ -7,7 +7,7 @@ Report issue - @if (reportSent) { + @if (reportState === 'sent') { @@ -16,6 +16,10 @@ {{ reportMessage }} + } @else if (reportState === 'sending') { + + + } @else { @@ -28,6 +32,14 @@ + + + + + Doesn't follow Chorus guidelines + + + @for (option of reportOptions; track $index) { @@ -49,7 +61,13 @@ placeholder="Please be specific. Vague reports may be ignored if the problem is not obvious." formControlName="reportExtraInfo"> - Please provide more details. + + @if (reportExtraInfo.value.length === 0) { + Please provide more details. + } @else { + Reports without a specific explanation will be ignored. + } + diff --git a/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.ts b/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.ts index b65621b..0937b52 100644 --- a/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.ts +++ b/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.ts @@ -19,7 +19,6 @@ export class ChartSidebarMenutComponent implements OnInit { public selectedVersion: FormControl public reportOptions = [ - `Doesn't follow Chorus guidelines`, `Doesn't meet chart quality standards`, 'No notes / chart ends immediately', `Download doesn't work`, @@ -27,7 +26,7 @@ export class ChartSidebarMenutComponent implements OnInit { 'Other', ] as const public reportForm: ReturnType - public reportSent = false + public reportState: 'not-sent' | 'sending' | 'sent' = 'not-sent' public reportMessage = '' constructor( @@ -45,7 +44,7 @@ export class ChartSidebarMenutComponent implements OnInit { getForm() { return this.fb.group({ reportOption: this.fb.control(null as ChartSidebarMenutComponent['reportOptions'][number] | null, [Validators.required]), - reportExtraInfo: this.fb.control('', [Validators.required]), + reportExtraInfo: this.fb.control('', [Validators.required, Validators.minLength(4)]), }) } @@ -106,16 +105,18 @@ export class ChartSidebarMenutComponent implements OnInit { } report() { - if (this.reportExtraInfo.valid) { + if (this.reportForm.valid && this.reportState === 'not-sent') { + this.reportState = 'sending' this.http.post(`${environment.apiUrl}/report`, { chartId: this.selectedVersion.value.chartId, reason: this.reportOption.value, extraInfo: this.reportExtraInfo.value, }).subscribe((response: { message: string }) => { this.reportMessage = response.message - this.reportSent = true + this.reportState = 'sent' }) } else { + this.reportOption.markAsTouched() this.reportExtraInfo.markAsTouched() } } diff --git a/src-angular/app/components/browse/status-bar/status-bar.component.html b/src-angular/app/components/browse/status-bar/status-bar.component.html index 8462417..1eff9da 100644 --- a/src-angular/app/components/browse/status-bar/status-bar.component.html +++ b/src-angular/app/components/browse/status-bar/status-bar.component.html @@ -1,6 +1,6 @@ - {{ searchService.songsResponse.found }} Result{{ searchService.songsResponse.found === 1 ? '' : 's' }} + {{ searchService.songsResponse.found | number: '1.0-0' }} Result{{ searchService.songsResponse.found === 1 ? '' : 's' }} 1" (click)="downloadSelected()" class="btn btn-sm btn-primary text-nowrap"> diff --git a/src-angular/main.ts b/src-angular/main.ts index 2e269f5..dee528d 100644 --- a/src-angular/main.ts +++ b/src-angular/main.ts @@ -1,8 +1,8 @@ -import { enableProdMode } from '@angular/core' +import { enableProdMode, LOCALE_ID } from '@angular/core' import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' -import { AppModule } from './app/app.module' -import { environment } from './environments/environment' +import { AppModule } from './app/app.module.js' +import { environment } from './environments/environment.js' window.electron.on.errorLog(data => console.error(data)) @@ -10,5 +10,8 @@ if (environment.production) { enableProdMode() } -platformBrowserDynamic().bootstrapModule(AppModule) +platformBrowserDynamic() + .bootstrapModule(AppModule, { + providers: [{ provide: LOCALE_ID, useValue: document.documentElement.lang || 'en-US' }], + }) .catch(err => console.error(err))