From ee2f53e503346c979e0e5364b3fd234e7e5673de Mon Sep 17 00:00:00 2001 From: Rakshita Varadarajan <54491584+rak108@users.noreply.github.com> Date: Fri, 16 Oct 2020 17:35:54 +0300 Subject: [PATCH] refactor (df/locale): reports module (#1258) See: #1213 --- src/app/reports/run-report/pentaho/pentaho.component.ts | 6 ++++-- src/app/reports/run-report/run-report.component.ts | 5 ++++- src/app/reports/xbrl-report/xbrl-report.component.ts | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/app/reports/run-report/pentaho/pentaho.component.ts b/src/app/reports/run-report/pentaho/pentaho.component.ts index 981590158..a250591e5 100644 --- a/src/app/reports/run-report/pentaho/pentaho.component.ts +++ b/src/app/reports/run-report/pentaho/pentaho.component.ts @@ -4,6 +4,7 @@ import { DomSanitizer } from '@angular/platform-browser'; /** Custom Services */ import { ReportsService } from '../../reports.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * Pentaho Component @@ -26,9 +27,10 @@ export class PentahoComponent implements OnChanges { /** * @param {DomSanitizer} sanitizer DOM Sanitizer * @param {ReportsService} reportsService Reports Service + * @param {SettingsService} settingsService Settings Service */ constructor(private sanitizer: DomSanitizer, - private reportsService: ReportsService) { } + private reportsService: ReportsService, private settingsService: SettingsService) { } /** * Fetches run report data post changes in run report form. @@ -39,7 +41,7 @@ export class PentahoComponent implements OnChanges { } getRunReportData() { - this.reportsService.getPentahoRunReportData(this.dataObject.report.name, this.dataObject.formData, 'default', 'en', 'dd MMMM yyyy') + this.reportsService.getPentahoRunReportData(this.dataObject.report.name, this.dataObject.formData, 'default', this.settingsService.language.code, this.settingsService.dateFormat) .subscribe( (res: any) => { const contentType = res.headers.get('Content-Type'); const file = new Blob([res.body], {type: contentType}); diff --git a/src/app/reports/run-report/run-report.component.ts b/src/app/reports/run-report/run-report.component.ts index 494157b69..2dd079ec2 100644 --- a/src/app/reports/run-report/run-report.component.ts +++ b/src/app/reports/run-report/run-report.component.ts @@ -6,6 +6,7 @@ import { DatePipe } from '@angular/common'; /** Custom Services */ import { ReportsService } from '../reports.service'; +import { SettingsService } from 'app/settings/settings.service'; /** Custom Models */ import { ReportParameter } from '../common-models/report-parameter.model'; @@ -55,10 +56,12 @@ export class RunReportComponent implements OnInit { * Fetches report specifications from route params and retrieves report parameters data from `resolve`. * @param {ActivatedRoute} route ActivatedRoute. * @param {ReportsService} reportsService ReportsService + * @param {SettingsService} settingsService Settings Service * @param {DatePipe} datePipe Date Pipe */ constructor(private route: ActivatedRoute, private reportsService: ReportsService, + private settingsService: SettingsService, private datePipe: DatePipe) { this.report.name = this.route.snapshot.params['name']; this.route.queryParams.subscribe((queryParams: { type: any, id: any }) => { @@ -189,7 +192,7 @@ export class RunReportComponent implements OnInit { formattedResponse[newKey] = value['id']; break; case 'date': - const dateFormat = 'yyyy-MM-dd'; + const dateFormat = this.settingsService.dateFormat; formattedResponse[newKey] = this.datePipe.transform(value, dateFormat); break; case 'none': diff --git a/src/app/reports/xbrl-report/xbrl-report.component.ts b/src/app/reports/xbrl-report/xbrl-report.component.ts index 58a23b122..d862bcbe2 100644 --- a/src/app/reports/xbrl-report/xbrl-report.component.ts +++ b/src/app/reports/xbrl-report/xbrl-report.component.ts @@ -7,6 +7,7 @@ import { DomSanitizer } from '@angular/platform-browser'; /** Custom Services */ import { ReportsService } from '../reports.service'; +import { SettingsService } from 'app/settings/settings.service'; /** * XBRL Report Component @@ -41,9 +42,11 @@ export class XBRLReportComponent implements OnInit { * @param {FormBuilder} formBuilder Form Builder. * @param {ActivatedRoute} route Activated Route. * @param {Router} router Router for navigation. + * @param {SettingsService} settingsService Settings Service */ constructor(private reportService: ReportsService, private formBuilder: FormBuilder, + private settingsService: SettingsService, private datePipe: DatePipe, private sanitizer: DomSanitizer) {} @@ -88,7 +91,7 @@ export class XBRLReportComponent implements OnInit { const startDate: Date = this.xbrlForm.value.startDate; const endDate: Date = this.xbrlForm.value.endDate; // TODO: Update once language and date settings are setup - const dateFormat = 'yyyy-MM-dd'; + const dateFormat = this.settingsService.dateFormat; this.xbrlForm.patchValue({ startDate: this.datePipe.transform(startDate, dateFormat), endDate: this.datePipe.transform(endDate, dateFormat) @@ -123,3 +126,4 @@ export class XBRLReportComponent implements OnInit { } } +