code refactor
This commit is contained in:
@@ -4,7 +4,6 @@ type AccountTypeName = 'SingleAccount' | 'MultiSubAccounts';
|
||||
|
||||
export class AccountType implements TypeAndName {
|
||||
private static readonly allInstances: AccountType[] = [];
|
||||
private static readonly allInstancesByTypeName: Record<string, AccountType> = {};
|
||||
|
||||
public static readonly SingleAccount = new AccountType(1, 'SingleAccount', 'Single Account');
|
||||
public static readonly MultiSubAccounts = new AccountType(2, 'MultiSubAccounts', 'Multiple Sub-accounts');
|
||||
@@ -19,16 +18,11 @@ export class AccountType implements TypeAndName {
|
||||
this.name = name;
|
||||
|
||||
AccountType.allInstances.push(this);
|
||||
AccountType.allInstancesByTypeName[typeName] = this;
|
||||
}
|
||||
|
||||
public static values(): AccountType[] {
|
||||
return AccountType.allInstances;
|
||||
}
|
||||
|
||||
public static all(): Record<AccountTypeName, AccountType> {
|
||||
return AccountType.allInstancesByTypeName;
|
||||
}
|
||||
}
|
||||
|
||||
type AccountCategoryTypeName = 'Cash' | 'CheckingAccount' | 'SavingsAccount' | 'CreditCard' | 'VirtualAccount' | 'DebtAccount' | 'Receivables' | 'CertificateOfDeposit' | 'InvestmentAccount';
|
||||
@@ -36,7 +30,6 @@ type AccountCategoryTypeName = 'Cash' | 'CheckingAccount' | 'SavingsAccount' | '
|
||||
export class AccountCategory implements TypeAndName {
|
||||
private static readonly allInstances: AccountCategory[] = [];
|
||||
private static readonly allInstancesByType: Record<number, AccountCategory> = {};
|
||||
private static readonly allInstancesByTypeName: Record<string, AccountCategory> = {};
|
||||
|
||||
public static readonly Cash = new AccountCategory(1, 'Cash', 'Cash', '1');
|
||||
public static readonly CheckingAccount = new AccountCategory(2, 'CheckingAccount', 'Checking Account', '100');
|
||||
@@ -63,7 +56,6 @@ export class AccountCategory implements TypeAndName {
|
||||
|
||||
AccountCategory.allInstances.push(this);
|
||||
AccountCategory.allInstancesByType[type] = this;
|
||||
AccountCategory.allInstancesByTypeName[typeName] = this;
|
||||
}
|
||||
|
||||
public static values(): AccountCategory[] {
|
||||
|
||||
@@ -10,7 +10,6 @@ type CategoricalChartTypeName = 'Pie' | 'Bar';
|
||||
|
||||
export class CategoricalChartType implements TypeAndName {
|
||||
private static readonly allInstances: CategoricalChartType[] = [];
|
||||
private static readonly allInstancesByTypeName: Record<string, CategoricalChartType> = {};
|
||||
|
||||
public static readonly Pie = new CategoricalChartType(0, 'Pie', 'Pie Chart');
|
||||
public static readonly Bar = new CategoricalChartType(1, 'Bar', 'Bar Chart');
|
||||
@@ -27,23 +26,17 @@ export class CategoricalChartType implements TypeAndName {
|
||||
this.name = name;
|
||||
|
||||
CategoricalChartType.allInstances.push(this);
|
||||
CategoricalChartType.allInstancesByTypeName[typeName] = this;
|
||||
}
|
||||
|
||||
public static values(): CategoricalChartType[] {
|
||||
return CategoricalChartType.allInstances;
|
||||
}
|
||||
|
||||
public static all(): Record<CategoricalChartTypeName, CategoricalChartType> {
|
||||
return CategoricalChartType.allInstancesByTypeName;
|
||||
}
|
||||
}
|
||||
|
||||
type TrendChartTypeName = 'Area' | 'Column';
|
||||
|
||||
export class TrendChartType implements TypeAndName {
|
||||
private static readonly allInstances: TrendChartType[] = [];
|
||||
private static readonly allInstancesByTypeName: Record<string, TrendChartType> = {};
|
||||
|
||||
public static readonly Area = new TrendChartType(0, 'Area', 'Area Chart');
|
||||
public static readonly Column = new TrendChartType(1, 'Column', 'Column Chart');
|
||||
@@ -60,16 +53,11 @@ export class TrendChartType implements TypeAndName {
|
||||
this.name = name;
|
||||
|
||||
TrendChartType.allInstances.push(this);
|
||||
TrendChartType.allInstancesByTypeName[typeName] = this;
|
||||
}
|
||||
|
||||
public static values(): TrendChartType[] {
|
||||
return TrendChartType.allInstances;
|
||||
}
|
||||
|
||||
public static all(): Record<TrendChartTypeName, TrendChartType> {
|
||||
return TrendChartType.allInstancesByTypeName;
|
||||
}
|
||||
}
|
||||
|
||||
type ChartDataTypeName = 'ExpenseByAccount' | 'ExpenseByPrimaryCategory' | 'ExpenseBySecondaryCategory' | 'IncomeByAccount' | 'IncomeByPrimaryCategory' | 'IncomeBySecondaryCategory' | 'AccountTotalAssets' | 'AccountTotalLiabilities' | 'TotalExpense' | 'TotalIncome' | 'TotalBalance';
|
||||
@@ -77,7 +65,6 @@ type ChartDataTypeName = 'ExpenseByAccount' | 'ExpenseByPrimaryCategory' | 'Expe
|
||||
export class ChartDataType implements TypeAndName {
|
||||
private static readonly allInstances: ChartDataType[] = [];
|
||||
private static readonly allInstancesByType: Record<number, ChartDataType> = {};
|
||||
private static readonly allInstancesByTypeName: Record<string, ChartDataType> = {};
|
||||
|
||||
public static readonly ExpenseByAccount = new ChartDataType(0, 'ExpenseByAccount', 'Expense By Account', StatisticsAnalysisType.CategoricalAnalysis, StatisticsAnalysisType.TrendAnalysis);
|
||||
public static readonly ExpenseByPrimaryCategory = new ChartDataType(1, 'ExpenseByPrimaryCategory', 'Expense By Primary Category', StatisticsAnalysisType.CategoricalAnalysis, StatisticsAnalysisType.TrendAnalysis);
|
||||
@@ -112,7 +99,6 @@ export class ChartDataType implements TypeAndName {
|
||||
|
||||
ChartDataType.allInstances.push(this);
|
||||
ChartDataType.allInstancesByType[type] = this;
|
||||
ChartDataType.allInstancesByTypeName[typeName] = this;
|
||||
}
|
||||
|
||||
public isAvailableAnalysisType(analysisType: StatisticsAnalysisType): boolean {
|
||||
@@ -135,10 +121,6 @@ export class ChartDataType implements TypeAndName {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static all(): Record<ChartDataTypeName, ChartDataType> {
|
||||
return ChartDataType.allInstancesByTypeName;
|
||||
}
|
||||
|
||||
public static valueOf(type: number): ChartDataType | undefined {
|
||||
return ChartDataType.allInstancesByType[type];
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ type ScheduledTemplateFrequencyTypeName = 'Disabled' | 'Weekly' | 'Monthly';
|
||||
export class ScheduledTemplateFrequencyType implements TypeAndName {
|
||||
private static readonly allInstances: ScheduledTemplateFrequencyType[] = [];
|
||||
private static readonly allInstancesByType: Record<number, ScheduledTemplateFrequencyType> = {};
|
||||
private static readonly allInstancesByTypeName: Record<string, ScheduledTemplateFrequencyType> = {};
|
||||
|
||||
public static readonly Disabled = new ScheduledTemplateFrequencyType(0, 'Disabled');
|
||||
public static readonly Weekly = new ScheduledTemplateFrequencyType(1, 'Weekly');
|
||||
@@ -55,17 +54,12 @@ export class ScheduledTemplateFrequencyType implements TypeAndName {
|
||||
|
||||
ScheduledTemplateFrequencyType.allInstances.push(this);
|
||||
ScheduledTemplateFrequencyType.allInstancesByType[type] = this;
|
||||
ScheduledTemplateFrequencyType.allInstancesByTypeName[name] = this;
|
||||
}
|
||||
|
||||
public static values(): ScheduledTemplateFrequencyType[] {
|
||||
return ScheduledTemplateFrequencyType.allInstances;
|
||||
}
|
||||
|
||||
public static all(): Record<ScheduledTemplateFrequencyTypeName, ScheduledTemplateFrequencyType> {
|
||||
return ScheduledTemplateFrequencyType.allInstancesByTypeName;
|
||||
}
|
||||
|
||||
public static valueOf(type: number): ScheduledTemplateFrequencyType | undefined {
|
||||
return ScheduledTemplateFrequencyType.allInstancesByType[type];
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@
|
||||
<v-tabs show-arrows class="my-4" direction="vertical"
|
||||
:disabled="loading" v-model="queryChartDataType">
|
||||
<v-tab class="tab-text-truncate" :key="dataType.type" :value="dataType.type"
|
||||
v-for="dataType in ChartDataType.all()" v-show="dataType.isAvailableAnalysisType(queryAnalysisType)">
|
||||
v-for="dataType in ChartDataType.values()"
|
||||
v-show="dataType.isAvailableAnalysisType(queryAnalysisType)">
|
||||
<span class="text-truncate">{{ tt(dataType.name) }}</span>
|
||||
<v-tooltip activator="parent" location="right">{{ tt(dataType.name) }}</v-tooltip>
|
||||
</v-tab>
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
<f7-list-item :title="tt(dataType.name)"
|
||||
:class="{ 'list-item-selected': analysisType === StatisticsAnalysisType.CategoricalAnalysis && query.chartDataType === dataType.type }"
|
||||
:key="dataType.type"
|
||||
v-for="dataType in ChartDataType.all()"
|
||||
v-show="dataType.isAvailableAnalysisType(StatisticsAnalysisType.CategoricalAnalysis)"
|
||||
v-for="dataType in ChartDataType.values(StatisticsAnalysisType.CategoricalAnalysis)"
|
||||
@click="setChartDataType(StatisticsAnalysisType.CategoricalAnalysis, dataType.type)">
|
||||
<template #after>
|
||||
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="analysisType === StatisticsAnalysisType.CategoricalAnalysis && query.chartDataType === dataType.type"></f7-icon>
|
||||
@@ -35,8 +34,7 @@
|
||||
<f7-list-item :title="tt(dataType.name)"
|
||||
:class="{ 'list-item-selected': analysisType === StatisticsAnalysisType.TrendAnalysis && query.chartDataType === dataType.type }"
|
||||
:key="dataType.type"
|
||||
v-for="dataType in ChartDataType.all()"
|
||||
v-show="dataType.isAvailableAnalysisType(StatisticsAnalysisType.TrendAnalysis)"
|
||||
v-for="dataType in ChartDataType.values(StatisticsAnalysisType.TrendAnalysis)"
|
||||
@click="setChartDataType(StatisticsAnalysisType.TrendAnalysis, dataType.type)">
|
||||
<template #after>
|
||||
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="analysisType === StatisticsAnalysisType.TrendAnalysis && query.chartDataType === dataType.type"></f7-icon>
|
||||
|
||||
Reference in New Issue
Block a user