build: Use prettier for typescript
Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
@@ -8,9 +8,8 @@ describe('CurrenciesComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CurrenciesComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [CurrenciesComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -20,12 +20,14 @@ import { ConfigurationWizardService } from '../../configuration-wizard/configura
|
||||
templateUrl: './currencies.component.html',
|
||||
styleUrls: ['./currencies.component.scss']
|
||||
})
|
||||
export class CurrenciesComponent implements OnInit, AfterViewInit {
|
||||
|
||||
export class CurrenciesComponent implements OnInit, AfterViewInit {
|
||||
/** Currencies data. */
|
||||
currenciesData: any;
|
||||
/** Columns to be displayed in currencies table. */
|
||||
displayedColumns: string[] = ['name', 'code'];
|
||||
displayedColumns: string[] = [
|
||||
'name',
|
||||
'code'
|
||||
];
|
||||
/** Data source for currencies table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
@@ -50,11 +52,13 @@ export class CurrenciesComponent implements OnInit, AfterViewInit {
|
||||
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
|
||||
* @param {PopoverService} popoverService PopoverService.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private configurationWizardService: ConfigurationWizardService,
|
||||
private popoverService: PopoverService) {
|
||||
this.route.data.subscribe(( data: { currencies: any }) => {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private configurationWizardService: ConfigurationWizardService,
|
||||
private popoverService: PopoverService
|
||||
) {
|
||||
this.route.data.subscribe((data: { currencies: any }) => {
|
||||
this.currenciesData = data.currencies.selectedCurrencyOptions;
|
||||
});
|
||||
}
|
||||
@@ -90,7 +94,12 @@ export class CurrenciesComponent 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);
|
||||
}
|
||||
|
||||
@@ -100,13 +109,13 @@ export class CurrenciesComponent implements OnInit, AfterViewInit {
|
||||
ngAfterViewInit() {
|
||||
if (this.configurationWizardService.showCurrencyPage === true) {
|
||||
setTimeout(() => {
|
||||
this.showPopover(this.templateButtonAddEdit, this.buttonAddEdit.nativeElement, 'bottom', true);
|
||||
this.showPopover(this.templateButtonAddEdit, this.buttonAddEdit.nativeElement, 'bottom', true);
|
||||
});
|
||||
}
|
||||
|
||||
if (this.configurationWizardService.showCurrencyList === true) {
|
||||
setTimeout(() => {
|
||||
this.showPopover(this.templateTableCurrencies, this.tableCurrencies.nativeElement, 'top', true);
|
||||
this.showPopover(this.templateTableCurrencies, this.tableCurrencies.nativeElement, 'top', true);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -130,5 +139,4 @@ export class CurrenciesComponent implements OnInit, AfterViewInit {
|
||||
this.configurationWizardService.showAddEditCurrency = true;
|
||||
this.router.navigate(['/organization']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import { OrganizationService } from '../organization.service';
|
||||
*/
|
||||
@Injectable()
|
||||
export class CurrenciesResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {OrganizationService} organizationService Organization service.
|
||||
*/
|
||||
@@ -26,5 +25,4 @@ export class CurrenciesResolver implements Resolve<Object> {
|
||||
resolve(): Observable<any> {
|
||||
return this.organizationService.getCurrencies();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -8,9 +8,8 @@ describe('ManageCurrenciesComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ManageCurrenciesComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [ManageCurrenciesComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user