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('BreadcrumbComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ BreadcrumbComponent ]
})
.compileComponents();
declarations: [BreadcrumbComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -1,5 +1,5 @@
/** Angular Imports */
import { Component, TemplateRef, ElementRef , ViewChild, AfterViewInit} from '@angular/core';
import { Component, TemplateRef, ElementRef, ViewChild, AfterViewInit } from '@angular/core';
import { ActivatedRoute, Router, NavigationEnd, Data } from '@angular/router';
/** rxjs Imports */
@@ -51,7 +51,6 @@ const routeAddBreadcrumbLink = 'addBreadcrumbLink';
styleUrls: ['./breadcrumb.component.scss']
})
export class BreadcrumbComponent implements AfterViewInit {
/** Array of breadcrumbs. */
breadcrumbs: Breadcrumb[];
/* Reference of breadcrumb */
@@ -66,11 +65,13 @@ export class BreadcrumbComponent implements AfterViewInit {
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService.
*/
constructor(private activatedRoute: ActivatedRoute,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService,
private translateService: TranslateService) {
constructor(
private activatedRoute: ActivatedRoute,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService,
private translateService: TranslateService
) {
this.generateBreadcrumbs();
}
@@ -78,7 +79,7 @@ export class BreadcrumbComponent implements AfterViewInit {
* Generates the array of breadcrumbs for the visited route.
*/
generateBreadcrumbs() {
const onNavigationEnd = this.router.events.pipe(filter(event => event instanceof NavigationEnd));
const onNavigationEnd = this.router.events.pipe(filter((event) => event instanceof NavigationEnd));
onNavigationEnd.subscribe(() => {
this.breadcrumbs = [];
@@ -90,7 +91,7 @@ export class BreadcrumbComponent implements AfterViewInit {
let breadcrumbLabel: any;
let url: any;
childrenRoutes.forEach(route => {
childrenRoutes.forEach((route) => {
currentRoute = route;
breadcrumbLabel = false;
@@ -98,22 +99,28 @@ export class BreadcrumbComponent implements AfterViewInit {
return;
}
const routeURL = route.snapshot.url.map(segment => segment.path).join('/');
const routeURL = route.snapshot.url.map((segment) => segment.path).join('/');
currentUrl += `/${routeURL}`;
if (currentUrl === '/') {
breadcrumbLabel = 'Home';
}
const hasData = (route.routeConfig && route.routeConfig.data);
const hasData = route.routeConfig && route.routeConfig.data;
if (hasData) {
if (route.snapshot.data.hasOwnProperty(routeResolveBreadcrumb) && route.snapshot.data[routeResolveBreadcrumb]) {
if (
route.snapshot.data.hasOwnProperty(routeResolveBreadcrumb) &&
route.snapshot.data[routeResolveBreadcrumb]
) {
breadcrumbLabel = route.snapshot.data;
route.snapshot.data[routeResolveBreadcrumb].forEach((property: any) => {
breadcrumbLabel = breadcrumbLabel[property];
});
} else if (route.snapshot.data.hasOwnProperty(routeParamBreadcrumb) && route.snapshot.paramMap.get(route.snapshot.data[routeParamBreadcrumb])) {
} else if (
route.snapshot.data.hasOwnProperty(routeParamBreadcrumb) &&
route.snapshot.paramMap.get(route.snapshot.data[routeParamBreadcrumb])
) {
breadcrumbLabel = route.snapshot.paramMap.get(route.snapshot.data[routeParamBreadcrumb]);
const routeData: Data = route.snapshot.data;
if (routeData.breadcrumb === 'Clients') {
@@ -124,11 +131,23 @@ export class BreadcrumbComponent implements AfterViewInit {
} else if (routeData.breadcrumb === 'Centers') {
breadcrumbLabel = routeData.centerViewData.name;
} else if (routeData.breadcrumb === 'Loans') {
breadcrumbLabel = this.printableValue(routeData.loanDetailsData.loanProductName) + ' (' + routeData.loanDetailsData.accountNo + ')';
breadcrumbLabel =
this.printableValue(routeData.loanDetailsData.loanProductName) +
' (' +
routeData.loanDetailsData.accountNo +
')';
} else if (routeData.breadcrumb === 'Savings') {
breadcrumbLabel = this.printableValue(routeData.savingsAccountData.savingsProductName) + ' (' + routeData.savingsAccountData.accountNo + ')';
breadcrumbLabel =
this.printableValue(routeData.savingsAccountData.savingsProductName) +
' (' +
routeData.savingsAccountData.accountNo +
')';
} else if (routeData.breadcrumb === 'Fixed Deposits') {
breadcrumbLabel = this.printableValue(routeData.fixedDepositsAccountData.depositProductName) + ' (' + routeData.fixedDepositsAccountData.accountNo + ')';
breadcrumbLabel =
this.printableValue(routeData.fixedDepositsAccountData.depositProductName) +
' (' +
routeData.fixedDepositsAccountData.accountNo +
')';
} else if (routeData.breadcrumb === 'Loan Products') {
breadcrumbLabel = this.printableValue(routeData.loanProduct.name);
} else if (routeData.breadcrumb === 'Charges') {
@@ -159,7 +178,7 @@ export class BreadcrumbComponent implements AfterViewInit {
}
}
if (url !== undefined) {
if (url.length > 8 && url.search(`/clients/`) > 0 ) {
if (url.length > 8 && url.search(`/clients/`) > 0) {
const replaceGeneral = `/general/`;
let currentUrlTemp = url.replace(replaceGeneral, `/`);
currentUrlTemp = currentUrlTemp.replace(`//`, `/`);
@@ -197,7 +216,12 @@ export class BreadcrumbComponent implements 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);
}
@@ -206,7 +230,7 @@ export class BreadcrumbComponent implements AfterViewInit {
*/
ngAfterViewInit() {
if (this.configurationWizardService.showBreadcrumbs === true) {
setTimeout(() => {
setTimeout(() => {
this.showPopover(this.templateBreadcrumb, this.breadcrumb.nativeElement, 'bottom', true);
});
}
@@ -237,8 +261,7 @@ export class BreadcrumbComponent implements AfterViewInit {
getTranslate(text: string): any {
const key: string = 'labels.text.' + text;
const translation = this.translateService.instant(key);
const result = (translation !== key) ? translation : text;
const result = translation !== key ? translation : text;
return result;
}
}
@@ -8,9 +8,8 @@ describe('ContentComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ContentComponent ]
})
.compileComponents();
declarations: [ContentComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -10,7 +10,5 @@ import { Component } from '@angular/core';
styleUrls: ['./content.component.scss']
})
export class ContentComponent {
constructor() { }
constructor() {}
}
+2 -3
View File
@@ -8,9 +8,8 @@ describe('ShellComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ShellComponent ]
})
.compileComponents();
declarations: [ShellComponent]
}).compileComponents();
}));
beforeEach(() => {
+8 -9
View File
@@ -18,12 +18,10 @@ import { ProgressBarService } from '../progress-bar/progress-bar.service';
styleUrls: ['./shell.component.scss']
})
export class ShellComponent implements OnInit, OnDestroy {
/** Subscription to breakpoint observer for handset. */
isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset)
.pipe(
map(result => result.matches)
);
isHandset$: Observable<boolean> = this.breakpointObserver
.observe(Breakpoints.Handset)
.pipe(map((result) => result.matches));
/** Sets the initial state of sidenav as collapsed. Not collapsed if false. */
sidenavCollapsed = true;
/** Progress bar mode. */
@@ -36,9 +34,11 @@ export class ShellComponent implements OnInit, OnDestroy {
* @param {ProgressBarService} progressBarService Progress Bar Service.
* @param {ChangeDetectorRef} cdr Change Detector Ref.
*/
constructor(private breakpointObserver: BreakpointObserver,
private progressBarService: ProgressBarService,
private cdr: ChangeDetectorRef) { }
constructor(
private breakpointObserver: BreakpointObserver,
private progressBarService: ProgressBarService,
private cdr: ChangeDetectorRef
) {}
/**
* Subscribes to progress bar to update its mode.
@@ -67,5 +67,4 @@ export class ShellComponent implements OnInit, OnDestroy {
this.progressBar$.unsubscribe();
}
}
}
@@ -53,5 +53,5 @@ export const frequentActivities: any[] = [
path: '/self-service',
icon: 'laptop',
toolTip: 'Self Service'
},
}
];
@@ -8,9 +8,8 @@ describe('SidenavComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SidenavComponent ]
})
.compileComponents();
declarations: [SidenavComponent]
}).compileComponents();
}));
beforeEach(() => {
+32 -24
View File
@@ -1,6 +1,5 @@
/** Angular Imports */
import { Component, OnInit, Input, TemplateRef, ElementRef , ViewChild,
AfterViewInit } from '@angular/core';
import { Component, OnInit, Input, TemplateRef, ElementRef, ViewChild, AfterViewInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Router } from '@angular/router';
@@ -25,7 +24,6 @@ import { SettingsService } from 'app/settings/settings.service';
styleUrls: ['./sidenav.component.scss']
})
export class SidenavComponent implements OnInit, AfterViewInit {
/** True if sidenav is in collapsed state. */
@Input() sidenavCollapsed: boolean;
/** Tooltip position */
@@ -48,7 +46,6 @@ export class SidenavComponent implements OnInit, AfterViewInit {
/* Template for popover on chart of accounts */
@ViewChild('templateChartOfAccounts') templateChartOfAccounts: TemplateRef<any>;
/**
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Mat Dialog
@@ -57,12 +54,14 @@ export class SidenavComponent implements OnInit, AfterViewInit {
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService.
*/
constructor(private router: Router,
public dialog: MatDialog,
private authenticationService: AuthenticationService,
private settingsService: SettingsService,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) {
constructor(
private router: Router,
public dialog: MatDialog,
private authenticationService: AuthenticationService,
private settingsService: SettingsService,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService
) {
this.userActivity = JSON.parse(localStorage.getItem('mifosXLocation'));
}
@@ -79,8 +78,7 @@ export class SidenavComponent implements OnInit, AfterViewInit {
* Logs out the authenticated user and redirects to login page.
*/
logout() {
this.authenticationService.logout()
.subscribe(() => this.router.navigate(['/login'], { replaceUrl: true }));
this.authenticationService.logout().subscribe(() => this.router.navigate(['/login'], { replaceUrl: true }));
}
/**
@@ -102,18 +100,24 @@ export class SidenavComponent implements OnInit, AfterViewInit {
* Returns top three frequent activities.
*/
getFrequentActivities() {
const frequencyCounts: any = {};
let index = this.userActivity.length;
const frequencyCounts: any = {};
let index = this.userActivity.length;
while (index) {
frequencyCounts[this.userActivity[--index]] = (frequencyCounts[this.userActivity[index]] || 0) + 1;
}
const frequencyCountsArray = Object.entries(frequencyCounts);
const topThreeFrequentActivities =
frequencyCountsArray
.sort((a: any, b: any) => b[1] - a[1])
.map((entry: any[]) => entry[0])
.filter((activity: string) => !['/', '/login', '/home', '/dashboard'].includes(activity))
.slice(0, 3);
const topThreeFrequentActivities = frequencyCountsArray
.sort((a: any, b: any) => b[1] - a[1])
.map((entry: any[]) => entry[0])
.filter(
(activity: string) => ![
'/',
'/login',
'/home',
'/dashboard'
].includes(activity)
)
.slice(0, 3);
return topThreeFrequentActivities;
}
@@ -168,7 +172,12 @@ export class SidenavComponent 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);
}
@@ -178,12 +187,12 @@ export class SidenavComponent implements OnInit, AfterViewInit {
ngAfterViewInit() {
if (this.configurationWizardService.showSideNav === true) {
setTimeout(() => {
this.showPopover(this.templateLogo, this.logo.nativeElement, 'bottom', true);
this.showPopover(this.templateLogo, this.logo.nativeElement, 'bottom', true);
});
}
if (this.configurationWizardService.showSideNavChartofAccounts === true) {
setTimeout(() => {
this.showPopover(this.templateChartOfAccounts, this.chartOfAccounts.nativeElement, 'top', true);
this.showPopover(this.templateChartOfAccounts, this.chartOfAccounts.nativeElement, 'top', true);
});
}
}
@@ -218,5 +227,4 @@ export class SidenavComponent implements OnInit, AfterViewInit {
}
return this.settingsService.tenantIdentifier;
}
}
@@ -8,9 +8,8 @@ describe('ToolbarComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ToolbarComponent ]
})
.compileComponents();
declarations: [ToolbarComponent]
}).compileComponents();
}));
beforeEach(() => {
+32 -21
View File
@@ -1,5 +1,17 @@
/** Angular Imports */
import { Component, OnInit, Input, EventEmitter, Output, ViewChild, AfterViewInit, ElementRef, TemplateRef, AfterContentChecked, ChangeDetectorRef } from '@angular/core';
import {
Component,
OnInit,
Input,
EventEmitter,
Output,
ViewChild,
AfterViewInit,
ElementRef,
TemplateRef,
AfterContentChecked,
ChangeDetectorRef
} from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { MatSidenav } from '@angular/material/sidenav';
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
@@ -26,7 +38,6 @@ import { ConfigurationWizardComponent } from '../../../configuration-wizard/conf
styleUrls: ['./toolbar.component.scss']
})
export class ToolbarComponent implements OnInit, AfterViewInit, AfterContentChecked {
/* Reference of institution */
@ViewChild('institution') institution: ElementRef<any>;
/* Template for popover on institution */
@@ -36,12 +47,10 @@ export class ToolbarComponent implements OnInit, AfterViewInit, AfterContentChec
/* Template for popover on appMenu */
@ViewChild('templateAppMenu') templateAppMenu: TemplateRef<any>;
/** Subscription to breakpoint observer for handset. */
isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset)
.pipe(
map(result => result.matches)
);
isHandset$: Observable<boolean> = this.breakpointObserver
.observe(Breakpoints.Handset)
.pipe(map((result) => result.matches));
/** Sets the initial state of sidenav as collapsed. Not collapsed if false. */
sidenavCollapsed = true;
@@ -59,19 +68,21 @@ export class ToolbarComponent implements OnInit, AfterViewInit, AfterContentChec
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService.
*/
constructor(private breakpointObserver: BreakpointObserver,
private router: Router,
private authenticationService: AuthenticationService,
private popoverService: PopoverService,
private configurationWizardService: ConfigurationWizardService,
private dialog: MatDialog,
private changeDetector: ChangeDetectorRef) { }
constructor(
private breakpointObserver: BreakpointObserver,
private router: Router,
private authenticationService: AuthenticationService,
private popoverService: PopoverService,
private configurationWizardService: ConfigurationWizardService,
private dialog: MatDialog,
private changeDetector: ChangeDetectorRef
) {}
/**
* Subscribes to breakpoint for handset.
*/
ngOnInit() {
this.isHandset$.subscribe(isHandset => {
this.isHandset$.subscribe((isHandset) => {
if (isHandset && this.sidenavCollapsed) {
this.toggleSidenavCollapse(false);
}
@@ -101,8 +112,7 @@ export class ToolbarComponent implements OnInit, AfterViewInit, AfterContentChec
* Logs out the authenticated user and redirects to login page.
*/
logout() {
this.authenticationService.logout()
.subscribe(() => this.router.navigate(['/login'], { replaceUrl: true }));
this.authenticationService.logout().subscribe(() => this.router.navigate(['/login'], { replaceUrl: true }));
}
/**
@@ -167,7 +177,6 @@ export class ToolbarComponent implements OnInit, AfterViewInit, AfterContentChec
this.router.navigate(['/organization']);
}
if (response.show === 0) {
}
});
}
@@ -182,8 +191,11 @@ export class ToolbarComponent implements OnInit, AfterViewInit, AfterContentChec
});
}
if (this.configurationWizardService.showSideNav === true || this.configurationWizardService.showSideNavChartofAccounts === true) {
this.toggleSidenavCollapse();
if (
this.configurationWizardService.showSideNav === true ||
this.configurationWizardService.showSideNavChartofAccounts === true
) {
this.toggleSidenavCollapse();
}
if (this.configurationWizardService.showToolbarAdmin === true) {
@@ -196,5 +208,4 @@ export class ToolbarComponent implements OnInit, AfterViewInit, AfterContentChec
navigateMenu(routePath: string): void {
this.router.navigate([routePath]);
}
}