Open source personal finance application
chore(wallets): refactor
ilkome3c1d59bf817b
diff --git a/components/wallets/Delete.vue b/components/wallets/Delete.vuenew file mode 100644index 00000000..c293f7c6--- /dev/null+++ b/components/wallets/Delete.vue@@ -0,0 +1,68 @@+<script setup lang="ts">+import { getTrnsIds } from '~/components/trns/functions/getTrns'+import { random, successEmo } from '~/assets/js/emo'+import { removeData } from '~/services/firebase/api'+import type { WalletID } from '~/components/wallets/types'++interface Props {+ walletId: WalletID+}+const props = defineProps<Props>()+const { walletId } = toRefs(props)++const { $store, $notify } = useNuxtApp()+const router = useRouter()++const trnsItems = computed(() => $store.state.trns.items)+const trnsIds = computed(() =>+ getTrnsIds({+ walletsIds: [walletId.value],+ trnsItems: trnsItems.value,+ }))++const isShowDeleteConfirm = ref(false)++// TODO: translate+const deleteDescText = computed(() => {+ if (trnsIds.value.length > 0)+ return `It's also will delete ${trnsIds.value.length} trns in this wallet`+ return null+})++// TODO: translate+async function onDeleteConfirm() {+ // Disable reactive to have data when user have already redirected to wallets page+ const uid = JSON.parse(JSON.stringify($store.state.user.user.uid))+ const trnsIdsS = JSON.parse(JSON.stringify(trnsIds.value))+ const walletIdS = JSON.parse(JSON.stringify(walletId.value))++ router.push('/wallets')++ // Give some time to complete redirect+ setTimeout(async() => {+ await this.$store.dispatch('trns/deleteTrnsByIds', trnsIdsS)+ removeData(`users/${uid}/accounts/${walletIdS}`)+ .then(() => {+ $notify({+ type: 'success',+ text: trnsIdsS?.length > 0 ? `Success delete wallet with ${trnsIdsS.length} transactions!` : 'Success delete wallet!',+ title: random(successEmo),+ })+ })+ }, 100)+}+</script>++<template lang="pug">+div+ .mdi.mdi-delete-empty-outline.cursor-pointer.rounded-full.mt-3.mr-2.w-16.h-16.flex-center.text-2xl.p-4.hocus_text-red-500.hocus_bg-gray-100.dark_hocus_bg-neutral-800(+ @click="isShowDeleteConfirm = true"+ )++ ModalBottomConfirm(+ :show="isShowDeleteConfirm"+ :description="deleteDescText"+ @onClose="isShowDeleteConfirm = false"+ @onConfirm="onDeleteConfirm"+ )+</template>diff --git a/components/wallets/Form.vue b/components/wallets/Form.vuenew file mode 100644index 00000000..f85afe43--- /dev/null+++ b/components/wallets/Form.vue@@ -0,0 +1,176 @@+<script setup lang="ts">+import { allColors, popularColors } from '~/assets/js/colorsPopular'++interface Props {+ walletForm: {+ name: string+ color: string+ currency: string+ }+}+const props = defineProps<Props>()+const { walletForm } = toRefs(props)+const emit = defineEmits(['updateValue', 'onSave'])++const { $store } = useNuxtApp()+const activeTab = ref('data')++// function findWalletWithThisColor(color) {+// const walletsItems = $store.state.wallets.items+// if (!walletsItems)+// return false++// const walletIdWithThisColor = Object.keys(walletsItems)?.find(id => walletsItems[id]?.color === color)+// if (!walletIdWithThisColor)+// return false++// return true+// }+</script>++<template lang="pug">+div+ //- Menu+ //-----------------------------------+ .px-3+ .overflow-hidden.mb-8.rounded-md.scrollbar.bg-skin-item-main-bg.dark_shadow+ .overflow-hidden.overflow-x-auto.flex.items-center.text-sm.text-center.max-w-md+ .cursor-pointer.px-6.py-3.grow.hocus_bg-skin-item-main-hover(+ :class="{ '_active cursor-default text-blue3 dark_text-blue1 bg-gray-300 dark_bg-232323': activeTab === 'data' }"+ @click="activeTab = 'data'"+ ) {{ $t('categories.form.data.label') }}++ .cursor-pointer.px-6.py-3.grow.hocus_bg-skin-item-main-hover(+ :class="{ '_active cursor-default text-blue3 dark_text-blue1 bg-gray-300 dark_bg-232323': activeTab === 'currencies' }"+ @click="activeTab = 'currencies'"+ ) {{ $t('wallets.form.currencies.label') }}++ .cursor-pointer.px-6.py-3.grow.hocus_bg-skin-item-main-hover(+ :class="{ '_active cursor-default text-blue3 dark_text-blue1 bg-gray-300 dark_bg-232323': activeTab === 'colors' }"+ @click="activeTab = 'colors'"+ ) {{ $t('categories.form.colors.label') }}++ //- Content+ //-----------------------------------+ .px-3.max-w-md+ //- Data+ //-----------------------------------+ template(v-if="activeTab === 'data'")+ .mb-4+ .pb-2.text-skin-item-base-down.text-sm.leading-none {{ $t('wallets.form.name.label') }}+ input.w-full.m-0.py-3.px-4.rounded-lg.text-base.font-normal.text-skin-item-base.bg-skin-item-main-bg.border.border-solid.border-skin-item-main-hover.placeholder_text-skin-item-base-down.transition.ease-in-out.focus_text-skin-item-base-up.focus_bg-skin-item-main-hover.focus_border-blue3.focus_outline-none(+ :placeholder="$t('wallets.form.name.placeholder')"+ :value="walletForm.name"+ type="text"+ @input="event => emit('updateValue', 'name', event.target.value)"+ )++ SharedContextMenuItem(+ :checkboxValue="walletForm.countTotal"+ :title="$t('wallets.form.total.placeholder')"+ showCheckbox+ @onClick="walletForm.countTotal = !walletForm.countTotal"+ )++ SharedContextMenuItem(+ :checkboxValue="walletForm.isCredit"+ :title="$t('isCredit')"+ showCheckbox+ @onClick="walletForm.isCredit = !walletForm.isCredit"+ )++ //- Currencies+ //-----------------------------------+ CurrenciesList.-mt-3(+ v-if="activeTab === 'currencies'"+ :active="walletForm.currency"+ @onSelect="value => emit('updateValue', 'currency', value)"+ )++ //- Colors+ //---------------------------------+ template(v-if="activeTab === 'colors'")+ .pb-2.text-sm.text-skin-item-base-down {{ $t('popularColors') }}+ .colors+ .iconItem(+ v-for="(color, idx) in popularColors"+ :key="idx"+ :class="{ _active: color === walletForm.color }"+ :style="{ background: color === walletForm.color ? color : 'transparent' }"+ @click="emit('updateValue', 'color', color)"+ )+ template(v-if="color")+ .colorPreview(:style="{ background: color }")++ .pb-2.text-sm.text-skin-item-base-down {{ $t('palette') }}+ .colors+ .iconItem(+ v-for="(color, idx) in allColors"+ :key="idx"+ :class="{ _active: color === walletForm.color, '_empty pointer-events-none': !color }"+ :style="{ background: color === walletForm.color ? color : 'transparent' }"+ @click="emit('updateValue', 'color', color)"+ )++ template(v-if="color")+ .colorPreview(:style="{ background: color }")++ .pb-2.text-sm.text-skin-item-base-down {{ $t('categories.form.colors.custom') }}+ input.cursor-pointer.w-full.h-12.p-0.border-0(v-model="walletForm.color" type="color")++ .pt-4.pb-6+ SharedButton(+ :class="['_text-center _blue2 _ml-big', { _inline: $store.state.ui.pc }]"+ :title="$t('wallets.form.save')"+ @onClick="emit('onSave')"+ )+</template>++<style lang="stylus" scoped>+.colorPreview+ display flex+ align-items center+ justify-content center+ width 90%+ height 90%+ border-radius 50%++.colors+ display grid+ grid-template-columns repeat(8, minmax(auto, 1fr))+ padding-bottom $m8+ &:last-child+ padding-bottom 0++.iconItem+ display flex+ align-items center+ justify-content center+ width 40px+ height 40px+ max-width 40px+ max-height 40px+ padding 4px+ font-size 24px+ border-radius 50%++ +media-hover()+ &:not(._empty)+ cursor pointer+ background var(--c-item-bd-hover)++ &._active+ padding 0+ background var(--c-item-bd-hover)+</style>++<i18n lang="json5">+{+ "en": {+ "isCredit": "Credit account"+ },+ "ru": {+ "isCredit": "Кредитный счёт"+ }+}+</i18n>diff --git a/components/wallets/FormWelcome.vue b/components/wallets/FormWelcome.vuenew file mode 100644index 00000000..1edd4ead--- /dev/null+++ b/components/wallets/FormWelcome.vue@@ -0,0 +1,115 @@+<script setup lang="ts">+import { popularColors } from '~/assets/js/colorsPopular'+import { random } from '~/assets/js/emo'+import generateId from '~/utils/id'++interface Props {+ saved: Function+}+const props = defineProps<Props>()++const { $store, $notify, nuxt2Context: { i18n } } = useNuxtApp()++const walletId = computed(() => generateId())++const walletForm = ref({+ color: random(popularColors),+ countTotal: true,+ currency: 'USD',+ isCredit: false,+ name: null,+ order: 1,+})++function updateValue(id, value) {+ walletForm.value[id] = value+}++function onSave() {+ const wallets = $store.state.wallets.items++ // name+ if (!walletForm.value.name) {+ $notify({+ title: '😮',+ text: i18n.t('wallets.form.name.error'),+ })+ return false+ }++ // currency+ if (!walletForm.value.currency) {+ $notify({+ title: '😮',+ text: i18n.t('wallets.form.currency.error'),+ })+ return false+ }++ for (const id in wallets) {+ if (wallets[id].name === walletForm.value.name) {+ if (walletId.value) {+ if (walletId.value !== id) {+ $notify({+ title: '😮',+ text: i18n.t('wallets.form.name.exist'),+ })+ return false+ }+ }+ else {+ $notify({+ title: '😮',+ text: i18n.t('wallets.form.name.exist'),+ })+ return false+ }+ }+ }++ const id = walletId.value++ const walletsValues = {+ color: walletForm.value.color,+ countTotal: walletForm.value.countTotal,+ currency: walletForm.value.currency,+ isCredit: walletForm.value.isCredit,+ name: walletForm.value.name,+ order: walletForm.value.order,+ }++ $store.dispatch('wallets/addWallet', { id, values: walletsValues })+ if (props.saved) props.saved()+}+</script>++<script lang="ts">+export default defineComponent({+ head() {+ return {+ title: `${this.$t('base.edit')}: ${this.wallet?.name}`,+ }+ },+})+</script>++<template lang="pug">+.overflow.overflow-x-auto.h-full.max-w-3xl(+ class="pb-[44px] md_pb-[52px] lg_pb-0"+)+ .mb-3.py-5.px-3.font-nunito+ .pb-1.text-xs.font-medium.text-skin-item-base-down+ | {{ $t("wallets.createNewTitle") }}++ .flex.items-center.gap-3+ .text-skin-item-base-up.text-2xl.font-semibold+ | {{ walletForm.name ? walletForm.name : $t("wallets.form.name.label") }}+ .p-1.flex-center.rounded.text-skin-icon-base.text-2xs(:style="{ background: walletForm.color }")+ | {{ walletForm.currency }}++ WalletsForm(+ :walletForm="walletForm"+ @onSave="onSave"+ @updateValue="updateValue"+ )+</template>diff --git a/components/wallets/form/WalletForm.vue b/components/wallets/form/WalletForm.vuedeleted file mode 100644index 0cf7bda1..00000000--- a/components/wallets/form/WalletForm.vue+++ /dev/null@@ -1,327 +0,0 @@-<script>-import generateId from '~/utils/id'-import colors from '~/assets/js/colors'--export default {- data() {- return {- showColors: false,- showCurrencies: false,- wallet: {- color: null,- countTotal: true,- currency: 'RUB',- isCredit: false,- name: null,- order: 1,- },- }- },-- computed: {- walletId() {- return this.$store.state.wallets.editId- },- },-- watch: {- walletId: {- handler(walletId) {- if (walletId) {- this.wallet = {- ...this.wallet,- ...this.$store.state.wallets.items[this.walletId],- }- }- },- immediate: true,- },- },-- created() {- this.colors = colors- if (!this.$store.state.wallets.editId)- this.wallet.color = colors[Math.floor(Math.random() * colors.length)]- },-- beforeUnmount() {- this.$store.commit('wallets/setWalletEditId', null)- },-- methods: {- handleColorSelect(color) {- this.wallet.color = color- this.showColors = false- },- handleCurrencySelect(currency) {- this.wallet.currency = currency- this.showCurrencies = false- },-- handleSubmit() {- if (this.validateForm()) {- const id = this.walletId || generateId()-- const walletsValues = {- color: this.wallet.color,- countTotal: this.wallet.countTotal,- currency: this.wallet.currency,- isCredit: this.wallet.isCredit,- name: this.wallet.name,- order: this.wallet.order,- }-- this.$store.dispatch('wallets/addWallet', { id, values: walletsValues })- this.$store.commit('wallets/setWalletEditId', null)-- if (this.$listeners.callback) this.$listeners.callback()- }- },-- validateForm() {- const wallets = this.$store.state.wallets.items- // name- if (!this.wallet.name) {- this.$notify({- title: '😮',- text: this.$t('wallets.form.name.error'),- })- return false- }-- // currency- if (!this.wallet.currency) {- this.$notify({- title: '😮',- text: this.$t('wallets.form.currencies.error'),- })- return false- }-- for (const walletId in wallets) {- if (wallets[walletId].name === this.wallet.name) {- if (this.walletId) {- if (this.walletId !== walletId) {- this.$notify({- title: '😮',- text: this.$t('wallets.form.name.exist'),- })- return false- }- }- else {- this.$notify({- title: '😮',- text: this.$t('wallets.form.name.exist'),- })- return false- }- }- }-- return true- },- },-}-</script>--<template lang="pug">-.h-full.overflow.overflow-x-auto- .pb-4.text-neutral-800.dark_text-white.text-2xl.font-semibold.font-nunito- template(v-if="!walletId") {{ $t('wallets.createNewTitle') }}- template(v-else) {{ $t('wallets.editTitle') }}-- .form- .form-line._text- .inputText- .inputText__label {{ $t('wallets.form.name.label') }}- input(- type="text"- :placeholder="$t('wallets.form.name.placeholder')"- v-model="wallet.name"- ).inputText__value-- .form__btns(style="paddingBottom: 8px")- .form__btns__i- .form-line(@click="showCurrencies = true")- .inputModal._flex- .inputModal__value {{ wallet.currency }}- .inputModal__content- .inputModal__label {{ $t('wallets.form.currencies.label') }}-- .form__btns__i- .form-line(@click="showColors = true")- .inputModal._flex- .inputModal__value: .inputModal__color(:style="{ background: wallet.color }")- .inputModal__label {{ $t('wallets.form.colors.label') }}-- SharedContextMenuItem(- :checkboxValue="wallet.countTotal"- :title="$t('wallets.form.total.placeholder')"- showCheckbox- @onClick="wallet.countTotal = !wallet.countTotal"- )-- SharedContextMenuItem(- :checkboxValue="wallet.isCredit"- :title="$t('isCredit')"- showCheckbox- @onClick="wallet.isCredit = !wallet.isCredit"- )-- .pt-6- SharedButton(- :class="['_text-center _blue2', { _inline: $store.state.ui.pc }]"- :title="$t('wallets.form.save')"- @onClick="handleSubmit")-- //- colors- Portal(- v-if="showColors"- to="modal"- )- ModalBottom(- :center="true"- :title="$t('wallets.form.colors.placeholder')"- @onClose="showColors = false"- )- .inputText- .inputText__colors- .colors- .colorItem(- :class="{ _active: wallet.color === color }"- :style="{ background: color }"- @click="handleColorSelect(color)"- v-for="color in colors")- .customColor- .customColor__title {{ $t('wallets.form.colors.custom') }}- input.customColor__value(v-model="wallet.color" type="color")-- //- currencies- Portal(- v-if="showCurrencies"- to="modal"- )- ModalBottom(- :center="true"- :title="$t('wallets.form.currencies.placeholder')"- @onClose="showCurrencies = false"- )- .inputText- .currencies- .currencies__item(- :class="{ _active: wallet.currency === currency }"- @click="handleCurrencySelect(currency)"- v-for="(item, currency) in $store.state.currencies.rates"- ) {{ currency }}-</template>--<style lang="stylus" scoped>-.customColor- margin (- $m7)- margin-top 0- padding $m7- background var(--c-bg-1)-- @media $media-laptop- margin (- $m9)- margin-top 0- padding $m9-- &__title- padding-bottom $m6- color var(--c-font-4)-- &__value- width 100%- height 40px- margin 0- padding 0- border 0--.form- @media $media-laptop- max-width 380px--.form__actions- @media $media-phone- text-align center--.form__btns- display grid- grid-template-columns repeat(2, 1fr)- grid-column-gap $m9- grid-row-gap $m9- padding-bottom $m9-- +media-laptop()- grid-column-gap $m10- grid-row-gap $m10-- &__i._full- grid-column 1 / -1-- .form-line- display flex- align-items center- justify-content center- height 100%- height 56px- margin-bottom 0-- +media-laptop()- height auto--.inputModal- &._flex- flex 1- display flex- align-items center- justify-content space-between-- &__content- display flex-- &__label- margin 0- padding 0- font-size 10px--.currencies- display grid- grid-template-columns repeat(auto-fill, minmax(120px, 1fr))- grid-column-gap $m7- grid-row-gap $m7-- &__item- cursor pointer- display flex- align-items center- justify-content center- height 44px- padding $m6- text-align center- border 1px solid var(--c-bg-6)- border-radius $m4-- +media-hover()- &:not(._active)- background var(--c-bg-6)-- &._active- cursor default- color var(--c-font-1)- background var(--c-blue-1)- border none-</style>--<i18n lang="json5">-{- "en": {- "isCredit": "Credit account"- },- "ru": {- "isCredit": "Кредитный счёт"- }-}-</i18n>diff --git a/components/wallets/page/List.vue b/components/wallets/page/List.vueindex 3831dca4..34649852 100644--- a/components/wallets/page/List.vue+++ b/components/wallets/page/List.vue@@ -1,6 +1,10 @@<script setup lang="ts">+import { useWindowSize } from '@vueuse/core'import useWallets from '~/components/wallets/useWallets'+const { $store } = useNuxtApp()+const { height } = useWindowSize()+const activeTab = computed(() => $store.state.ui.activeTab)const { walletsItemsSorted } = useWallets()</script>@@ -89,4 +93,60 @@ export default defineComponent({class="basis-1/2 max-w-[280px]"@click="$store.dispatch('ui/setActiveTab', 'createWallet')") {{ $t('wallets.new') }}++ //- Sort+ //-----------------------------------+ Portal(v-if="activeTab === 'walletsSort'" to="modal" key="walletsSort")+ ModalBottom(+ isShow+ key="walletsSort"+ @onClose="$store.dispatch('ui/setActiveTab', null)"+ )+ template(#default="{ closeModal }")+ WalletsSort(+ v-if="activeTab === 'walletsSort'"+ @closeModal="closeModal"+ )++ //- Portal(+ //- v-if="activeTab === 'walletsSort'"+ //- to="modal"+ //- )+ //- BaseBottomSheet(+ //- :maxHeight="height"+ //- insideClass="bg-skin-layout-main"+ //- @closed="$store.dispatch('ui/setActiveTab', null)"+ //- )+ //- template(#handler="{ close }")+ //- BaseBottomSheetHandler+ //- BaseBottomSheetClose(@onClick="close")++ //- template(#header)+ //- .py-4.px-3.rounded-t-2xl.text-center.text-neutral-800.dark_text-white.text-xl.font-semibold.font-nunito.bg-skin-layout-main+ //- | {{ $t('wallets.sortTitle') }}++ //- template(#default="{ close }")+ //- WalletsSort(+ //- v-if="activeTab === 'walletsSort'"+ //- @closeModal="close"+ //- )++ //- Create+ Portal(+ v-if="activeTab === 'createWallet'"+ to="modal"+ )+ BaseBottomSheet(+ :maxHeight="height"+ insideClass="bg-skin-layout-main"+ @closed="$store.dispatch('ui/setActiveTab', null)"+ )+ template(#handler="{ close }")+ BaseBottomSheetHandler+ BaseBottomSheetClose(@onClick="close")++ template(#default="{ close }")+ WalletsFormWalletForm(+ @callback="close"+ )</template>diff --git a/components/wallets/page/id/Edit.vue b/components/wallets/page/id/Edit.vueindex fd3fdb46..87122524 100644--- a/components/wallets/page/id/Edit.vue+++ b/components/wallets/page/id/Edit.vue@@ -1,17 +1,11 @@<script setup lang="ts">-import { allColors, popularColors } from '~/assets/js/colorsPopular'-import { currencies } from '~/components/currencies/currencies'-import { getTrnsIds } from '~/components/trns/functions/getTrns'-import { random, successEmo } from '~/assets/js/emo'-import { removeData } from '~/services/firebase/api'+import { popularColors } from '~/assets/js/colorsPopular'+import { random } from '~/assets/js/emo'const { $store, $notify, nuxt2Context: { i18n } } = useNuxtApp()-const route = useRoute()const router = useRouter()-const activeTab = ref('data')-const walletId = computed(() => route.params.id)const wallet = computed(() => $store.state.wallets.items[walletId.value])@@ -24,60 +18,8 @@ const walletForm = ref({order: wallet.value?.order || 1,})-function findWalletWithThisColor(color) {- const walletsItems = $store.state.wallets.items- if (!walletsItems) return false- const walletIdWithThisColor = Object.keys(walletsItems)?.find(id => walletsItems[id]?.color === color)- if (!walletIdWithThisColor) return false-- return true-}--function onSelectColor(color) {- walletForm.value.color = color-}--function onCurrencySelect(currency) {- walletForm.value.currency = currency-}--const trnsItems = computed(() => $store.state.trns.items)-const trnsIds = computed(() =>- getTrnsIds({- walletsIds: [walletId.value],- trnsItems: trnsItems.value,- }))--const isShowDeleteConfirm = ref(false)--// TODO: translate-const deleteDescText = computed(() => {- if (trnsIds.value.length > 0)- return `It's also will delete ${trnsIds.value.length} trns in this wallet`- return null-})--// TODO: translate-async function onDeleteConfirm() {- // Disable reactive to have data when user have already redirected to wallets page- const uid = JSON.parse(JSON.stringify($store.state.user.user.uid))- const trnsIdsS = JSON.parse(JSON.stringify(trnsIds.value))- const walletIdS = JSON.parse(JSON.stringify(walletId.value))-- router.push('/wallets')-- // Give some time to complete redirect- setTimeout(async() => {- await this.$store.dispatch('trns/deleteTrnsByIds', trnsIdsS)- removeData(`users/${uid}/accounts/${walletIdS}`)- .then(() => {- $notify({- type: 'success',- text: trnsIdsS?.length > 0 ? `Success delete wallet with ${trnsIdsS.length} transactions!` : 'Success delete wallet!',- title: random(successEmo),- })- })- }, 100)+function updateValue(id, value) {+ walletForm.value[id] = value}function onSave() {@@ -149,332 +91,34 @@ export default defineComponent({</script><template lang="pug">-.h-full.overflow.overflow-x-auto.max-w-3xl.h-full(+.overflow.overflow-x-auto.h-full.max-w-3xl(v-if="wallet"class="pb-[44px] md_pb-[52px] lg_pb-0").flex.items-startrouter-link(- v-slot='{ href, navigate }'- :to='`/wallets/${walletId}`'+ v-slot="{ href, navigate }"custom+ :to="`/wallets/${walletId}`")- a.grow.cursor-pointer.block.py-5.pb-5.mb-4.px-3.font-nunito.hocus_bg-gray-100.dark_hocus_bg-neutral-800(- :href='href'- @click='navigate'+ a.cursor-pointer.grow.mb-3.py-5.px-3.block.font-nunito.hocus_bg-skin-item-main-hover(+ :href="href"+ @click="navigate")- .pb-1.text-xs.font-medium(class="dark_text-white/50") {{ $t('wallets.editTitle') }}+ .pb-1.text-xs.font-medium.text-skin-item-base-down+ | {{ $t("wallets.editTitle") }}.flex.items-center.gap-3- .text-neutral-800.dark_text-white.text-2xl.font-semibold {{ wallet.name ? wallet.name : $t('wallets.title') }}- .p-1.px-1.rounded.flex-center.text-2xs.text-neutral-50(- :style="{ background: wallet.color }"- ) {{ wallet.currency }}-- .mdi.mdi-delete-empty-outline.cursor-pointer.rounded-full.mt-3.mr-2.w-16.h-16.flex-center.text-2xl.p-4.hocus_text-red-500.hocus_bg-gray-100.dark_hocus_bg-neutral-800(- @click="isShowDeleteConfirm = true"- )-- //- Menu- //------------------------------------ .px-3.pb-4- .overflow-hidden.rounded-md.scrollbar.mb-4.bg-gray-50.dark_bg-dark4.dark_shadow- .overflow-hidden.overflow-x-auto.flex.items-center.text-sm.text-center.max-w-md- .cursor-pointer.px-6.py-3.grow.hocus_bg-gray-200.dark_hocus_bg-neutral-800(- :class="{ '_active cursor-default text-blue3 dark_text-blue1 bg-gray-100 dark_bg-232323': activeTab === 'data' }"- @click="activeTab = 'data'"- ) {{ $t('categories.form.data.label') }}-- .cursor-pointer.px-6.py-3.grow.hocus_bg-gray-200.dark_hocus_bg-neutral-800(- :class="{ '_active cursor-default text-blue3 dark_text-blue1 bg-gray-100 dark_bg-232323': activeTab === 'currencies' }"- @click="activeTab = 'currencies'"- ) {{ $t('wallets.form.currencies.label') }}-- .cursor-pointer.px-6.py-3.grow.hocus_bg-gray-200.dark_hocus_bg-neutral-800(- :class="{ '_active cursor-default text-blue3 dark_text-blue1 bg-gray-100 dark_bg-232323': activeTab === 'colors' }"- @click="activeTab = 'colors'"- ) {{ $t('categories.form.colors.label') }}-- //- Content- //------------------------------------ .px-3.max-w-md- //- Data- //------------------------------------ template(v-if="activeTab === 'data'")- .mb-4- .pb-2.text-skin-item-base-down.text-sm.leading-none {{ $t('wallets.form.name.label') }}- input.w-full.m-0.py-3.px-4.rounded-lg.text-base.font-normal.text-skin-item-base.bg-skin-item-main-bg.border.border-solid.border-skin-item-main-hover.placeholder_text-skin-item-base-down.transition.ease-in-out.focus_text-skin-item-base-up.focus_bg-skin-item-main-hover.focus_border-blue3.focus_outline-none(- :placeholder="$t('wallets.form.name.placeholder')"- type="text"- v-model="walletForm.name"- )-- SharedContextMenuItem(- :checkboxValue="walletForm.countTotal"- :title="$t('wallets.form.total.placeholder')"- showCheckbox- @onClick="walletForm.countTotal = !walletForm.countTotal"- )-- SharedContextMenuItem(- :checkboxValue="walletForm.isCredit"- :title="$t('isCredit')"- showCheckbox- @onClick="walletForm.isCredit = !walletForm.isCredit"- )-- //- Currencies- //------------------------------------ template(v-if="activeTab === 'currencies'")- div- .border-b.border-gray-50.dark_border-neutral-800.p-3.hocus_bg-gray-200.dark_hocus_bg-neutral-800(- v-for="(item, currency) in $store.state.currencies.rates"- :key="item"- :class="{ '_active cursor-default text-blue3 dark_text-blue1': walletForm.currency === currency }"- @click="onCurrencySelect(currency)"- )- .flex.items-center- .w-14 {{ currency }}- .text-sm(- v-if="currencies.find(c => c.code === currency)"- ) {{ currencies.find(c => c.code === currency).name }}-- //- Colors- //---------------------------------- template(v-if="activeTab === 'colors'")- .form- .subTitle {{ $t('popularColors') }}- .colors- .iconItem(- v-for="(color, idx) in popularColors"- :key="idx"- :class="{ _active: color === walletForm.color }"- :style="{ background: color === walletForm.color ? color : 'transparent' }"- @click="onSelectColor(color)"- )- template(v-if="color")- template(v-if="findWalletWithThisColor(color)")- Icon(- icon="mdi mdi-circle-small"- :color="color === walletForm.color ? null : color"- big- )- template(v-else-if="color === walletForm.color")- Icon(- icon="mdi mdi-circle-small"- background="transparent"- big- )- template(v-else-if="color")- .colorPreview(:style="{ background: color }")-- .subTitle {{ $t('palette') }}- .colors- .iconItem(- v-for="(color, idx) in allColors"- :key="idx"- :class="{ _active: color === walletForm.color, _empty: !color }"- :style="{ background: color === walletForm.color ? color : 'transparent' }"- @click="onSelectColor(color)"- )-- template(v-if="color")- template(v-if="findWalletWithThisColor(color)")- Icon(- icon="mdi mdi-circle-small"- :color="color === walletForm.color ? null : color"- big- )- template(v-else-if="color === walletForm.color")- Icon(- icon="mdi mdi-circle-small"- background="transparent"- big- )- template(v-else-if="color")- .colorPreview(:style="{ background: color }")+ .text-skin-item-base-up.text-2xl.font-semibold+ | {{ walletForm.name ? walletForm.name : $t("wallets.title") }}+ .p-1.flex-center.rounded.text-skin-icon-base.text-2xs(:style="{ background: walletForm.color }")+ | {{ walletForm.currency }}- .subTitle {{ $t('categories.form.colors.custom') }}- .customColor- input.customColor__value(v-model="walletForm.color" type="color")+ WalletsDelete(:walletId="walletId")- .pt-4.pb-6- SharedButton(- :class="['_text-center _blue2 _ml-big', { _inline: $store.state.ui.pc }]"- :title="$t('wallets.form.save')"- @onClick="onSave"- )-- ModalBottomConfirm(- :show="isShowDeleteConfirm"- :description="deleteDescText"- @onClose="isShowDeleteConfirm = false"- @onConfirm="onDeleteConfirm"+ WalletsForm(+ :walletForm="walletForm"+ @onSave="onSave"+ @updateValue="updateValue")</template>--<style lang="stylus" scoped>-.preview- display flex- align-items center- justify-content space-between- padding $m5 $m7- gap $m7--.subTitle- padding 0 $m5- padding-bottom $m6- color var(--c-font-4)- font-size 13px- font-weight 500--.customColor- padding 0 $m4- background var(--c-bg-3)-- &__title- padding-bottom $m6- color var(--c-font-4)-- &__value- overflow hidden- display block- appearance none- width 100%- height 48px- margin 0- padding 0- background none- border 0- border-radius $borderRadiusMd--.form__actions- @media $media-phone- text-align center--.form__btns- display grid- grid-template-columns repeat(2, 1fr)- grid-column-gap $m9- grid-row-gap $m9- padding-bottom $m9-- +media-laptop()- grid-column-gap $m10- grid-row-gap $m10-- &__i._full- grid-column 1 / -1--.inputModal- &._flex- flex 1- display flex- align-items center- justify-content space-between-- &__content- display flex-- &__label- margin 0- padding 0- font-size 10px--.currencies- display grid- grid-template-columns repeat(auto-fill, minmax(120px, 1fr))- grid-column-gap $m7- grid-row-gap $m7-- &__item- cursor pointer- display flex- align-items center- justify-content center- height 44px- padding $m6- text-align center- border 1px solid var(--c-bg-6)- border-radius $m4-- +media-hover()- &:not(._active)- background var(--c-bg-6)-- &._active- cursor default- color var(--c-font-1)- background var(--c-blue-1)- border none--.colorPreview- display flex- align-items center- justify-content center- width 90%- height 90%- border-radius 50%--.colors- display grid- grid-template-columns repeat(8, minmax(auto, 1fr))- padding-bottom $m8- &:last-child- padding-bottom 0--.iconItem- display flex- align-items center- justify-content center- width 40px- height 40px- max-width 40px- max-height 40px- padding 4px- font-size 24px- border-radius 50%-- +media-hover()- &:not(._empty)- cursor pointer- background var(--c-item-bd-hover)-- &._active- padding 0- background var(--c-item-bd-hover)--.customColor- padding 0 $m4- background var(--c-bg-3)-- &__title- padding-bottom $m6- color var(--c-font-4)-- &__value- overflow hidden- display block- appearance none- width 100%- height 48px- margin 0- padding 0- background none- border 0- border-radius $borderRadiusMd-</style>--<i18n lang="json5">-{- "en": {- "isCredit": "Credit account",- "askDelete": "Delete wallet?",- },-- "ru": {- "isCredit": "Кредитный счёт",- "askDelete": "Удалить кошелек?",- }-}-</i18n>diff --git a/components/wallets/page/id/Index.vue b/components/wallets/page/id/Index.vueindex 026b6055..25b32077 100644--- a/components/wallets/page/id/Index.vue+++ b/components/wallets/page/id/Index.vue@@ -1,5 +1,4 @@<script setup lang="ts">-import { removeData } from '~/services/firebase/api'import useFilter from '~/modules/filter/useFilter'import { getTrnsIds } from '~/components/trns/functions/getTrns'@@ -27,13 +26,6 @@ const trnsIds = computed(() =>const periodTrnsIds = computed(() => $store.getters['trns/selectedTrnsIdsWithDate'].filter(trnId => $store.state.trns.items[trnId].walletId === walletId.value))-const showModalConfirm = ref(false)-const deleteInfo = computed(() => {- if (trnsIds.value.length > 0)- return `It's also will delete ${trnsIds.value.length} trns in this wallet`- return false-})-function handleSetFilterWallet() {setFilterWalletsId(walletId.value)$store.commit('filter/setFilterDateNow')@@ -43,21 +35,6 @@ function handleSetFilterWallet() {function handleEditClick() {router.push(`/wallets/${walletId.value}/edit`)}--function handleDeleteConfirm() {- const uid = $store.state.user.user.uid- const id = JSON.parse(JSON.stringify(walletId.value))- const trnsIdsForDelete = JSON.parse(JSON.stringify(trnsIds.value))-- showModalConfirm.value = false- router.replace('/wallets')-- setTimeout(async() => {- await $store.dispatch('trns/deleteTrnsByIds', trnsIdsForDelete)- removeData(`users/${uid}/accounts/${id}`)- .then(() => console.log('wallet deleted'))- }, 200)-}</script><script lang="ts">@@ -71,74 +48,67 @@ export default defineComponent({</script><template lang="pug">-.h-full.overflow.overflow-x-auto.max-w-3xl.h-full(+.overflow.overflow-x-auto.h-full.max-w-3xl(+ v-if="wallet"class="pb-[44px] md_pb-[52px] lg_pb-0")- template(v-if="wallet")- router-link(- v-slot='{ href, navigate }'- to='/wallets'- custom- )- .flex.items-start- a.grow.cursor-pointer.block.py-5.mb-3.px-3.font-nunito.hocus_bg-gray-100.dark_hocus_bg-neutral-800(- :href='href'- @click='navigate'- )- .pb-2.text-xs.font-medium(class="dark_text-white/50") {{ $t('wallets.title') }}-- .flex.items-center.gap-3.pb-3- .text-neutral-800.dark_text-white.text-2xl.leading-none.font-semibold {{ wallet.name }}- .p-1.px-1.rounded.flex-center.text-2xs.text-neutral-50(- :style="{ background: wallet.color }"- ) {{ wallet.currency }}-- .flex- Amount(- :currency="wallet.currency"- :value="total"- showBase- size="lg"- vertical="right"- )-- .mdi.mdi-pencil-outline.cursor-pointer.rounded-full.mt-3.mr-2.w-16.h-16.flex-center.text-2xl.p-4.hocus_bg-gray-100.dark_hocus_bg-neutral-800(- @click="handleEditClick"- )-- .pb-6- .px-3.flex- .cursor-pointer.p-1.px-3.flex.items-center.gap-3.bg-gray-50.dark_bg-dark4.rounded-md.hocus_bg-gray-100.dark_hocus_bg-neutral-800.shadow.hocus_shadow-lg(- class="dark_text-white/60"- @click="handleSetFilterWallet"- )- .mdi.mdi-poll.text-xl- .text-xs.leading-none {{ $t('statBy') }}: {{ wallet.name }}- .mdi.mdi-chevron-right.opacity-70.text-lg.leading-none-- //- Stat- .overflow-hidden.relative.bg-gray-50.dark_bg-custom4.mx-3.mb-12.p-3.rounded-md- SharedDate.text-xs.font-medium(class="-mb-1 dark_text-white/50")- div(class="-mb-3")- StatGroupSum2(- :trnsIds="periodTrnsIds"- )-- //- History- .px-3- TrnsHistory(- :trnsIds="trnsIds"- :trnType="filter.trnType"- @setFilterTrnType="value => filter.trnType = value"+ router-link(+ v-slot="{ href, navigate }"+ custom+ to="/wallets"+ )+ .flex.items-start+ a.grow.cursor-pointer.block.py-5.mb-3.px-3.font-nunito.hocus_bg-skin-item-main-hover(+ :href="href"+ @click="navigate"+ )+ .pb-1.text-xs.font-medium.text-skin-item-base-down+ | {{ $t("wallets.title") }}++ .flex.items-center.gap-3.pb-3+ .text-skin-item-base-up.text-2xl.font-semibold+ | {{ wallet.name }}+ .p-1.flex-center.rounded.text-skin-icon-base.text-2xs(:style="{ background: wallet.color }")+ | {{ wallet.currency }}++ .flex+ Amount(+ :currency="wallet.currency"+ :value="total"+ showBase+ size="lg"+ vertical="right"+ )++ .mdi.mdi-pencil-outline.cursor-pointer.rounded-full.mt-3.mr-2.w-16.h-16.flex-center.text-2xl.p-4.hocus_bg-gray-100.dark_hocus_bg-neutral-800(+ @click="handleEditClick")- //- Delete?- ModalBottomConfirm(- :show="showModalConfirm"- :description="deleteInfo"- @onClose="showModalConfirm = false"- @onConfirm="handleDeleteConfirm"- )+ .pb-6+ .px-3.flex+ .cursor-pointer.p-1.px-3.flex.items-center.gap-3.bg-gray-50.dark_bg-dark4.rounded-md.hocus_bg-gray-100.dark_hocus_bg-neutral-800.shadow.hocus_shadow-lg(+ class="dark_text-white/60"+ @click="handleSetFilterWallet"+ )+ .mdi.mdi-poll.text-xl+ .text-xs.leading-none {{ $t("statBy") }}: {{ wallet.name }}+ .mdi.mdi-chevron-right.opacity-70.text-lg.leading-none++ //- Stat+ .overflow-hidden.relative.bg-gray-50.dark_bg-custom4.mx-3.mb-12.p-3.rounded-md+ SharedDate.text-xs.font-medium(class="-mb-1 dark_text-white/50")+ div(class="-mb-3")+ StatGroupSum2(+ :trnsIds="periodTrnsIds"+ )++ //- History+ .px-3+ TrnsHistory(+ :trnsIds="trnsIds"+ :trnType="filter.trnType"+ @setFilterTrnType="value => filter.trnType = value"+ )</template><i18n lang="json5">diff --git a/components/wallets/sort/WalletsSort.vue b/components/wallets/sort/WalletsSort.vueindex bf5133d8..41e0122e 100644--- a/components/wallets/sort/WalletsSort.vue+++ b/components/wallets/sort/WalletsSort.vue@@ -38,7 +38,7 @@ export default {</script><template lang="pug">-.h-full.overflow.overflow-x-auto+.h-full.overflow.overflow-x-auto.bg-skin-layout-main//- Header//-----------------------------------.pb-6.text-neutral-800.dark_text-white.text-2xl.font-semibold.font-nunito@@ -51,7 +51,7 @@ export default {handle=".handle"ghost-class="_draggable")- .overflow-hidden.flex.items-center.gap-3.bg.py-0.pl-3.rounded-md(+ .overflow-hidden.py-0.pl-3.flex.items-center.gap-3.rounded-md.bg-skin-item-main-bg(v-for="walletId in sortedWalletsIds":key="walletId")@@ -62,7 +62,7 @@ export default {) {{ $store.state.wallets.items[walletId].name.substring(0, 2) }}.grow.text-sm.text-neutral-500(class="dark_text-neutral-400") {{ $store.state.wallets.items[walletId].name }}- .cursor-grab.flex-center.w-11.h-11.handle.doNotCloseModal.hocus_bg-gray-100.dark_hocus_bg-neutral-800+ .cursor-grab.flex-center.w-11.h-11.handle.doNotCloseModal.hocus_bg-skin-item-main-hoversvg.w-6.h-6(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24")path(fill="currentColor" d="M11 18c0 1.1-.9 2-2 2s-2-.9-2-2s.9-2 2-2s2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2s-2 .9-2 2s.9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2z")@@ -72,51 +72,34 @@ export default {:title="$t('base.save')"@onClick="saveWalletsOrder")-</template>--<style lang="stylus" scoped>-@import "~assets/stylus/variables"--.bg- background var(--c-item-bg-main)--item-bg-active()- background var(--c-bg-6)--item-main-text()- color var(--c-font-4)- fs-m()--item-icon()- color var(--c-font-5)- font-size 22px- &:active- item-bg-active()--.walletItem2- display grid- grid-template-columns minmax(10px, max-content) 1fr minmax(10px, max-content)- grid-template-rows repeat(2, 1fr)- grid-column-gap 20px- padding-left $m5- border-radius $m4- border-bottom 1px solid var(--c-bg-6)-- +media-hover()- item-bg-active()-- &._draggable- item-bg-active()-- &__icon- grid-column 1 / 2- grid-row 1 / -1- align-self center-- &__name- grid-column 2 / 3- grid-row 1 / 3- align-self center- item-main-text()-</style>+//- .px-3+//- //- Items+//- //-----------------------------------+//- Draggable.grid.gap-1(+//- v-model="sortedWalletsIds"+//- handle=".handle"+//- ghost-class="_draggable"+//- )+//- .overflow-hidden.flex.items-center.gap-3.bg.py-0.pl-3.rounded-md(+//- v-for="walletId in sortedWalletsIds"+//- :key="walletId"+//- )+//- .grow.flex-center.gap-x-3+//- .w-6.h-6.rounded-md.flex-center.text-neutral-50.text-xs.leading-none(+//- :style="{ background: $store.state.wallets.items[walletId].color }"+//- class="mt-[2px]"+//- ) {{ $store.state.wallets.items[walletId].name.substring(0, 2) }}+//- .grow.text-sm.text-neutral-500(class="dark_text-neutral-400") {{ $store.state.wallets.items[walletId].name }}++//- .cursor-grab.flex-center.w-11.h-11.handle.doNotCloseModal.hocus_bg-gray-100.dark_hocus_bg-neutral-800+//- svg.w-6.h-6(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24")+//- path(fill="currentColor" d="M11 18c0 1.1-.9 2-2 2s-2-.9-2-2s.9-2 2-2s2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2s-2 .9-2 2s.9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2s2-.9 2-2s-.9-2-2-2z")++//- .pt-6+//- SharedButton(+//- className="_blue2 _text-center"+//- :title="$t('base.save')"+//- @onClick="saveWalletsOrder"+//- )+</template>diff --git a/locales/en-US.js b/locales/en-US.jsindex e38909ef..2a96b51f 100644--- a/locales/en-US.js+++ b/locales/en-US.js@@ -137,12 +137,12 @@ export default {showAll: 'Show all wallets',showOnly: 'Show only',sortTitle: 'Sort wallets',- createNewTitle: 'Create new wallet',+ createNewTitle: 'Create wallet',editTitle: 'Edit Wallet',form: {name: {label: 'Wallet name',- placeholder: 'Write wallet name...',+ placeholder: 'Write...',error: 'Write wallet name',exist: 'Wallet with same name is exist',},diff --git a/locales/ru-RU.js b/locales/ru-RU.jsindex fb0f45d0..08d52bcf 100644--- a/locales/ru-RU.js+++ b/locales/ru-RU.js@@ -144,7 +144,7 @@ export default {form: {name: {label: 'Имя кошелька',- placeholder: 'Напишите имя кошелька...',+ placeholder: 'Напишите...',error: 'Напишите имя кошелька',exist: 'Кошелек с таким именем уже существует',},