code refactor
This commit is contained in:
@@ -205,10 +205,7 @@ export const ALL_TIMEZONES: TimezoneInfo[] = [
|
||||
timezoneName: 'Atlantic/Cape_Verde'
|
||||
},
|
||||
// UTC
|
||||
{
|
||||
displayName: 'Coordinated Universal Time',
|
||||
timezoneName: 'Etc/GMT'
|
||||
},
|
||||
UTC_TIMEZONE,
|
||||
// UTC+00:00
|
||||
{
|
||||
displayName: 'Dublin, Edinburgh, Lisbon, London',
|
||||
|
||||
@@ -77,12 +77,10 @@ export function allTransactionCategoriesWithVisibleCount(allTransactionCategorie
|
||||
|| allowCategoryTypes[CategoryType.Expense.toString()]
|
||||
|| allowCategoryTypes[CategoryType.Transfer.toString()]);
|
||||
|
||||
for (let key in CategoryType) {
|
||||
if (!Object.prototype.hasOwnProperty.call(CategoryType, key)) {
|
||||
continue;
|
||||
}
|
||||
const allCategoryTypes = [ CategoryType.Income, CategoryType.Expense, CategoryType.Transfer ];
|
||||
|
||||
const categoryType = CategoryType[key];
|
||||
for (let i = 0; i < allCategoryTypes.length; i++) {
|
||||
const categoryType = allCategoryTypes[i];
|
||||
|
||||
if (!allTransactionCategories[categoryType]) {
|
||||
continue;
|
||||
|
||||
@@ -206,11 +206,11 @@ function getCurrentLanguageDisplayName(i18nGlobal) {
|
||||
return currentLanguageInfo.displayName;
|
||||
}
|
||||
|
||||
function getLocalizedDisplayNameAndType(nameAndTypes, translateFn) {
|
||||
function getLocalizedDisplayNameAndType(typeAndNames, translateFn) {
|
||||
const ret = [];
|
||||
|
||||
for (let i = 0; i < nameAndTypes.length; i++) {
|
||||
const nameAndType = nameAndTypes[i];
|
||||
for (let i = 0; i < typeAndNames.length; i++) {
|
||||
const nameAndType = typeAndNames[i];
|
||||
|
||||
ret.push({
|
||||
type: nameAndType.type,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import uaParser from 'ua-parser-js';
|
||||
|
||||
import { CliUserAgent, type TokenInfoResponse, SessionInfo } from '@/models/token.ts';
|
||||
import { TOKEN_CLI_USER_AGENT, type TokenInfoResponse, SessionInfo } from '@/models/token.ts';
|
||||
|
||||
interface UserAgentInfo {
|
||||
device: {
|
||||
@@ -39,7 +39,7 @@ function parseUserAgent(ua: string): UserAgentInfo {
|
||||
}
|
||||
|
||||
function isSessionUserAgentCreatedByCli(ua: string): boolean {
|
||||
return ua === CliUserAgent;
|
||||
return ua === TOKEN_CLI_USER_AGENT;
|
||||
}
|
||||
|
||||
function parseDeviceInfo(uaInfo: UserAgentInfo): string {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const CliUserAgent: string = 'ezbookkeeping Cli';
|
||||
export const TOKEN_CLI_USER_AGENT: string = 'ezbookkeeping Cli';
|
||||
|
||||
export interface TokenInfoResponse {
|
||||
readonly tokenId: string;
|
||||
|
||||
@@ -166,8 +166,6 @@ export default {
|
||||
'f7router'
|
||||
],
|
||||
data: function () {
|
||||
const self = this;
|
||||
|
||||
return {
|
||||
loading: true,
|
||||
loadingError: null,
|
||||
@@ -175,7 +173,17 @@ export default {
|
||||
allowCategoryTypes: null,
|
||||
filterCategoryIds: {},
|
||||
showHidden: false,
|
||||
collapseStates: self.getCollapseStates(),
|
||||
collapseStates: {
|
||||
[CategoryType.Income]: {
|
||||
opened: true
|
||||
},
|
||||
[CategoryType.Expense]: {
|
||||
opened: true
|
||||
},
|
||||
[CategoryType.Transfer]: {
|
||||
opened: true
|
||||
}
|
||||
},
|
||||
showMoreActionSheet: false
|
||||
}
|
||||
},
|
||||
@@ -367,23 +375,6 @@ export default {
|
||||
},
|
||||
isSubCategoriesHasButNotAllChecked(category, filterCategoryIds) {
|
||||
return isSubCategoriesHasButNotAllChecked(category, filterCategoryIds);
|
||||
},
|
||||
getCollapseStates() {
|
||||
const collapseStates = {};
|
||||
|
||||
for (const categoryTypeField in CategoryType) {
|
||||
if (!Object.prototype.hasOwnProperty.call(CategoryType, categoryTypeField)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const categoryType = CategoryType[categoryTypeField];
|
||||
|
||||
collapseStates[categoryType] = {
|
||||
opened: true
|
||||
};
|
||||
}
|
||||
|
||||
return collapseStates;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user