build: Use prettier for typescript
Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
@@ -4,75 +4,86 @@ import { Pipe, PipeTransform } from '@angular/core';
|
||||
name: 'accountsFilter'
|
||||
})
|
||||
export class AccountsFilterPipe implements PipeTransform {
|
||||
|
||||
transform(accounts: any, type: any, status: any, checkSavings: any): any {
|
||||
if (accounts) {
|
||||
if (type === 'loan') {
|
||||
if (status === 'closed') {
|
||||
accounts = accounts.filter((account: any) => {
|
||||
return (account.status.code === 'loanStatusType.closed.written.off' ||
|
||||
return (
|
||||
account.status.code === 'loanStatusType.closed.written.off' ||
|
||||
account.status.code === 'loanStatusType.closed.obligations.met' ||
|
||||
account.status.code === 'loanStatusType.closed.reschedule.outstanding.amount' ||
|
||||
account.status.code === 'loanStatusType.withdrawn.by.client' ||
|
||||
account.status.code === 'loanStatusType.rejected');
|
||||
account.status.code === 'loanStatusType.rejected'
|
||||
);
|
||||
});
|
||||
} else {
|
||||
accounts = accounts.filter((account: any) => {
|
||||
return (account.status.code !== 'loanStatusType.closed.written.off' &&
|
||||
return (
|
||||
account.status.code !== 'loanStatusType.closed.written.off' &&
|
||||
account.status.code !== 'loanStatusType.closed.obligations.met' &&
|
||||
account.status.code !== 'loanStatusType.closed.reschedule.outstanding.amount' &&
|
||||
account.status.code !== 'loanStatusType.withdrawn.by.client' &&
|
||||
account.status.code !== 'loanStatusType.rejected');
|
||||
account.status.code !== 'loanStatusType.rejected'
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (type === 'saving') {
|
||||
if (checkSavings === 'isFixed') {
|
||||
accounts = accounts.filter((account: any) => {
|
||||
return (account.depositType.value === 'Fixed Deposit');
|
||||
return account.depositType.value === 'Fixed Deposit';
|
||||
});
|
||||
} else if (checkSavings === 'isRecurring') {
|
||||
accounts = accounts.filter((account: any) => {
|
||||
return (account.depositType.value === 'Recurring Deposit');
|
||||
return account.depositType.value === 'Recurring Deposit';
|
||||
});
|
||||
} else if (checkSavings === 'isSavings') {
|
||||
accounts = accounts.filter((account: any) => {
|
||||
return (account.depositType.value === 'Savings');
|
||||
return account.depositType.value === 'Savings';
|
||||
});
|
||||
}
|
||||
if (status === 'closed') {
|
||||
accounts = accounts.filter((account: any) => {
|
||||
return (account.status.code === 'savingsAccountStatusType.withdrawn.by.applicant' ||
|
||||
return (
|
||||
account.status.code === 'savingsAccountStatusType.withdrawn.by.applicant' ||
|
||||
account.status.code === 'savingsAccountStatusType.closed' ||
|
||||
account.status.code === 'savingsAccountStatusType.pre.mature.closure' ||
|
||||
account.status.code === 'savingsAccountStatusType.rejected');
|
||||
account.status.code === 'savingsAccountStatusType.rejected'
|
||||
);
|
||||
});
|
||||
} else {
|
||||
accounts = accounts.filter((account: any) => {
|
||||
return (account.status.code !== 'savingsAccountStatusType.withdrawn.by.applicant' &&
|
||||
return (
|
||||
account.status.code !== 'savingsAccountStatusType.withdrawn.by.applicant' &&
|
||||
account.status.code !== 'savingsAccountStatusType.closed' &&
|
||||
account.status.code !== 'savingsAccountStatusType.pre.mature.closure' &&
|
||||
account.status.code !== 'savingsAccountStatusType.rejected');
|
||||
account.status.code !== 'savingsAccountStatusType.rejected'
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (type === 'share') {
|
||||
if (status === 'closed') {
|
||||
accounts = accounts.filter((account: any) => {
|
||||
return (account.status.code === 'shareAccountStatusType.closed' ||
|
||||
account.status.code === 'shareAccountStatusType.rejected');
|
||||
return (
|
||||
account.status.code === 'shareAccountStatusType.closed' ||
|
||||
account.status.code === 'shareAccountStatusType.rejected'
|
||||
);
|
||||
});
|
||||
} else {
|
||||
accounts = accounts.filter((account: any) => {
|
||||
return (account.status.code !== 'shareAccountStatusType.closed' &&
|
||||
account.status.code !== 'shareAccountStatusType.rejected');
|
||||
return (
|
||||
account.status.code !== 'shareAccountStatusType.closed' &&
|
||||
account.status.code !== 'shareAccountStatusType.rejected'
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (type === 'guarantor') {
|
||||
if (status === false) {
|
||||
accounts = accounts.filter((account: any) => {
|
||||
return (account.status === true);
|
||||
return account.status === true;
|
||||
});
|
||||
} else {
|
||||
return accounts;
|
||||
@@ -80,7 +91,7 @@ export class AccountsFilterPipe implements PipeTransform {
|
||||
}
|
||||
if (type === 'clientApproval') {
|
||||
accounts = accounts.filter((account: any) => {
|
||||
return (account.active === false && account.status.value === 'Pending');
|
||||
return account.active === false && account.status.value === 'Pending';
|
||||
});
|
||||
}
|
||||
return accounts;
|
||||
|
||||
@@ -4,11 +4,14 @@ import { Pipe, PipeTransform } from '@angular/core';
|
||||
name: 'chargesFilter'
|
||||
})
|
||||
export class ChargesFilterPipe implements PipeTransform {
|
||||
|
||||
transform(charges: any, chargesDataSource: any, currencyCode: string, multiDisburseLoan?: boolean): any {
|
||||
if (charges) {
|
||||
charges = charges.filter((charge: any) => {
|
||||
if ((charge.currency.code !== currencyCode) || (!!multiDisburseLoan && charge.chargeTimeType.id === 12) || chargesDataSource.filter((chargeData: any) => chargeData.id === charge.id).length) {
|
||||
if (
|
||||
charge.currency.code !== currencyCode ||
|
||||
(!!multiDisburseLoan && charge.chargeTimeType.id === 12) ||
|
||||
chargesDataSource.filter((chargeData: any) => chargeData.id === charge.id).length
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -16,5 +19,4 @@ export class ChargesFilterPipe implements PipeTransform {
|
||||
}
|
||||
return charges;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import { Pipe, PipeTransform } from '@angular/core';
|
||||
name: 'chargesPenaltyFilter'
|
||||
})
|
||||
export class ChargesPenaltyFilterPipe implements PipeTransform {
|
||||
|
||||
transform(charges: any, penalty: boolean): any {
|
||||
if (charges) {
|
||||
charges = charges.filter((charge: any) => {
|
||||
@@ -16,5 +15,4 @@ export class ChargesPenaltyFilterPipe implements PipeTransform {
|
||||
}
|
||||
return charges;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,13 +3,11 @@ import { SettingsService } from 'app/settings/settings.service';
|
||||
import { DateFormatPipe } from './date-format.pipe';
|
||||
|
||||
describe('DateFormatPipe', () => {
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ SettingsService ],
|
||||
declarations: [ DateFormatPipe ]
|
||||
})
|
||||
.compileComponents();
|
||||
imports: [SettingsService],
|
||||
declarations: [DateFormatPipe]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
it('create an instance', () => {
|
||||
|
||||
@@ -6,9 +6,7 @@ import * as moment from 'moment';
|
||||
name: 'dateFormat'
|
||||
})
|
||||
export class DateFormatPipe implements PipeTransform {
|
||||
|
||||
constructor(private settingsService: SettingsService) {
|
||||
}
|
||||
constructor(private settingsService: SettingsService) {}
|
||||
|
||||
transform(value: any, dateFormat?: string): any {
|
||||
const defaultDateFormat = this.settingsService.dateFormat.replace('dd', 'DD');
|
||||
@@ -27,5 +25,4 @@ export class DateFormatPipe implements PipeTransform {
|
||||
}
|
||||
return dateVal.format(dateFormat);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,9 +6,7 @@ import * as moment from 'moment';
|
||||
name: 'datetimeFormat'
|
||||
})
|
||||
export class DatetimeFormatPipe implements PipeTransform {
|
||||
|
||||
constructor(private settingsService: SettingsService) {
|
||||
}
|
||||
constructor(private settingsService: SettingsService) {}
|
||||
|
||||
transform(value: any, datetimeFormat?: string): any {
|
||||
const defaultDateFormat = this.settingsService.dateFormat.replace('dd', 'DD');
|
||||
|
||||
@@ -4,7 +4,6 @@ import { Pipe, PipeTransform } from '@angular/core';
|
||||
name: 'externalIdentifier'
|
||||
})
|
||||
export class ExternalIdentifierPipe implements PipeTransform {
|
||||
|
||||
transform(externalId: string): string {
|
||||
const limit = 20;
|
||||
if (!externalId) {
|
||||
@@ -17,9 +16,8 @@ export class ExternalIdentifierPipe implements PipeTransform {
|
||||
return values[4];
|
||||
} else {
|
||||
const inputLen = externalId.length;
|
||||
return inputLen > limit ? externalId.substring((inputLen - limit), inputLen) : externalId;
|
||||
return inputLen > limit ? externalId.substring(inputLen - limit, inputLen) : externalId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import { Pipe, PipeTransform } from '@angular/core';
|
||||
name: 'find'
|
||||
})
|
||||
export class FindPipe implements PipeTransform {
|
||||
|
||||
transform(value: any, options: any, key: string, property: string): any {
|
||||
let optionFound;
|
||||
if (options) {
|
||||
@@ -12,5 +11,4 @@ export class FindPipe implements PipeTransform {
|
||||
}
|
||||
return optionFound ? optionFound[property] : '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ import { SettingsService } from 'app/settings/settings.service';
|
||||
name: 'formatNumber'
|
||||
})
|
||||
export class FormatNumberPipe implements PipeTransform {
|
||||
|
||||
constructor(private decimalFormat: DecimalPipe,
|
||||
private settingsService: SettingsService) {
|
||||
}
|
||||
constructor(
|
||||
private decimalFormat: DecimalPipe,
|
||||
private settingsService: SettingsService
|
||||
) {}
|
||||
|
||||
transform(value: string | number, defaultValue: any): string {
|
||||
if (!value) {
|
||||
@@ -19,5 +19,4 @@ export class FormatNumberPipe implements PipeTransform {
|
||||
const format = `1.${decimals}-${decimals}`;
|
||||
return this.decimalFormat.transform(value, format);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,48 +19,53 @@ import { YesnoPipe } from './yesno.pipe';
|
||||
imports: [
|
||||
CommonModule
|
||||
],
|
||||
declarations: [ StatusLookupPipe,
|
||||
AccountsFilterPipe,
|
||||
ChargesFilterPipe,
|
||||
ChargesPenaltyFilterPipe,
|
||||
FindPipe,
|
||||
UrlToStringPipe,
|
||||
DateFormatPipe,
|
||||
DatetimeFormatPipe,
|
||||
ExternalIdentifierPipe,
|
||||
FormatNumberPipe,
|
||||
YesnoPipe,
|
||||
PrettyPrintPipe,
|
||||
TruncateTextPipe,
|
||||
TranslatePipe
|
||||
],
|
||||
providers: [StatusLookupPipe,
|
||||
AccountsFilterPipe,
|
||||
ChargesFilterPipe,
|
||||
ChargesPenaltyFilterPipe,
|
||||
FindPipe,
|
||||
UrlToStringPipe,
|
||||
DateFormatPipe,
|
||||
DatetimeFormatPipe,
|
||||
ExternalIdentifierPipe,
|
||||
FormatNumberPipe,
|
||||
YesnoPipe,
|
||||
PrettyPrintPipe,
|
||||
TranslatePipe,
|
||||
TruncateTextPipe],
|
||||
exports: [StatusLookupPipe,
|
||||
AccountsFilterPipe,
|
||||
ChargesFilterPipe,
|
||||
ChargesPenaltyFilterPipe,
|
||||
FindPipe,
|
||||
UrlToStringPipe,
|
||||
DateFormatPipe,
|
||||
DatetimeFormatPipe,
|
||||
ExternalIdentifierPipe,
|
||||
FormatNumberPipe,
|
||||
YesnoPipe,
|
||||
PrettyPrintPipe,
|
||||
TranslatePipe,
|
||||
TruncateTextPipe]
|
||||
declarations: [
|
||||
StatusLookupPipe,
|
||||
AccountsFilterPipe,
|
||||
ChargesFilterPipe,
|
||||
ChargesPenaltyFilterPipe,
|
||||
FindPipe,
|
||||
UrlToStringPipe,
|
||||
DateFormatPipe,
|
||||
DatetimeFormatPipe,
|
||||
ExternalIdentifierPipe,
|
||||
FormatNumberPipe,
|
||||
YesnoPipe,
|
||||
PrettyPrintPipe,
|
||||
TruncateTextPipe,
|
||||
TranslatePipe
|
||||
],
|
||||
providers: [
|
||||
StatusLookupPipe,
|
||||
AccountsFilterPipe,
|
||||
ChargesFilterPipe,
|
||||
ChargesPenaltyFilterPipe,
|
||||
FindPipe,
|
||||
UrlToStringPipe,
|
||||
DateFormatPipe,
|
||||
DatetimeFormatPipe,
|
||||
ExternalIdentifierPipe,
|
||||
FormatNumberPipe,
|
||||
YesnoPipe,
|
||||
PrettyPrintPipe,
|
||||
TranslatePipe,
|
||||
TruncateTextPipe
|
||||
],
|
||||
exports: [
|
||||
StatusLookupPipe,
|
||||
AccountsFilterPipe,
|
||||
ChargesFilterPipe,
|
||||
ChargesPenaltyFilterPipe,
|
||||
FindPipe,
|
||||
UrlToStringPipe,
|
||||
DateFormatPipe,
|
||||
DatetimeFormatPipe,
|
||||
ExternalIdentifierPipe,
|
||||
FormatNumberPipe,
|
||||
YesnoPipe,
|
||||
PrettyPrintPipe,
|
||||
TranslatePipe,
|
||||
TruncateTextPipe
|
||||
]
|
||||
})
|
||||
export class PipesModule { }
|
||||
export class PipesModule {}
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import * as vkbeautify from 'vkbeautify';
|
||||
|
||||
@Pipe({
|
||||
name: 'prettyPrint'
|
||||
name: 'prettyPrint'
|
||||
})
|
||||
export class PrettyPrintPipe implements PipeTransform {
|
||||
|
||||
transform(value: any) {
|
||||
if (value.charAt(0) === '{' && value.charAt(value.length - 1) === '}') {
|
||||
try {
|
||||
return vkbeautify.json(value);
|
||||
} catch (error) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
transform(value: any) {
|
||||
if (value.charAt(0) === '{' && value.charAt(value.length - 1) === '}') {
|
||||
try {
|
||||
return vkbeautify.json(value);
|
||||
} catch (error) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,12 @@ import { Pipe, PipeTransform } from '@angular/core';
|
||||
name: 'statusLookup'
|
||||
})
|
||||
export class StatusLookupPipe implements PipeTransform {
|
||||
|
||||
transform(status: string): string {
|
||||
const cssClassNameLookup = {
|
||||
'true': 'status-active',
|
||||
'false': 'status-deleted',
|
||||
'Active': 'status-active',
|
||||
'Block': 'status-block',
|
||||
true: 'status-active',
|
||||
false: 'status-deleted',
|
||||
Active: 'status-active',
|
||||
Block: 'status-block',
|
||||
'charges.StatusType.active.true': 'status-active',
|
||||
'loanStatusType.submitted.and.pending.approval': 'status-pending',
|
||||
'loanStatusType.approved': 'status-approved',
|
||||
|
||||
@@ -5,12 +5,10 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
name: 'translateKey'
|
||||
})
|
||||
export class TranslatePipe implements PipeTransform {
|
||||
|
||||
constructor(private translateService: TranslateService) { }
|
||||
constructor(private translateService: TranslateService) {}
|
||||
|
||||
transform(attributeValue: any, group: string, prefix: string = 'labels'): string {
|
||||
const translationKey = `${prefix}.${group}.${attributeValue}`;
|
||||
return this.translateService.instant(translationKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import { Pipe, PipeTransform } from '@angular/core';
|
||||
name: 'truncateText'
|
||||
})
|
||||
export class TruncateTextPipe implements PipeTransform {
|
||||
|
||||
transform(value: string, chars: number): string {
|
||||
if (value.length <= 40) {
|
||||
return value;
|
||||
@@ -17,5 +16,4 @@ export class TruncateTextPipe implements PipeTransform {
|
||||
|
||||
return truncatedText;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,26 +9,25 @@ import { Pipe, PipeTransform } from '@angular/core';
|
||||
name: 'urlToString'
|
||||
})
|
||||
export class UrlToStringPipe implements PipeTransform {
|
||||
|
||||
transform(url: string): any {
|
||||
url = decodeURIComponent(url);
|
||||
const urlSubstrings: string[] = url.slice(1).split('/');
|
||||
if (url.includes('?')) { // Query params URL.
|
||||
if (url.includes('?')) {
|
||||
// Query params URL.
|
||||
const query = urlSubstrings.pop();
|
||||
const prefix = query.slice(0, query.indexOf('?'));
|
||||
urlSubstrings.push(prefix);
|
||||
}
|
||||
const stringRepresentation =
|
||||
urlSubstrings
|
||||
.map((path: string) => {
|
||||
return path.split('-')
|
||||
.map((str: string) => {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
})
|
||||
.join(' ');
|
||||
})
|
||||
.join(' | ');
|
||||
const stringRepresentation = urlSubstrings
|
||||
.map((path: string) => {
|
||||
return path
|
||||
.split('-')
|
||||
.map((str: string) => {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
})
|
||||
.join(' ');
|
||||
})
|
||||
.join(' | ');
|
||||
return stringRepresentation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
name: 'yesNo'
|
||||
})
|
||||
export class YesnoPipe implements PipeTransform {
|
||||
|
||||
constructor(private translateService: TranslateService) { }
|
||||
constructor(private translateService: TranslateService) {}
|
||||
|
||||
transform(value: boolean, ...args: unknown[]): string {
|
||||
if (value == null) {
|
||||
@@ -15,5 +14,4 @@ export class YesnoPipe implements PipeTransform {
|
||||
const result = value ? 'Yes' : 'No';
|
||||
return this.translateService.instant('labels.buttons.' + result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user