build: Use prettier for typescript

Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
Ralph Hopman
2025-01-15 11:59:30 +00:00
committed by Adam Saghy
parent 9d6cf1514a
commit cac1d11ad7
1812 changed files with 22516 additions and 16862 deletions
@@ -8,9 +8,8 @@ describe('CreateReportComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CreateReportComponent ]
})
.compileComponents();
declarations: [CreateReportComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -24,20 +24,22 @@ import { ReportParameterDialogComponent } from '../report-parameter-dialog/repor
styleUrls: ['./create-report.component.scss']
})
export class CreateReportComponent implements OnInit {
/** Report Form. */
reportForm: UntypedFormGroup;
/** Report Template Data. */
reportTemplateData: any;
/** Data passed to dialog. */
dataForDialog: { allowedParameters: any[], parameterName: string, reportParameterName: string } =
{
allowedParameters: undefined,
parameterName: undefined,
reportParameterName: undefined
};
dataForDialog: { allowedParameters: any[]; parameterName: string; reportParameterName: string } = {
allowedParameters: undefined,
parameterName: undefined,
reportParameterName: undefined
};
/** Columns to be displayed in report parameters table. */
displayedColumns: string[] = ['parameterName', 'parameterNamePassed', 'actions'];
displayedColumns: string[] = [
'parameterName',
'parameterNamePassed',
'actions'
];
/** Data source for report parameters table. */
dataSource: MatTableDataSource<any>;
/** Report Parameters Data. */
@@ -47,7 +49,13 @@ export class CreateReportComponent implements OnInit {
/** Sorter for report parameters table. */
@ViewChild(MatSort, { static: true }) sort: MatSort;
reportCategoryTypeOptions: string[] = ['Client', 'Loan', 'Savings', 'Fund', 'Accounting'];
reportCategoryTypeOptions: string[] = [
'Client',
'Loan',
'Savings',
'Fund',
'Accounting'
];
/**
* Retrieves the report template data from `resolve`.
@@ -58,12 +66,14 @@ export class CreateReportComponent implements OnInit {
* @param {MatDialog} dialog Dialog Reference.
* @param {TranslateService} translateService Translate Service.
*/
constructor(private formBuilder: UntypedFormBuilder,
private systemService: SystemService,
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog,
private translateServices: TranslateService) {
constructor(
private formBuilder: UntypedFormBuilder,
private systemService: SystemService,
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog,
private translateServices: TranslateService
) {
this.route.data.subscribe((data: { reportTemplate: any }) => {
this.reportTemplateData = data.reportTemplate;
this.dataForDialog.allowedParameters = this.reportTemplateData.allowedParameters;
@@ -93,13 +103,22 @@ export class CreateReportComponent implements OnInit {
*/
createReportForm() {
this.reportForm = this.formBuilder.group({
'reportName': ['', Validators.required],
'reportCategory': [''],
'description': [''],
'reportType': ['', Validators.required],
'reportSubType': [{ value: '', disabled: true }],
'useReport': [false],
'reportSql': ['', Validators.required]
reportName: [
'',
Validators.required
],
reportCategory: [''],
description: [''],
reportType: [
'',
Validators.required
],
reportSubType: [{ value: '', disabled: true }],
useReport: [false],
reportSql: [
'',
Validators.required
]
});
}
@@ -114,10 +133,14 @@ export class CreateReportComponent implements OnInit {
});
addReportParameterDialogRef.afterClosed().subscribe((response: any) => {
if (response !== '') {
this.reportParametersData.push({ id: '',
parameterName: this.reportTemplateData.allowedParameters.find((allowedParameter: any) => allowedParameter.id === response.parameterName).parameterName,
parameterId: response.parameterName,
reportParameterName: response.reportParameterName });
this.reportParametersData.push({
id: '',
parameterName: this.reportTemplateData.allowedParameters.find(
(allowedParameter: any) => allowedParameter.id === response.parameterName
).parameterName,
parameterId: response.parameterName,
reportParameterName: response.reportParameterName
});
this.dataSource.connect().next(this.reportParametersData);
}
});
@@ -135,10 +158,14 @@ export class CreateReportComponent implements OnInit {
});
editReportParameterDialogRef.afterClosed().subscribe((response: any) => {
if (response !== '') {
this.reportParametersData[this.reportParametersData.indexOf(reportParameter)] = { id: '',
parameterName: this.reportTemplateData.allowedParameters.find((allowedParameter: any) => allowedParameter.id === response.parameterName).parameterName,
this.reportParametersData[this.reportParametersData.indexOf(reportParameter)] = {
id: '',
parameterName: this.reportTemplateData.allowedParameters.find(
(allowedParameter: any) => allowedParameter.id === response.parameterName
).parameterName,
parameterId: response.parameterName,
reportParameterName: response.reportParameterName };
reportParameterName: response.reportParameterName
};
this.dataSource.connect().next(this.reportParametersData);
}
});
@@ -150,7 +177,10 @@ export class CreateReportComponent implements OnInit {
*/
deleteReportParameter(reportParameter: any) {
const deleteReportDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: this.translateServices.instant('labels.heading.Report Parameter') + ' ' + reportParameter.parameterName }
data: {
deleteContext:
this.translateServices.instant('labels.heading.Report Parameter') + ' ' + reportParameter.parameterName
}
});
deleteReportDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
@@ -164,22 +194,21 @@ export class CreateReportComponent implements OnInit {
* Toggles the visibility status of Report Sub Type dropdown.
*/
toggleVisibility() {
this.reportForm.get('reportType').valueChanges
.subscribe(type => {
switch (type) {
case 'Chart':
this.reportForm.get('reportSubType').enable();
this.reportForm.get('reportSql').enable();
break;
case 'Pentaho':
this.reportForm.get('reportSql').disable();
this.reportForm.get('reportSubType').disable();
break;
default:
this.reportForm.get('reportSql').enable();
this.reportForm.get('reportSubType').disable();
}
});
this.reportForm.get('reportType').valueChanges.subscribe((type) => {
switch (type) {
case 'Chart':
this.reportForm.get('reportSubType').enable();
this.reportForm.get('reportSql').enable();
break;
case 'Pentaho':
this.reportForm.get('reportSql').disable();
this.reportForm.get('reportSubType').disable();
break;
default:
this.reportForm.get('reportSql').enable();
this.reportForm.get('reportSubType').disable();
}
});
}
/**
@@ -187,15 +216,19 @@ export class CreateReportComponent implements OnInit {
* if successful redirects to view created report.
*/
submit() {
this.reportForm.value.reportParameters = this.reportParametersData.map( function(reportParameter: any) {
this.reportForm.value.reportParameters = this.reportParametersData.map(function (reportParameter: any) {
reportParameter.parameterName = undefined;
return reportParameter;
});
this.systemService.createReport(this.reportForm.value)
.subscribe((response: any) => {
// TODO: Implement Maker Checker Component.
this.router.navigate(['../', response.resourceId], { relativeTo: this.route });
});
this.systemService.createReport(this.reportForm.value).subscribe((response: any) => {
// TODO: Implement Maker Checker Component.
this.router.navigate(
[
'../',
response.resourceId
],
{ relativeTo: this.route }
);
});
}
}
@@ -8,9 +8,8 @@ describe('EditReportComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditReportComponent ]
})
.compileComponents();
declarations: [EditReportComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -23,7 +23,6 @@ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.co
styleUrls: ['./edit-report.component.scss']
})
export class EditReportComponent implements OnInit {
/** Report Data. */
reportData: any;
/** Report Template Data. */
@@ -31,22 +30,31 @@ export class EditReportComponent implements OnInit {
/** Report Parameters Data. */
reportParametersData: any[] = [];
/** Data passed to dialog. */
dataForDialog: { allowedParameters: any[], parameterName: string, reportParameterName: string } =
{
allowedParameters: undefined,
parameterName: undefined,
reportParameterName: undefined
};
dataForDialog: { allowedParameters: any[]; parameterName: string; reportParameterName: string } = {
allowedParameters: undefined,
parameterName: undefined,
reportParameterName: undefined
};
/** Report Form. */
reportForm: UntypedFormGroup;
/** Columns to be displayed in report parameters table. */
displayedColumns: string[] = ['parameterName', 'parameterNamePassed', 'actions'];
displayedColumns: string[] = [
'parameterName',
'parameterNamePassed',
'actions'
];
/** Data source for report parameters table. */
dataSource: MatTableDataSource<any>;
/** Boolean to check if report parameters data is changed or not. */
isReportParametersChanged: Boolean = false;
reportCategoryTypeOptions: string[] = ['Client', 'Loan', 'Savings', 'Fund', 'Accounting'];
reportCategoryTypeOptions: string[] = [
'Client',
'Loan',
'Savings',
'Fund',
'Accounting'
];
/** Paginator for report parameters table. */
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
@@ -61,12 +69,14 @@ export class EditReportComponent implements OnInit {
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog Reference.
*/
constructor(private formBuilder: UntypedFormBuilder,
private route: ActivatedRoute,
private router: Router,
private systemService: SystemService,
private dialog: MatDialog) {
this.route.data.subscribe((data: { report: any, reportTemplate: any }) => {
constructor(
private formBuilder: UntypedFormBuilder,
private route: ActivatedRoute,
private router: Router,
private systemService: SystemService,
private dialog: MatDialog
) {
this.route.data.subscribe((data: { report: any; reportTemplate: any }) => {
this.reportData = data.report;
this.reportParametersData = data.report.reportParameters ? data.report.reportParameters : [];
this.reportTemplateData = data.reportTemplate;
@@ -97,13 +107,41 @@ export class EditReportComponent implements OnInit {
*/
createReportForm() {
this.reportForm = this.formBuilder.group({
'reportName': [{ value: this.reportData.reportName, disabled: this.reportData.coreReport }, Validators.required],
'reportCategory': [{ value: this.reportData.reportCategory ? this.reportData.reportCategory : '', disabled: this.reportData.coreReport }],
'description': [{ value: this.reportData.description ? this.reportData.description : '', disabled: this.reportData.coreReport }],
'reportType': [{ value: this.reportData.reportType, disabled: this.reportData.coreReport }, Validators.required],
'reportSubType': [{ value: this.reportData.reportSubType ? this.reportData.reportSubType : '', disabled: this.reportData.reportType !== 'Chart' || this.reportData.coreReport }],
'useReport': [this.reportData.useReport ? this.reportData.useReport : false],
'reportSql': [{ value: this.reportData.reportSql, disabled: this.reportData.coreReport || this.reportData.reportType === 'Pentaho' }, Validators.required]
reportName: [
{ value: this.reportData.reportName, disabled: this.reportData.coreReport },
Validators.required
],
reportCategory: [
{
value: this.reportData.reportCategory ? this.reportData.reportCategory : '',
disabled: this.reportData.coreReport
}
],
description: [
{
value: this.reportData.description ? this.reportData.description : '',
disabled: this.reportData.coreReport
}
],
reportType: [
{ value: this.reportData.reportType, disabled: this.reportData.coreReport },
Validators.required
],
reportSubType: [
{
value: this.reportData.reportSubType ? this.reportData.reportSubType : '',
disabled: this.reportData.reportType !== 'Chart' || this.reportData.coreReport
}
],
useReport: [this.reportData.useReport ? this.reportData.useReport : false],
reportSql: [
{
value: this.reportData.reportSql,
disabled: this.reportData.coreReport || this.reportData.reportType === 'Pentaho'
},
Validators.required
]
});
}
@@ -118,10 +156,14 @@ export class EditReportComponent implements OnInit {
});
addReportParameterDialogRef.afterClosed().subscribe((response: any) => {
if (response !== '') {
this.reportParametersData.push({ id: '',
parameterName: this.reportTemplateData.allowedParameters.find((allowedParameter: any) => allowedParameter.id === response.parameterName).parameterName,
parameterId: response.parameterName,
reportParameterName: response.reportParameterName ? response.reportParameterName : undefined });
this.reportParametersData.push({
id: '',
parameterName: this.reportTemplateData.allowedParameters.find(
(allowedParameter: any) => allowedParameter.id === response.parameterName
).parameterName,
parameterId: response.parameterName,
reportParameterName: response.reportParameterName ? response.reportParameterName : undefined
});
this.dataSource.connect().next(this.reportParametersData);
this.isReportParametersChanged = true;
}
@@ -140,10 +182,14 @@ export class EditReportComponent implements OnInit {
});
editReportParameterDialogRef.afterClosed().subscribe((response: any) => {
if (response !== '') {
this.reportParametersData[this.reportParametersData.indexOf(reportParameter)] = { id: reportParameter.id,
parameterName: this.reportTemplateData.allowedParameters.find((allowedParameter: any) => allowedParameter.id === response.parameterName).parameterName,
this.reportParametersData[this.reportParametersData.indexOf(reportParameter)] = {
id: reportParameter.id,
parameterName: this.reportTemplateData.allowedParameters.find(
(allowedParameter: any) => allowedParameter.id === response.parameterName
).parameterName,
parameterId: response.parameterName,
reportParameterName: response.reportParameterName };
reportParameterName: response.reportParameterName
};
this.dataSource.connect().next(this.reportParametersData);
this.isReportParametersChanged = true;
}
@@ -171,22 +217,21 @@ export class EditReportComponent implements OnInit {
* Toggles the visibility status of Report Sub Type dropdown.
*/
toggleVisibility() {
this.reportForm.get('reportType').valueChanges
.subscribe(type => {
switch (type) {
case 'Chart':
this.reportForm.get('reportSubType').enable();
this.reportForm.get('reportSql').enable();
break;
case 'Pentaho':
this.reportForm.get('reportSql').disable();
this.reportForm.get('reportSubType').disable();
break;
default:
this.reportForm.get('reportSql').enable();
this.reportForm.get('reportSubType').disable();
}
});
this.reportForm.get('reportType').valueChanges.subscribe((type) => {
switch (type) {
case 'Chart':
this.reportForm.get('reportSubType').enable();
this.reportForm.get('reportSql').enable();
break;
case 'Pentaho':
this.reportForm.get('reportSql').disable();
this.reportForm.get('reportSubType').disable();
break;
default:
this.reportForm.get('reportSql').enable();
this.reportForm.get('reportSubType').disable();
}
});
}
/**
@@ -198,15 +243,13 @@ export class EditReportComponent implements OnInit {
this.reportForm.value.reportParameters = undefined;
} else {
this.reportForm.value.reportParameters = this.reportParametersData;
this.reportForm.value.reportParameters.map( function(reportParameter: any) {
this.reportForm.value.reportParameters.map(function (reportParameter: any) {
reportParameter.parameterName = undefined;
return reportParameter;
});
}
this.systemService.updateReport(this.reportData.id, this.reportForm.value)
.subscribe(() => {
this.router.navigate(['../'], { relativeTo: this.route });
});
this.systemService.updateReport(this.reportData.id, this.reportForm.value).subscribe(() => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
}
@@ -8,9 +8,8 @@ describe('ManageReportsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ManageReportsComponent ]
})
.compileComponents();
declarations: [ManageReportsComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -22,23 +22,29 @@ import { CompletionDialogComponent } from '../../configuration-wizard/completion
styleUrls: ['./manage-reports.component.scss']
})
export class ManageReportsComponent implements OnInit, AfterViewInit {
/** Reports Data. */
reportsData: any;
/** Columns to be displayed in reports table. */
displayedColumns: string[] = ['reportName', 'reportType', 'reportSubType', 'reportCategory', 'coreReport', 'userReport'];
displayedColumns: string[] = [
'reportName',
'reportType',
'reportSubType',
'reportCategory',
'coreReport',
'userReport'
];
/** Data source for reports table. */
dataSource: MatTableDataSource<any>;
/** Paginator for reports table. */
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
/** Sorter for reports table. */
@ViewChild(MatSort, { static: true }) sort: MatSort;
/** Paginator for reports table. */
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
/** Sorter for reports table. */
@ViewChild(MatSort, { static: true }) sort: MatSort;
/* Reference of Create Report Button */
@ViewChild('buttonCreateReport') buttonCreateReport: ElementRef<any>;
/* Template for popover on Create Report Button */
@ViewChild('templateButtonCreateReport') templateButtonCreateReport: TemplateRef<any>;
/* Reference of Create Report Button */
@ViewChild('buttonCreateReport') buttonCreateReport: ElementRef<any>;
/* Template for popover on Create Report Button */
@ViewChild('templateButtonCreateReport') templateButtonCreateReport: TemplateRef<any>;
/**
* Retrieves the reports data from `resolve`.
@@ -48,11 +54,13 @@ export class ManageReportsComponent implements OnInit, AfterViewInit {
* @param {PopoverService} popoverService PopoverService.
* @param {Matdialog} matdialog Matdialog.
*/
constructor(private route: ActivatedRoute,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService,
private dialog: MatDialog) {
constructor(
private route: ActivatedRoute,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService,
private dialog: MatDialog
) {
this.route.data.subscribe((data: { reports: any }) => {
this.reportsData = data.reports;
});
@@ -100,7 +108,12 @@ export class ManageReportsComponent implements OnInit, AfterViewInit {
* @param position String.
* @param backdrop Boolean.
*/
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void {
showPopover(
template: TemplateRef<any>,
target: HTMLElement | ElementRef<any>,
position: string,
backdrop: boolean
): void {
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
}
@@ -123,7 +136,7 @@ export class ManageReportsComponent implements OnInit, AfterViewInit {
* Completed Configuration Wizard Tour Dialog.
*/
openNextStepDialog() {
const completionDialogRef = this.dialog.open( CompletionDialogComponent );
const completionDialogRef = this.dialog.open(CompletionDialogComponent);
completionDialogRef.afterClosed().subscribe(() => {
this.router.navigate(['/home']);
});
@@ -8,9 +8,8 @@ describe('AddReportParameterDialogComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ReportParameterDialogComponent ]
})
.compileComponents();
declarations: [ReportParameterDialogComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -12,7 +12,6 @@ import { UntypedFormGroup, UntypedFormBuilder, Validators } from '@angular/forms
styleUrls: ['./report-parameter-dialog.component.scss']
})
export class ReportParameterDialogComponent implements OnInit {
/** Report Parameter Form. */
reportParameterForm: UntypedFormGroup;
@@ -21,18 +20,22 @@ export class ReportParameterDialogComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder.
* @param {any} data Provides the allowed parameters and values for the form (if available).
*/
constructor(public dialogRef: MatDialogRef<ReportParameterDialogComponent>,
public formBuilder: UntypedFormBuilder,
@Inject(MAT_DIALOG_DATA) public data: any) {
}
constructor(
public dialogRef: MatDialogRef<ReportParameterDialogComponent>,
public formBuilder: UntypedFormBuilder,
@Inject(MAT_DIALOG_DATA) public data: any
) {}
/**
* Creates the add report parameter form.
*/
ngOnInit() {
this.reportParameterForm = this.formBuilder.group({
'parameterName': [this.data.parameterName, Validators.required],
'reportParameterName': [this.data.reportParameterName]
parameterName: [
this.data.parameterName,
Validators.required
],
reportParameterName: [this.data.reportParameterName]
});
}
@@ -42,5 +45,4 @@ export class ReportParameterDialogComponent implements OnInit {
submit() {
this.dialogRef.close(this.reportParameterForm.value);
}
}
@@ -13,7 +13,6 @@ import { SystemService } from '../system.service';
*/
@Injectable()
export class ReportTemplateResolver implements Resolve<Object> {
/**
* @param {SystemService} systemService System service.
*/
@@ -26,5 +25,4 @@ export class ReportTemplateResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.systemService.getReportTemplate();
}
}
@@ -13,7 +13,6 @@ import { SystemService } from '../system.service';
*/
@Injectable()
export class ReportResolver implements Resolve<Object> {
/**
* @param {SystemService} systemService System service.
*/
@@ -27,5 +26,4 @@ export class ReportResolver implements Resolve<Object> {
const reportId = route.paramMap.get('id');
return this.systemService.getReport(reportId);
}
}
@@ -13,7 +13,6 @@ import { SystemService } from '../system.service';
*/
@Injectable()
export class ReportsResolver implements Resolve<Object> {
/**
* @param {SystemService} systemService System service.
*/
@@ -26,5 +25,4 @@ export class ReportsResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.systemService.getReports();
}
}
@@ -8,9 +8,8 @@ describe('ViewReportComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewReportComponent ]
})
.compileComponents();
declarations: [ViewReportComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -18,7 +18,6 @@ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.co
styleUrls: ['./view-report.component.scss']
})
export class ViewReportComponent {
/** Report Data. */
reportData: any;
@@ -29,10 +28,12 @@ export class ViewReportComponent {
* @param {MatDialog} dialog Dialog Reference.
* @param {Router} router Router for navigation.
*/
constructor(private route: ActivatedRoute,
private systemService: SystemService,
private dialog: MatDialog,
private router: Router) {
constructor(
private route: ActivatedRoute,
private systemService: SystemService,
private dialog: MatDialog,
private router: Router
) {
this.route.data.subscribe((data: { report: any }) => {
this.reportData = data.report;
});
@@ -47,10 +48,9 @@ export class ViewReportComponent {
});
deleteReportDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.systemService.deleteReport(this.reportData.id)
.subscribe(() => {
this.router.navigate(['/system/reports']);
});
this.systemService.deleteReport(this.reportData.id).subscribe(() => {
this.router.navigate(['/system/reports']);
});
}
});
}