From b2f5b0afd3e064259ca9597a8257be996b97cc2f Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sun, 20 Dec 2020 01:26:10 +0800 Subject: [PATCH] add category selection in transaction edit page --- src/Mobile.vue | 4 + .../TwoColumnListItemSelectionSheet.vue | 166 +++++++++++++++++ src/mobile-main.js | 2 + src/views/mobile/transactions/Edit.vue | 175 +++++++++++++++++- 4 files changed, 342 insertions(+), 5 deletions(-) create mode 100644 src/components/mobile/TwoColumnListItemSelectionSheet.vue diff --git a/src/Mobile.vue b/src/Mobile.vue index 861fee20..e4a224ef 100644 --- a/src/Mobile.vue +++ b/src/Mobile.vue @@ -168,6 +168,10 @@ i.icon.la, i.icon.las, i.icon.lab { align-self: center; } +.list .item-content .list-item-showing { + font-size: 16px; +} + .list .item-content .list-item-checked { font-size: 20px; color: var(--f7-radio-active-color, var(--f7-theme-color)); diff --git a/src/components/mobile/TwoColumnListItemSelectionSheet.vue b/src/components/mobile/TwoColumnListItemSelectionSheet.vue new file mode 100644 index 00000000..66126d57 --- /dev/null +++ b/src/components/mobile/TwoColumnListItemSelectionSheet.vue @@ -0,0 +1,166 @@ + + + + + diff --git a/src/mobile-main.js b/src/mobile-main.js index 98b0d558..1dd22667 100644 --- a/src/mobile-main.js +++ b/src/mobile-main.js @@ -42,6 +42,7 @@ import PasswordInputSheet from "./components/mobile/PasswordInputSheet.vue"; import PasscodeInputSheet from "./components/mobile/PasscodeInputSheet.vue"; import PinCodeInputSheet from "./components/mobile/PinCodeInputSheet.vue"; import ListItemSelectionSheet from "./components/mobile/ListItemSelectionSheet.vue"; +import TwoColumnListItemSelectionSheet from "./components/mobile/TwoColumnListItemSelectionSheet.vue"; import IconSelectionSheet from "./components/mobile/IconSelectionSheet.vue"; import ColorSelectionSheet from "./components/mobile/ColorSelectionSheet.vue"; import InformationSheet from "./components/mobile/InformationSheet.vue"; @@ -57,6 +58,7 @@ Vue.component('PasswordInputSheet', PasswordInputSheet); Vue.component('PasscodeInputSheet', PasscodeInputSheet); Vue.component('PinCodeInputSheet', PinCodeInputSheet); Vue.component('ListItemSelectionSheet', ListItemSelectionSheet); +Vue.component('TwoColumnListItemSelectionSheet', TwoColumnListItemSelectionSheet); Vue.component('IconSelectionSheet', IconSelectionSheet); Vue.component('ColorSelectionSheet', ColorSelectionSheet); Vue.component('InformationSheet', InformationSheet); diff --git a/src/views/mobile/transactions/Edit.vue b/src/views/mobile/transactions/Edit.vue index a858a3e5..1b82a354 100644 --- a/src/views/mobile/transactions/Edit.vue +++ b/src/views/mobile/transactions/Edit.vue @@ -24,7 +24,7 @@ style="font-size: 40px;" header="Expense Amount" title="0.00"> - + @@ -68,9 +68,77 @@ +
+ {{ transaction.expenseCategory | primaryCategoryName(allCategories[$constants.category.allCategoryTypes.Expense]) }} + + {{ transaction.expenseCategory | secondaryCategoryName(allCategories[$constants.category.allCategoryTypes.Expense]) }} +
+ + +
+ + +
+ {{ transaction.incomeCategory | primaryCategoryName(allCategories[$constants.category.allCategoryTypes.Income]) }} + + {{ transaction.incomeCategory | secondaryCategoryName(allCategories[$constants.category.allCategoryTypes.Income]) }} +
+ + +
+ + +
+ {{ transaction.transferCategory | primaryCategoryName(allCategories[$constants.category.allCategoryTypes.Transfer]) }} + + {{ transaction.transferCategory | secondaryCategoryName(allCategories[$constants.category.allCategoryTypes.Transfer]) }} +
+ +
= 100000000 || amount <= -100000000) { @@ -396,6 +529,30 @@ export default { } }, filters: { + primaryCategoryName(categoryId, allCategories) { + for (let i = 0; i < allCategories.length; i++) { + for (let j = 0; j < allCategories[i].subCategories.length; j++) { + const subCategory = allCategories[i].subCategories[j]; + if (subCategory.id === categoryId) { + return allCategories[i].name; + } + } + } + + return ''; + }, + secondaryCategoryName(categoryId, allCategories) { + for (let i = 0; i < allCategories.length; i++) { + for (let j = 0; j < allCategories[i].subCategories.length; j++) { + const subCategory = allCategories[i].subCategories[j]; + if (subCategory.id === categoryId) { + return subCategory.name; + } + } + } + + return ''; + }, accountName(accountId, allAccounts) { for (let i = 0; i < allAccounts.length; i++) { if (allAccounts[i].id === accountId) { @@ -419,6 +576,14 @@ export default {