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
@@ -1,5 +1,15 @@
/** Angular Imports */
import { Component, OnInit, TemplateRef, ElementRef, ViewChild, AfterViewInit, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
import {
Component,
OnInit,
TemplateRef,
ElementRef,
ViewChild,
AfterViewInit,
OnDestroy,
OnChanges,
SimpleChanges
} from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { UntypedFormBuilder, UntypedFormControl, Validators } from '@angular/forms';
@@ -27,7 +37,6 @@ import { Currency } from 'app/shared/models/general.model';
styleUrls: ['./manage-currencies.component.scss']
})
export class ManageCurrenciesComponent implements OnInit, AfterViewInit, OnDestroy, OnChanges {
/** Selected Currencies data. */
selectedCurrencies: any[];
/** Currency options data */
@@ -56,23 +65,23 @@ export class ManageCurrenciesComponent implements OnInit, AfterViewInit, OnDestr
* @param {OrganizationService} organizationservice Organization Service
* @param {MatDialog} dialog Mat Dialog
*/
constructor(private route: ActivatedRoute,
private formBuilder: UntypedFormBuilder,
private organizationservice: OrganizationService,
public dialog: MatDialog,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) {
this.route.parent.data.subscribe(( data: { currencies: any }) => {
constructor(
private route: ActivatedRoute,
private formBuilder: UntypedFormBuilder,
private organizationservice: OrganizationService,
public dialog: MatDialog,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService
) {
this.route.parent.data.subscribe((data: { currencies: any }) => {
this.selectedCurrencies = data.currencies.selectedCurrencyOptions;
this.currencyList = data.currencies.currencyOptions;
});
}
ngOnInit() {
this.filterFormCtrl.valueChanges
.pipe(takeUntil(this._onDestroy))
.subscribe(() => {
this.filterFormCtrl.valueChanges.pipe(takeUntil(this._onDestroy)).subscribe(() => {
this.searchItem();
});
this.createCurrencyForm();
@@ -94,7 +103,10 @@ export class ManageCurrenciesComponent implements OnInit, AfterViewInit, OnDestr
*/
createCurrencyForm() {
this.currencyForm = this.formBuilder.group({
'currency': ['', Validators.required]
currency: [
'',
Validators.required
]
});
}
@@ -103,11 +115,13 @@ export class ManageCurrenciesComponent implements OnInit, AfterViewInit, OnDestr
const search: string = this.filterFormCtrl.value.toLowerCase();
if (!search) {
this.currencyData.next(this.currencyList.slice());
this.currencyData.next(this.currencyList.slice());
} else {
this.currencyData.next(this.currencyList.filter((option: Currency) => {
return option.name.toLowerCase().indexOf(search) >= 0 || option.code.toLowerCase().indexOf(search) >= 0;
}));
this.currencyData.next(
this.currencyList.filter((option: Currency) => {
return option.name.toLowerCase().indexOf(search) >= 0 || option.code.toLowerCase().indexOf(search) >= 0;
})
);
}
}
}
@@ -117,18 +131,17 @@ export class ManageCurrenciesComponent implements OnInit, AfterViewInit, OnDestr
*/
addCurrency() {
const newCurrency = this.currencyForm.value.currency;
const selectedCurrencyCodes: any[] = this.selectedCurrencies.map(currency => currency.code);
const selectedCurrencyCodes: any[] = this.selectedCurrencies.map((currency) => currency.code);
if (!selectedCurrencyCodes.includes(newCurrency.code)) {
selectedCurrencyCodes.push(newCurrency.code);
this.organizationservice.updateCurrencies(selectedCurrencyCodes)
.subscribe((response: any) => {
this.selectedCurrencies.push(newCurrency);
this.formRef.resetForm();
if (this.configurationWizardService.showCurrencyForm === true) {
this.configurationWizardService.showCurrencyForm = false;
this.openDialog();
}
});
this.organizationservice.updateCurrencies(selectedCurrencyCodes).subscribe((response: any) => {
this.selectedCurrencies.push(newCurrency);
this.formRef.resetForm();
if (this.configurationWizardService.showCurrencyForm === true) {
this.configurationWizardService.showCurrencyForm = false;
this.openDialog();
}
});
}
}
@@ -138,30 +151,34 @@ export class ManageCurrenciesComponent implements OnInit, AfterViewInit, OnDestr
* @param {number} index Index
*/
deleteCurrency(currencyCode: string, index: number) {
const selectedCurrencyCodes: any[] = this.selectedCurrencies.map(currency => currency.code);
const selectedCurrencyCodes: any[] = this.selectedCurrencies.map((currency) => currency.code);
selectedCurrencyCodes.splice(index, 1);
const deleteCurrencyDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `currency: ${currencyCode}` }
});
deleteCurrencyDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.organizationservice.updateCurrencies(selectedCurrencyCodes)
.subscribe(() => {
this.selectedCurrencies.splice(index, 1);
this.formRef.resetForm();
});
this.organizationservice.updateCurrencies(selectedCurrencyCodes).subscribe(() => {
this.selectedCurrencies.splice(index, 1);
this.formRef.resetForm();
});
}
});
}
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);
}
ngAfterViewInit() {
if (this.configurationWizardService.showCurrencyForm === true) {
setTimeout(() => {
this.showPopover(this.templateCurrencyFormRef, this.currencyFormRef.nativeElement, 'bottom', true);
this.showPopover(this.templateCurrencyFormRef, this.currencyFormRef.nativeElement, 'bottom', true);
});
}
}
@@ -182,10 +199,10 @@ export class ManageCurrenciesComponent implements OnInit, AfterViewInit, OnDestr
const continueSetupDialogRef = this.dialog.open(ContinueSetupDialogComponent, {
data: {
stepName: 'currency'
},
}
});
continueSetupDialogRef.afterClosed().subscribe((response: { step: number }) => {
if (response.step === 1) {
if (response.step === 1) {
this.configurationWizardService.showCurrencyForm = false;
this.router.navigate(['../'], { relativeTo: this.route });
} else if (response.step === 2) {