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('DatatableMultiRowComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ DatatableMultiRowComponent ]
})
.compileComponents();
declarations: [DatatableMultiRowComponent]
}).compileComponents();
});
beforeEach(() => {
@@ -22,7 +22,6 @@ import * as _ from 'lodash';
styleUrls: ['./datatable-multi-row.component.scss']
})
export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges {
SELECT_NAME_FIELD = 'select';
/** Data Object */
@Input() dataObject: any;
@@ -55,15 +54,17 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
* @param {MatDialog} dialog Mat Dialog.
* @param {Datatables} datatables Datatable utils
*/
constructor(private route: ActivatedRoute,
private dateUtils: Dates,
private systemService: SystemService,
private settingsService: SettingsService,
private dialog: MatDialog,
private datatables: Datatables,
private dateFormat: DateFormatPipe,
private dateTimeFormat: DatetimeFormatPipe,
private numberFormat: DecimalPipe) { }
constructor(
private route: ActivatedRoute,
private dateUtils: Dates,
private systemService: SystemService,
private settingsService: SettingsService,
private dialog: MatDialog,
private datatables: Datatables,
private dateFormat: DateFormatPipe,
private dateTimeFormat: DatetimeFormatPipe,
private numberFormat: DecimalPipe
) {}
/**
* Fetches data table name from route params.
@@ -117,7 +118,7 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
}
this.isSelected = false;
this.isLoading = false;
});
});
}
/**
@@ -127,7 +128,11 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
let dataTableEntryObject: any = { locale: this.settingsService.language.code };
const dateTransformColumns: string[] = [];
const columns = this.datatables.filterSystemColumns(this.dataObject.columnHeaders);
const formfields: FormfieldBase[] = this.datatables.getFormfields(columns, dateTransformColumns, dataTableEntryObject);
const formfields: FormfieldBase[] = this.datatables.getFormfields(
columns,
dateTransformColumns,
dataTableEntryObject
);
const data = {
title: 'Add ' + this.datatableName + ' for ' + this.entityType,
formfields: formfields
@@ -136,12 +141,17 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
addDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) {
dateTransformColumns.forEach((column) => {
response.data.value[column] = this.dateUtils.formatDate(response.data.value[column], dataTableEntryObject.dateFormat);
response.data.value[column] = this.dateUtils.formatDate(
response.data.value[column],
dataTableEntryObject.dateFormat
);
});
dataTableEntryObject = { ...response.data.value, ...dataTableEntryObject };
this.systemService.addEntityDatatableEntry(this.entityId, this.datatableName, dataTableEntryObject).subscribe((result: any) => {
this.getData();
});
this.systemService
.addEntityDatatableEntry(this.entityId, this.datatableName, dataTableEntryObject)
.subscribe((result: any) => {
this.getData();
});
}
});
}
@@ -179,14 +189,14 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
this.datatableData.splice(index, 1);
this.dataTableRef.renderRows();
this.selection = new SelectionModel(true, []);
this.isSelected = (this.selection.selected.length > 0);
this.isSelected = this.selection.selected.length > 0;
}
});
});
});
} else {
this.selection = new SelectionModel(true, []);
this.isSelected = (this.selection.selected.length > 0);
this.isSelected = this.selection.selected.length > 0;
}
});
}
@@ -219,11 +229,11 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
/** Whether the number of selected elements matches the total number of rows. */
isAllSelected() {
const numSelected = this.selection.selected;
return (this.datatableData.length === numSelected);
return this.datatableData.length === numSelected;
}
isAnySelected() {
return (this.selection.selected && this.selection.selected.length > 0);
return this.selection.selected && this.selection.selected.length > 0;
}
/** Selects all rows if they are not all selected; otherwise clear selection. */
@@ -233,12 +243,12 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
} else {
this.selection = new SelectionModel(true, []);
}
this.isSelected = (this.selection.selected.length > 0);
this.isSelected = this.selection.selected.length > 0;
}
itemToggle(data: any): void {
this.selection.toggle(data);
this.isSelected = (this.selection.selected.length > 0);
this.isSelected = this.selection.selected.length > 0;
}
/** The label for the checkbox on the passed row */
@@ -259,5 +269,4 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
getInputName(attr: string): string {
return this.datatables.getName(attr);
}
}
@@ -8,9 +8,8 @@ describe('DatatableSingleRowComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ DatatableSingleRowComponent ]
})
.compileComponents();
declarations: [DatatableSingleRowComponent]
}).compileComponents();
});
beforeEach(() => {
@@ -15,7 +15,6 @@ import { SystemService } from 'app/system/system.service';
styleUrls: ['./datatable-single-row.component.scss']
})
export class DatatableSingleRowComponent implements OnInit {
@Input() dataObject: any;
@Input() entityId: string;
@Input() entityType: string;
@@ -28,12 +27,14 @@ export class DatatableSingleRowComponent implements OnInit {
* @param {SettingsService} settingsService Settings Service
* @param {Datatables} datatables Datatable utils
*/
constructor(private route: ActivatedRoute,
constructor(
private route: ActivatedRoute,
private dateUtils: Dates,
private dialog: MatDialog,
private settingsService: SettingsService,
private datatables: Datatables,
private systemService: SystemService) { }
private systemService: SystemService
) {}
ngOnInit() {
this.route.params.subscribe((routeParams: any) => {
@@ -47,7 +48,11 @@ export class DatatableSingleRowComponent implements OnInit {
};
const dateTransformColumns: string[] = [];
const columns = this.datatables.filterSystemColumns(this.dataObject.columnHeaders);
const formfields: FormfieldBase[] = this.datatables.getFormfields(columns, dateTransformColumns, dataTableEntryObject);
const formfields: FormfieldBase[] = this.datatables.getFormfields(
columns,
dateTransformColumns,
dataTableEntryObject
);
const data = {
title: 'Add ' + this.datatableName + ' for ' + this.entityType,
formfields: formfields
@@ -56,14 +61,19 @@ export class DatatableSingleRowComponent implements OnInit {
addDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) {
dateTransformColumns.forEach((column) => {
response.data.value[column] = this.dateUtils.formatDate(response.data.value[column], dataTableEntryObject.dateFormat);
response.data.value[column] = this.dateUtils.formatDate(
response.data.value[column],
dataTableEntryObject.dateFormat
);
});
dataTableEntryObject = { ...response.data.value, ...dataTableEntryObject };
this.systemService.addEntityDatatableEntry(this.entityId, this.datatableName, dataTableEntryObject).subscribe(() => {
this.systemService.getEntityDatatable(this.entityId, this.datatableName).subscribe((dataObject: any) => {
this.dataObject = dataObject;
this.systemService
.addEntityDatatableEntry(this.entityId, this.datatableName, dataTableEntryObject)
.subscribe(() => {
this.systemService.getEntityDatatable(this.entityId, this.datatableName).subscribe((dataObject: any) => {
this.dataObject = dataObject;
});
});
});
}
});
}
@@ -74,34 +84,49 @@ export class DatatableSingleRowComponent implements OnInit {
};
const dateTransformColumns: string[] = [];
const columns = this.datatables.filterSystemColumns(this.dataObject.columnHeaders);
let formfields: FormfieldBase[] = this.datatables.getFormfields(columns, dateTransformColumns, dataTableEntryObject);
let formfields: FormfieldBase[] = this.datatables.getFormfields(
columns,
dateTransformColumns,
dataTableEntryObject
);
formfields = formfields.map((formfield: FormfieldBase, index: number) => {
if (formfield.controlType === 'datepicker') {
formfield.value = (this.dataObject.data[0].row[columns[index].idx]) ? this.dateUtils.parseDate(this.dataObject.data[0].row[columns[index].idx]) : '';
formfield.value = this.dataObject.data[0].row[columns[index].idx]
? this.dateUtils.parseDate(this.dataObject.data[0].row[columns[index].idx])
: '';
} else if (formfield.controlType === 'datetimepicker') {
formfield.value = (this.dataObject.data[0].row[columns[index].idx]) ? this.dateUtils.parseDatetime(this.dataObject.data[0].row[columns[index].idx]) : '';
formfield.value = this.dataObject.data[0].row[columns[index].idx]
? this.dateUtils.parseDatetime(this.dataObject.data[0].row[columns[index].idx])
: '';
} else {
formfield.value = (this.dataObject.data[0].row[columns[index].idx]) ? this.dataObject.data[0].row[columns[index].idx] : '';
formfield.value = this.dataObject.data[0].row[columns[index].idx]
? this.dataObject.data[0].row[columns[index].idx]
: '';
}
return formfield;
});
const data = {
title: 'Edit ' + this.datatableName + ' for ' + this.entityType,
formfields: formfields,
layout: {addButtonText: 'Save'}
layout: { addButtonText: 'Save' }
};
const editDialogRef = this.dialog.open(FormDialogComponent, { data, width: '50rem' });
editDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) {
dateTransformColumns.forEach((column) => {
response.data.value[column] = this.dateUtils.formatDate(response.data.value[column], dataTableEntryObject.dateFormat);
response.data.value[column] = this.dateUtils.formatDate(
response.data.value[column],
dataTableEntryObject.dateFormat
);
});
dataTableEntryObject = { ...response.data.value, ...dataTableEntryObject };
this.systemService.editEntityDatatableEntry(this.entityId, this.datatableName, dataTableEntryObject).subscribe(() => {
this.systemService.getEntityDatatable(this.entityId, this.datatableName).subscribe((dataObject: any) => {
this.dataObject = dataObject;
this.systemService
.editEntityDatatableEntry(this.entityId, this.datatableName, dataTableEntryObject)
.subscribe(() => {
this.systemService.getEntityDatatable(this.entityId, this.datatableName).subscribe((dataObject: any) => {
this.dataObject = dataObject;
});
});
});
}
});
}
@@ -112,13 +137,12 @@ export class DatatableSingleRowComponent implements OnInit {
});
deleteDataTableDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.systemService.deleteDatatableContent(this.entityId, this.datatableName)
.subscribe(() => {
this.systemService.getEntityDatatable(this.entityId, this.datatableName).subscribe((dataObject: any) => {
this.dataObject = dataObject;
});
this.systemService.deleteDatatableContent(this.entityId, this.datatableName).subscribe(() => {
this.systemService.getEntityDatatable(this.entityId, this.datatableName).subscribe((dataObject: any) => {
this.dataObject = dataObject;
});
}
});
}
});
}
@@ -167,5 +191,4 @@ export class DatatableSingleRowComponent implements OnInit {
openSite(siteUrl: string) {
window.open(siteUrl, '_blank');
}
}
@@ -8,9 +8,8 @@ describe('EntityDatatableTabComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ EntityDatatableTabComponent ]
})
.compileComponents();
declarations: [EntityDatatableTabComponent]
}).compileComponents();
});
beforeEach(() => {
@@ -6,12 +6,10 @@ import { Component, Input } from '@angular/core';
styleUrls: ['./entity-datatable-tab.component.scss']
})
export class EntityDatatableTabComponent {
@Input() multiRowDatatableFlag = false;
@Input() entityDatatable: any;
@Input() entityType: string;
@Input() entityId: string;
constructor() { }
constructor() {}
}
@@ -8,9 +8,8 @@ describe('EntityDocumentsTabComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ EntityDocumentsTabComponent ]
})
.compileComponents();
declarations: [EntityDocumentsTabComponent]
}).compileComponents();
});
beforeEach(() => {
@@ -32,7 +32,12 @@ export class EntityDocumentsTabComponent implements OnInit {
choice: boolean;
/** Columns to be displayed in loan documents table. */
displayedColumns: string[] = ['name', 'description', 'filename', 'actions'];
displayedColumns: string[] = [
'name',
'description',
'filename',
'actions'
];
/** Data source for loan documents table. */
dataSource: MatTableDataSource<any>;
@@ -48,10 +53,12 @@ export class EntityDocumentsTabComponent implements OnInit {
* @param {LoansService} loansService Loan Account services.
* @param {ClientsService} clientsService Client services.
*/
constructor(public dialog: MatDialog,
constructor(
public dialog: MatDialog,
private savingsService: SavingsService,
private loansService: LoansService,
private clientsService: ClientsService) { }
private clientsService: ClientsService
) {}
ngOnInit() {
this.dataSource = new MatTableDataSource(this.entityDocuments);
@@ -69,7 +76,7 @@ export class EntityDocumentsTabComponent implements OnInit {
});
uploadDocumentDialogRef.afterClosed().subscribe((dialogResponse: any) => {
if (dialogResponse) {
const formData: FormData = new FormData;
const formData: FormData = new FormData();
formData.append('name', dialogResponse.fileName);
formData.append('file', dialogResponse.file);
formData.append('description', dialogResponse.description);
@@ -104,5 +111,4 @@ export class EntityDocumentsTabComponent implements OnInit {
}
});
}
}
@@ -8,9 +8,8 @@ describe('EntityNotesTabComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ EntityNotesTabComponent ]
})
.compileComponents();
declarations: [EntityNotesTabComponent]
}).compileComponents();
});
beforeEach(() => {
@@ -14,7 +14,6 @@ import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.componen
styleUrls: ['./entity-notes-tab.component.scss']
})
export class EntityNotesTabComponent implements OnInit {
@ViewChild('formRef', { static: true }) formRef: any;
@Input() entityId: string;
@@ -26,12 +25,14 @@ export class EntityNotesTabComponent implements OnInit {
noteForm: UntypedFormGroup;
constructor(private formBuilder: UntypedFormBuilder,
constructor(
private formBuilder: UntypedFormBuilder,
private savingsService: SavingsService,
private loansService: LoansService,
private clientsService: ClientsService,
private groupsService: GroupsService,
private dialog: MatDialog) { }
private dialog: MatDialog
) {}
ngOnInit() {
this.createNoteForm();
@@ -39,7 +40,10 @@ export class EntityNotesTabComponent implements OnInit {
createNoteForm() {
this.noteForm = this.formBuilder.group({
'note': ['', Validators.required]
note: [
'',
Validators.required
]
});
}
@@ -50,19 +54,22 @@ export class EntityNotesTabComponent implements OnInit {
editNote(noteId: string, noteContent: string, index: number) {
const editNoteDialogRef = this.dialog.open(FormDialogComponent, {
data: { formfields: [{
controlName: 'note',
required: true,
value: noteContent,
controlType: 'input',
label: 'Note'
}],
layout: {
columns: 1,
addButtonText: 'Confirm'
},
title: 'Edit Note'
}
data: {
formfields: [
{
controlName: 'note',
required: true,
value: noteContent,
controlType: 'input',
label: 'Note'
}
],
layout: {
columns: 1,
addButtonText: 'Confirm'
},
title: 'Edit Note'
}
});
editNoteDialogRef.afterClosed().subscribe((response: any) => {
if (response.data && response.data.value.note !== noteContent) {
@@ -81,5 +88,4 @@ export class EntityNotesTabComponent implements OnInit {
}
});
}
}