Open source personal finance application
feat(release): 3.6.2
ilkomead61f6206d39
diff --git a/assets/js/colors.js b/assets/js/colors.jsindex 0636cd6b..c39c912d 100644--- a/assets/js/colors.js+++ b/assets/js/colors.js@@ -1,194 +1,148 @@-export default [- '#ffebee',- '#ffcdd2',- '#ef9a9a',- '#e57373',- '#ef5350',- '#f44336',- '#e53935',- '#d32f2f',- '#c62828',- '#b71c1c',- '#fce4ec',- '#f8bbd0',- '#f48fb1',- '#f06292',- '#ec407a',- '#e91e63',- '#d81b60',- '#c2185b',- '#ad1457',- '#880e4f',- '#f3e5f5',- '#e1bee7',- '#ce93d8',- '#ba68c8',- '#ab47bc',- '#9c27b0',- '#8e24aa',- '#7b1fa2',- '#6a1b9a',- '#4a148c',- '#ede7f6',- '#d1c4e9',- '#b39ddb',- '#9575cd',- '#7e57c2',- '#673ab7',- '#5e35b1',- '#512da8',- '#4527a0',- '#311b92',- '#e8eaf6',- '#c5cae9',- '#9fa8da',- '#7986cb',- '#5c6bc0',- '#3f51b5',- '#3949ab',- '#303f9f',- '#283593',- '#1a237e',- '#e3f2fd',- '#bbdefb',- '#90caf9',- '#64b5f6',- '#42a5f5',- '#2196f3',- '#1e88e5',- '#1976d2',- '#1565c0',- '#0d47a1',- '#e1f5fe',- '#b3e5fc',- '#81d4fa',- '#4fc3f7',- '#29b6f6',- '#03a9f4',- '#039be5',- '#0288d1',- '#0277bd',- '#01579b',- '#e0f7fa',- '#b2ebf2',- '#80deea',- '#4dd0e1',- '#26c6da',- '#00bcd4',- '#00acc1',- '#0097a7',- '#00838f',- '#006064',- '#e0f2f1',- '#b2dfdb',- '#80cbc4',- '#4db6ac',- '#26a69a',- '#009688',- '#00897b',- '#00796b',- '#00695c',- '#004d40',- '#e8f5e9',- '#c8e6c9',- '#a5d6a7',- '#81c784',- '#66bb6a',- '#4caf50',- '#43a047',- '#388e3c',- '#2e7d32',- '#1b5e20',- '#f1f8e9',- '#dcedc8',- '#c5e1a5',- '#aed581',- '#9ccc65',- '#8bc34a',- '#7cb342',- '#689f38',- '#558b2f',- '#33691e',- '#f9fbe7',- '#f0f4c3',- '#e6ee9c',- '#dce775',- '#d4e157',- '#cddc39',- '#c0ca33',- '#afb42b',- '#9e9d24',- '#827717',- '#fffde7',- '#fff9c4',- '#fff59d',- '#fff176',- '#ffee58',- '#ffeb3b',- '#fdd835',- '#fbc02d',- '#f9a825',- '#f57f17',- '#fff8e1',- '#ffecb3',- '#ffe082',- '#ffd54f',- '#ffca28',- '#ffc107',- '#ffb300',- '#ffa000',- '#ff8f00',- '#ff6f00',- '#fff3e0',- '#ffe0b2',- '#ffcc80',- '#ffb74d',- '#ffa726',- '#ff9800',- '#fb8c00',- '#f57c00',- '#ef6c00',- '#e65100',- '#fbe9e7',- '#ffccbc',- '#ffab91',- '#ff8a65',- '#ff7043',- '#ff5722',- '#f4511e',- '#e64a19',- '#d84315',- '#bf360c',- '#efebe9',- '#d7ccc8',- '#bcaaa4',- '#a1887f',- '#8d6e63',- '#795548',- '#6d4c41',- '#5d4037',- '#4e342e',- '#3e2723',- '#fafafa',- '#f5f5f5',- '#eeeeee',- '#e0e0e0',- '#bdbdbd',- '#9e9e9e',- '#757575',- '#616161',- '#424242',- '#212121',- '#eceff1',- '#cfd8dc',- '#b0bec5',- '#90a4ae',- '#78909c',- '#607d8b',- '#546e7a',- '#455a64',- '#37474f',- '#263238',- '#ffffff',- '#000000',+export const allColors = [+ [+ '#ef9a9a',+ '#e57373',+ '#ef5350',+ '#f44336',+ '#e53935',+ '#d32f2f',+ '#c62828',+ '#b71c1c',+ '#f48fb1',+ '#f06292',+ '#ec407a',+ '#e91e63',+ '#d81b60',+ '#c2185b',+ '#ad1457',+ '#880e4f',+ '#ce93d8',+ '#ba68c8',+ '#ab47bc',+ '#9c27b0',+ '#8e24aa',+ '#7b1fa2',+ '#6a1b9a',+ ],+ [+ '#b39ddb',+ '#9575cd',+ '#7e57c2',+ '#673ab7',+ '#5e35b1',+ '#512da8',+ '#4527a0',+ ], [+ '#9fa8da',+ '#7986cb',+ '#5c6bc0',+ '#3f51b5',+ '#3949ab',+ '#303f9f',+ ], [+ '#90caf9',+ '#64b5f6',+ '#42a5f5',+ '#2196f3',+ '#1e88e5',+ '#1976d2',+ '#1565c0',+ '#0d47a1',+ '#81d4fa',+ '#4fc3f7',+ '#29b6f6',+ '#03a9f4',+ '#039be5',+ '#0288d1',+ '#0277bd',+ '#01579b',+ '#80deea',+ '#4dd0e1',+ '#26c6da',+ '#00bcd4',+ '#00acc1',+ '#0097a7',+ '#00838f',+ '#006064',+ '#80cbc4',+ '#4db6ac',+ '#26a69a',+ '#009688',+ '#00897b',+ '#00796b',+ '#00695c',+ '#004d40',+ '#81c784',+ '#66bb6a',+ '#4caf50',+ '#43a047',+ '#388e3c',+ '#2e7d32',+ '#1b5e20',+ ], [+ '#aed581',+ '#9ccc65',+ '#8bc34a',+ '#7cb342',+ '#689f38',+ '#558b2f',+ '#33691e',+ ], [+ '#dce775',+ '#d4e157',+ '#cddc39',+ '#c0ca33',+ '#afb42b',+ '#9e9d24',+ '#827717',+ ], [+ '#ffeb3b',+ '#fdd835',+ '#fbc02d',+ '#f9a825',+ '#f57f17',+ ], [+ '#ffe082',+ '#ffd54f',+ '#ffca28',+ '#ffc107',+ '#ffb300',+ '#ffa000',+ '#ff8f00',+ '#ff6f00',+ '#ffcc80',+ '#ffb74d',+ '#ffa726',+ '#ff9800',+ '#fb8c00',+ '#f57c00',+ '#ef6c00',+ '#e65100',+ '#ffab91',+ '#ff8a65',+ '#ff7043',+ '#ff5722',+ '#f4511e',+ '#e64a19',+ '#d84315',+ '#bf360c',+ '#bcaaa4',+ '#a1887f',+ '#8d6e63',+ '#795548',+ '#6d4c41',+ '#5d4037',+ ], [+ '#bdbdbd',+ '#9e9e9e',+ '#757575',+ '#616161',+ ], [+ '#b0bec5',+ '#90a4ae',+ '#78909c',+ '#607d8b',+ '#546e7a',+ '#455a64',+ ],]diff --git a/assets/js/colorsPopular.js b/assets/js/colorsPopular.jsdeleted file mode 100644index a983d86f..00000000--- a/assets/js/colorsPopular.js+++ /dev/null@@ -1,186 +0,0 @@-export const popularColors = [- '#0288d1',- '#039be5',- '#03a9f4',- '#1976d2',- '#00bcd4',- '#c0ca33',- '#26a69a',- '#26c6da',- '#42a5f5',- '#4caf50',- '#4fc3f7',- '#5c6bc0',- '#689f38',- '#78909c',- '#8bc34a',- '#8d6e63',- '#9575cd',- '#a1887f',- '#ba68c8',- '#ce93d8',- '#d4e157',- '#d84315',- '#ec407a',- '#ef5350',- '#f06292',- '#f48fb1',- '#f57f17',- '#fb8c00',- '#fdd835',- '#ff8a65',- '#ffc107',-]--export const allColors = [- '#ef9a9a',- '#e57373',- '#ef5350',- '#f44336',- '#e53935',- '#d32f2f',- '#c62828',- '#b71c1c',- '#f48fb1',- '#f06292',- '#ec407a',- '#e91e63',- '#d81b60',- '#c2185b',- '#ad1457',- '#880e4f',- '#ce93d8',- '#ba68c8',- '#ab47bc',- '#9c27b0',- '#8e24aa',- '#7b1fa2',- '#6a1b9a',- '',- '#b39ddb',- '#9575cd',- '#7e57c2',- '#673ab7',- '#5e35b1',- '#512da8',- '#4527a0',- '',- '#9fa8da',- '#7986cb',- '#5c6bc0',- '#3f51b5',- '#3949ab',- '#303f9f',- '',- '',- '#90caf9',- '#64b5f6',- '#42a5f5',- '#2196f3',- '#1e88e5',- '#1976d2',- '#1565c0',- '#0d47a1',- '#81d4fa',- '#4fc3f7',- '#29b6f6',- '#03a9f4',- '#039be5',- '#0288d1',- '#0277bd',- '#01579b',- '#80deea',- '#4dd0e1',- '#26c6da',- '#00bcd4',- '#00acc1',- '#0097a7',- '#00838f',- '#006064',- '#80cbc4',- '#4db6ac',- '#26a69a',- '#009688',- '#00897b',- '#00796b',- '#00695c',- '#004d40',- '#81c784',- '#66bb6a',- '#4caf50',- '#43a047',- '#388e3c',- '#2e7d32',- '#1b5e20',- '',- '#aed581',- '#9ccc65',- '#8bc34a',- '#7cb342',- '#689f38',- '#558b2f',- '#33691e',- '',- '#dce775',- '#d4e157',- '#cddc39',- '#c0ca33',- '#afb42b',- '#9e9d24',- '#827717',- '',- '#ffeb3b',- '#fdd835',- '#fbc02d',- '#f9a825',- '#f57f17',- '',- '',- '',- '#ffe082',- '#ffd54f',- '#ffca28',- '#ffc107',- '#ffb300',- '#ffa000',- '#ff8f00',- '#ff6f00',- '#ffcc80',- '#ffb74d',- '#ffa726',- '#ff9800',- '#fb8c00',- '#f57c00',- '#ef6c00',- '#e65100',- '#ffab91',- '#ff8a65',- '#ff7043',- '#ff5722',- '#f4511e',- '#e64a19',- '#d84315',- '#bf360c',- '#bcaaa4',- '#a1887f',- '#8d6e63',- '#795548',- '#6d4c41',- '#5d4037',- '',- '',- '#bdbdbd',- '#9e9e9e',- '#757575',- '#616161',- '',- '',- '',- '',- '#b0bec5',- '#90a4ae',- '#78909c',- '#607d8b',- '#546e7a',- '#455a64',-]diff --git a/assets/stylus/colors-light.styl b/assets/stylus/colors-light.stylindex a28a6a73..8a533e6c 100644--- a/assets/stylus/colors-light.styl+++ b/assets/stylus/colors-light.styl@@ -60,7 +60,6 @@ html--c-font-5 #969696--c-bg-3 #fff- --color-text-link #0366d6--color-link-bg #eaeaea--c-item-bg-main #f5f6f8diff --git a/components/categories/Delete.vue b/components/categories/Delete.vuenew file mode 100644index 00000000..3ab49255--- /dev/null+++ b/components/categories/Delete.vue@@ -0,0 +1,84 @@+<script setup lang="ts">+import { getTrnsIds } from '~/components/trns/functions/getTrns'+import { errorEmo, random, successEmo } from '~/assets/js/emo'+import { removeData } from '~/services/firebase/api'+import type { CategoryID } from '~/components/categories/types'++const props = defineProps<{+ categoryId: CategoryID+}>()++const { $store, $notify } = useNuxtApp()+const router = useRouter()++const { categoryId } = toRefs(props)+const category = computed(() => $store.state.categories.items[categoryId.value])++const trnsItems = computed(() => $store.state.trns.items)+const trnsIds = computed(() =>+ getTrnsIds({+ categoriesIds: category.value?.childIds?.length > 0 ? category.value?.childIds : [categoryId.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 category.`+ return null+})++// TODO: translate+function onClickDelete() {+ for (const id in $store.state.categories.items) {+ if ($store.state.categories.items[id].parentId === categoryId.value) {+ $notify({+ title: random(errorEmo),+ type: 'error',+ text: 'You can not delete category with child categories. Remove child categories first.',+ })+ return false+ }+ }++ isShowDeleteConfirm.value = true+}++// TODO: translate+async function onDeleteConfirm() {+ // Disable reactive to have data when user have already redirected to categories page+ const uid = JSON.parse(JSON.stringify($store.state.user.user.uid))+ const trnsIdsS = JSON.parse(JSON.stringify(trnsIds.value))+ const categoryIdS = JSON.parse(JSON.stringify(categoryId.value))++ router.push('/categories')++ // Give some time to complete redirect+ setTimeout(async() => {+ await this.$store.dispatch('trns/deleteTrnsByIds', trnsIdsS)+ removeData(`users/${uid}/categories/${categoryIdS}`)+ .then(() => {+ $notify({+ type: 'success',+ text: trnsIdsS?.length > 0 ? `Success delete category with ${trnsIdsS.length} transactions!` : 'Success delete category!',+ title: random(successEmo),+ })+ })+ }, 100)+}+</script>++<template lang="pug">+div+ UiHeaderLink(@click="onClickDelete")+ .mdi.mdi-delete-empty-outline.group-hover_text-white.text-xl++ ModalBottomConfirm(+ :show="isShowDeleteConfirm"+ :description="deleteDescText"+ @onClose="isShowDeleteConfirm = false"+ @onConfirm="onDeleteConfirm"+ )+</template>diff --git a/components/categories/EditModal.vue b/components/categories/EditModal.vuedeleted file mode 100644index 422a5967..00000000--- a/components/categories/EditModal.vue+++ /dev/null@@ -1,695 +0,0 @@-<script>-import { saveData } from '~/services/firebase/api'-import generateId from '~/utils/id'-import { allColors, popularColors } from '~/assets/js/colorsPopular'-import { random } from '~/assets/js/emo'-import icons from '~/assets/js/icons'--export default {- setup() {- const { $store } = useNuxtApp()-- const showColors = ref(false)- const activeTab = ref('data')-- const category = ref({- color: '',- icon: '',- name: null,- parentId: 0,- showInLastUsed: true,- showInQuickSelector: false,- showStat: true,- })-- function findCategoryWithThisColor(color) {- const categories = $store.state.categories.items- if (categories) {- const categoryIdWithThisColor = $store.getters['categories/categoriesRootIds']?.find(id => categories[id]?.color === color)- if (categoryIdWithThisColor)- return categories[categoryIdWithThisColor]?.icon- }- }-- function onSelectColor(color) {- if (color)- category.value.color = color- }-- const documentHeight = ref('100%')- onMounted(() => {- documentHeight.value = `${document.documentElement.clientHeight}px`- })-- return {- activeTab,- category,- findCategoryWithThisColor,-- onSelectColor,- showColors,-- popularColors,- allColors,- documentHeight,- }- },-- data() {- return {- originalParentId: null,- showParents: false,- showIcons: false,- applyChildColor: true,- }- },-- computed: {- categoryId() {- return this.$store.state.categories.editId- },- },-- watch: {- categoryId: {- handler(categoryId) {- if (categoryId) {- this.category = {- ...this.category,- ...this.$store.state.categories.items[this.categoryId],- }-- this.originalParentId = this.category.parentId- }- },- immediate: true,- },- },-- created() {- this.colors = allColors- this.icons = icons- if (!this.$store.state.categories.editId) {- this.category.icon = random(random(icons))- this.category.color = random(popularColors)- }- },-- beforeUnmount() {- this.$store.commit('categories/setCategoryEditId', null)- },-- methods: {- closed() {- this.$store.commit('categories/setCategoryEditId', null)- this.$store.dispatch('ui/setActiveTab', null)- },-- handleIconSelect(icon) {- this.category.icon = icon- this.showIcons = false- },-- handleParenCategorySelect(categoryId) {- const parentCategory = this.$store.state.categories.items[categoryId]- if (parentCategory)- this.category.color = parentCategory.color-- this.category.parentId = categoryId- this.showParents = false- },-- handleSubmit(close) {- if (this.validateForm()) {- const uid = this.$store.state.user.user.uid- const id = this.categoryId || generateId()- const categories = this.$store.state.categories.items-- const categoriesValues = {- order: this.category.order || null,- color: this.category.color,- icon: this.category.icon,- name: this.category.name,- childIds: this.category.childIds || [],- parentId: this.category.parentId,- showInLastUsed: this.category.showInLastUsed,- showInQuickSelector: this.category.showInQuickSelector,- showStat: true,- }-- // ad or remove from parent- if (this.originalParentId !== this.category.parentId) {- // remove from old parent- if (this.originalParentId !== 0) {- const originalParent = categories[this.originalParentId]- if (originalParent) {- saveData(`users/${uid}/categories/${this.originalParentId}`, {- ...originalParent,- childIds: originalParent.childIds.filter(cId => cId !== id),- })- }- }-- // add to new parent- if (this.category.parentId !== 0) {- const parenCategory = categories[this.category.parentId]- const childIds = parenCategory.childIds- ? [...parenCategory.childIds.filter(cId => cId !== id), id]- : [id]-- saveData(`users/${uid}/categories/${this.category.parentId}`, {- ...parenCategory,- showInLastUsed: false,- showInQuickSelector: false,- childIds,- })- }- }-- const childIds = this.$store.getters['categories/getChildCategoriesIds'](id)-- // update category- saveData(`users/${uid}/categories/${id}`, {- ...categoriesValues,- childIds,- })-- // update child categories colors- if (this.applyChildColor) {- for (const childId of childIds)- saveData(`users/${uid}/categories/${childId}/color`, categoriesValues.color)- }-- close()- }- },-- validateForm() {- const categories = this.$store.state.categories.items- if (!this.category.name) {- this.$notify({- title: '😮',- text: this.$t('categories.form.name.error'),- })- return false- }-- for (const categoryId in categories) {- if (categories[categoryId].name === this.category.name && categories[categoryId].parentId === this.category.parentId) {- if (this.categoryId) {- if (this.categoryId !== categoryId) {- this.$notify({- title: '😮',- text: this.$t('categories.form.name.exist'),- })- return false- }- }- else {- this.$notify({- title: '😮',- text: this.$t('categories.form.name.exist'),- })- return false- }- }- }-- return true- },- },-}-</script>--<template lang="pug">-div- Portal(- key="categoryFormModal"- to="modal"- )- BaseBottomSheet(- show- @closed="closed()"- )- template(#handler="{ close }")- BaseBottomSheetClose(@onClick="close")-- template(#default="{ close }")- .content(:style="{ maxHeight: documentHeight }")- //- Header- .header- template(v-if="!categoryId") {{ $t('categories.createNewTitle') }}- template(v-else) {{ $t('categories.editTitle') }}-- //-- //- Menu- //-- .menu- .menuItem(- :class="{ _active: activeTab === 'data' }"- @click="activeTab = 'data'"- ) {{ $t('categories.form.data.label') }}- .menuItem(- :class="{ _active: activeTab === 'colors' }"- @click="activeTab = 'colors'"- ) {{ $t('categories.form.colors.label') }}- .menuItem(- :class="{ _active: activeTab === 'icons' }"- @click="activeTab = 'icons'"- ) {{ $t('categories.form.icons.label') }}-- .bg-main.m-3.p-2.rounded-md.items-center.gap-x-3.flex(- v-if="activeTab !== 'data'"- )- .text-neutral-50.text-xl.leading-none.w-8.h-8.rounded-full.justify-center.items-center.flex(- :style="{ background: category.color }"- @click.stop="handleIconClick"- ): div(:class="category.icon")- .text-sm.text-neutral-700(class="dark_text-neutral-300") {{ category.name || $t('categories.form.name.label') }}-- //-- //- Content- //-- .scrollerBlock- //- Data- template(v-if="activeTab === 'data'")- .form- .inputText- .inputText__label {{ $t('categories.form.name.label') }}- input(- type="text"- :placeholder="$t('categories.form.name.placeholder')"- v-model="category.name"- ).inputText__value-- //- can not change root category if inside this category already has some categories- div(- v-if="$store.getters['categories/getChildCategoriesIds'](categoryId).length === 0 && $store.getters['categories/hasCategories']"- style="paddingBottom: 8px"- )- .inputText__label {{ $t('categories.form.parent.label') }}-- div(@click="showParents = true")- template(v-if="category.parentId !== 0")- CategoriesItem(- :category="$store.state.categories.items[category.parentId]"- :id="category.parentId"- )- template(v-else)- .categoryParentItem- .categoryParentItem__icon- Icon(icon="mdi mdi-folder-star")- .categoryParentItem__name {{ $t('categories.form.parent.no') }}-- LazySharedContextMenuItem(- v-if="$store.getters['categories/getChildCategoriesIds'](categoryId).length"- :checkboxValue="applyChildColor"- :title="$t('categories.form.childColor')"- showCheckbox- @onClick="applyChildColor = !applyChildColor"- )- LazySharedContextMenuItem(- v-if="$store.getters['categories/getChildCategoriesIds'](categoryId).length === 0"- :checkboxValue="category.showInLastUsed"- :title="$t('categories.form.lastUsed')"- showCheckbox- @onClick="category.showInLastUsed = !category.showInLastUsed"- )- SharedContextMenuItem(- :checkboxValue="category.showInQuickSelector"- :title="$t('categories.form.quickSelector')"- showCheckbox- @onClick="category.showInQuickSelector = !category.showInQuickSelector"- )-- //-- //- Colors- //-- template(v-if="activeTab === 'colors'")- .form- .subTitle {{ $t('popularColors') }}- .colors- .iconItem(- v-for="(color, idx) in popularColors"- :key="idx"- :class="{ _active: color === category.color }"- :style="{ background: color === category.color ? color : 'transparent' }"- @click="onSelectColor(color)"- )- template(v-if="color")- //- .colorPreview(:style="{ background: color }")- template(v-if="findCategoryWithThisColor(color)")- Icon(- :icon="findCategoryWithThisColor(color)"- :color="color === category.color ? null : color"- big- )- template(v-else-if="color === category.color")- Icon(- :icon="category.icon"- background="transparent"- big- )- template(v-else)- .colorPreview(:style="{ background: color }")- //- Icon(- //- :icon="category.icon"- //- :color="color"- //- big- //- )-- .subTitle {{ $t('palette') }}- .colors- .iconItem(- v-for="(color, idx) in allColors"- :key="idx"- :class="{ _active: color === category.color, _empty: !color }"- :style="{ background: color === category.color ? color : 'transparent' }"- @click="onSelectColor(color)"- )-- template(v-if="color")- template(v-if="findCategoryWithThisColor(color)")- Icon(- :icon="findCategoryWithThisColor(color)"- :color="color === category.color ? null : color"- big- )- template(v-else-if="color === category.color")- Icon(- :icon="category.icon"- background="transparent"- big- )- template(v-else)- .colorPreview(:style="{ background: color }")- //- Icon(- //- icon="mdi mdi-folder-star"- //- :color="color"- //- big- //- )-- .subTitle {{ $t('categories.form.colors.custom') }}- .customColor- input.customColor__value(v-model="category.color" type="color")-- template(v-if="activeTab === 'icons'")- .form- .icons- .icons__group(- v-for="iconGroup in icons"- )- .iconItem(- v-for="icon in iconGroup"- :class="{ _active: category.icon === icon }"- :style="{ color: category.color }"- @click="handleIconSelect(icon)"- )- div(:class="icon")-- //- Submit- .col.pt-2.pb-6- SharedButton(- :class="['_text-center _blue2 _ml-big', { _inline: $store.state.ui.pc }]"- :title="$t('categories.form.save')"- @onClick="handleSubmit(close)"- )- //-- //- Parent Modal- //-- Portal(to="modal")- LazyBaseBottomSheet(- v-if="showParents"- @closed="showParents = false"- )- template(#handler="{ close }")- BaseBottomSheetClose(@onClick="close")-- template(#default="{ close }")- .content(:style="{ maxHeight: documentHeight }")- .scrollerBlock- .wrap- //- Header- .header {{ $t('categories.form.parent.label') }}-- .padding-bottom- ModalButton(- :name="$t('categories.form.parent.no')"- icon="mdi mdi-folder-star"- @onClick="() => handleParenCategorySelect(0)")-- CategoriesList(- :activeItemId="category.parentId"- :ids="$store.getters['categories/categoriesForBeParent'].filter(cId => cId !== categoryId)"- @onClick="handleParenCategorySelect"- )-</template>--<style lang="stylus" scoped>-.bg-main- background var(--c-item-bg-main)--.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--.categoryParentItem- overflow hidden- cursor pointer- position relative- display flex- flex-flow row nowrap- align-items center- justify-content center- min-height 48px- padding $m6- color var(--c-font-1)- background var(--c-item-bg-main)- border 1px solid transparent- border-radius $m5- anim()- +media-hover()- color var(--c-text-1)- background var(--c-item-bg-hover)- border 1px solid var(--c-item-bd-hover)- /.light &- color var(--c-font-2)--.menu- overflow hidden- z-index 10- display flex- align-items center- justify-content space-between- max-width 480px- overflow-x auto- margin 0 auto- padding $m5 $m6-- +media(600px)- overflow initial--.menuItem- cursor pointer- display flex- align-items center- justify-content center- min-height 38px- min-width 70px- margin 0 $m5- padding $m6 $m7- color var(--c-font-4)- font-size 12px- font-weight 500- font-roboto()- text-align center- border-radius $m6- anim()-- +media(400px)- min-width 80px- margin 0 $m5- padding-right $m7- padding-left $m7-- +media(600px)- padding-right $m9- padding-left $m9-- +media-hover()- &:not(._active)- cursor pointer- color var(--c-font-3)- background var(--c-item2-bg-hover)-- &._active- cursor default- color var(--c-blue-1)- background var(--c-item-bg-active)--.wrap- padding 0 $m8- padding-top $m6--.form- padding $m6-- .inputText- margin-bottom 0- padding-bottom $m8-- h2- padding-bottom $m6--.scrollerBlock- overflow hidden- overflow-y auto- height 100%--.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--.icons- &__group- display grid- grid-template-columns repeat(auto-fill, minmax(40px, 1fr))- padding-bottom $m8--.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)--.header- position relative- display flex- align-items center- justify-content center- padding $m7- padding-top 0- padding-bottom $m5- color var(--c-font-3)- font-size 18px- font-weight 700- letter-spacing 1px- fontFamilyNunito()-- /.light &- color var(--c-font-4)--.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--.padding-bottom- padding-bottom $m8--.content- overflow hidden- display grid- padding-top $m7- background var(--c-bg-3)- border-radius $m8 $m8 0 0-- +media(600px)- border-radius 16px--.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 $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--.inputModal- &._flex- flex 1- display flex- align-items center- justify-content space-between-- &__content- display flex-- &__label- margin 0- padding 0- font-size 10px-</style>--<style lang="stylus">-@import '~assets/stylus/variables'-</style>diff --git a/components/categories/Form.vue b/components/categories/Form.vueindex a65044ce..939ba89b 100644--- a/components/categories/Form.vue+++ b/components/categories/Form.vue@@ -1,445 +1,340 @@-<script>+<script setup lang="ts">+import { allColors } from '~/assets/js/colors'import { saveData } from '~/services/firebase/api'import generateId from '~/utils/id'-import colors from '~/assets/js/colors'import icons from '~/assets/js/icons'--function random(icons) {- return icons[Math.floor(Math.random() * icons.length)]+import type { CategoryID } from '~/components/categories/types'++const props = defineProps<{+ categoryId?: CategoryID+ categoryForm: {+ color: string+ icon: string+ name: string+ order: number+ parentId: string | 0+ showInLastUsed: boolean+ showInQuickSelector: boolean+ showStat: boolean+ }+}>()+const { categoryId, categoryForm } = toRefs(props)+const emit = defineEmits(['updateValue', 'afterSave'])++const { $store, $notify, nuxt2Context: { i18n } } = useNuxtApp()+const editCategoryId = categoryId.value ?? generateId()++const activeTab = ref('data')+const isUpdateChildCategoriesColor = ref(true)++const isAllowChangeParent = computed(() => {+ const childs = getChildCategoriesIds(categoryId.value)+ if (childs) return false++ return true+})++/**+ * Find category with color+ *+ * @param color+ */+function findCategoryWithThisColor(color) {+ const categoriesItems = $store.state.categories.items+ if (!categoriesItems)+ return false++ const categoryIdWithThisColor = $store.getters['categories/categoriesRootIds']?.find(id => categoriesItems[id]?.color === color)++ if (categoryIdWithThisColor)+ return categoriesItems[categoryIdWithThisColor]?.icon}-export default {- setup(_props, { emit }) {- const closed = () => {- emit('onClose')- }-- return {- closed,- }- },-- data() {- return {- originalParentId: null,- showParents: false,- showColors: false,- showIcons: false,- applyChildColor: true,- category: {- color: '',- icon: '',- name: null,- parentId: 0,- showInLastUsed: true,- showInQuickSelector: false,- showStat: true,- },+/**+ * Get child categoreies ids+ *+ * @param categoryId+ */+function getChildCategoriesIds(categoryId) {+ if (!categoryId) return false++ const category = $store.state.categories.items[categoryId]+ const categoriesItems = $store.state.categories.items+ const ids = []++ if (category?.parentId === 0) {+ for (const id in categoriesItems) {+ if (categoriesItems[id].parentId === categoryId)+ ids.push(id)}- },-- computed: {- categoryId() {- return this.$store.state.categories.editId- },- },-- watch: {- categoryId: {- handler(categoryId) {- if (categoryId) {- this.category = {- ...this.category,- ...this.$store.state.categories.items[this.categoryId],- }-- this.originalParentId = this.category.parentId- }- },- immediate: true,- },- },-- created() {- this.colors = colors- this.icons = icons- if (!this.$store.state.categories.editId) {- this.category.icon = random(random(icons))- this.category.color = colors[Math.floor(Math.random() * colors.length)]- }- },-- beforeUnmount() {- this.$store.commit('categories/setCategoryEditId', null)- },-- methods: {- handleColorSelect(color) {- this.category.color = color- this.showColors = false- },-- handleIconSelect(icon) {- this.category.icon = icon- this.showIcons = false- },-- handleParenCategorySelect(categoryId) {- const parentCategory = this.$store.state.categories.items[categoryId]- if (parentCategory)- this.category.color = parentCategory.color-- this.category.parentId = categoryId- this.showParents = false- },-- handleSubmit() {- if (this.validateForm()) {- const uid = this.$store.state.user.user.uid- const id = this.categoryId || generateId()- const categories = this.$store.state.categories.items-- const categoriesValues = {- order: this.category.order || null,- color: this.category.color,- icon: this.category.icon,- name: this.category.name,- childIds: this.category.childIds || [],- parentId: this.category.parentId,- showInLastUsed: this.category.showInLastUsed,- showInQuickSelector: this.category.showInQuickSelector,- showStat: true,- }+ }- // ad or remove from parent- if (this.originalParentId !== this.category.parentId) {- // remove from old parent- if (this.originalParentId !== 0) {- const originalParent = categories[this.originalParentId]- if (originalParent) {- saveData(`users/${uid}/categories/${this.originalParentId}`, {- ...originalParent,- childIds: originalParent.childIds.filter(cId => cId !== id),- })- }- }-- // add to new parent- if (this.category.parentId !== 0) {- const parenCategory = categories[this.category.parentId]- const childIds = parenCategory.childIds- ? [...parenCategory.childIds.filter(cId => cId !== id), id]- : [id]-- saveData(`users/${uid}/categories/${this.category.parentId}`, {- ...parenCategory,- childIds,- })- }- }+ if (ids.length === 0)+ return false- const childIds = this.$store.getters['categories/getChildCategoriesIds'](id)+ return ids+}- // update category- saveData(`users/${uid}/categories/${id}`, {- ...categoriesValues,- childIds,- })+/**+ * Select parent+ * @param parentId+ */+function onParentSelect(parentId) {+ emit('updateValue', 'parentId', parentId)++ // Change category color when patent category changed+ const parentCategoryColor = $store.state.categories.items[parentId]?.color+ if (parentCategoryColor)+ emit('updateValue', 'color', parentCategoryColor)+}- // update child categories colors- if (this.applyChildColor) {- for (const childId of childIds) {- const category = categories[childId]- saveData(`users/${uid}/categories/${childId}`, {- ...category,- color: categoriesValues.color,- })- }+/**+ * Validate+ */+function validate({ values, categoriesItems }) {+ if (!values.name) {+ $notify({+ title: '😮',+ text: i18n.t('categories.form.name.error'),+ })+ return false+ }++ for (const id in categoriesItems) {+ if (categoriesItems[id].name === values.name && categoriesItems[id].parentId === values.parentId) {+ if (editCategoryId) {+ if (editCategoryId !== id) {+ $notify({+ title: '😮',+ text: i18n.t('categories.form.name.exist'),+ })+ return false}-- this.$store.commit('categories/setCategoryEditId', null)-- if (this.$listeners.callback)- this.$listeners.callback()}- },-- validateForm() {- const categories = this.$store.state.categories.items- if (!this.category.name) {- this.$notify({+ else {+ $notify({title: '😮',- text: this.$t('categories.form.name.error'),+ text: i18n.t('categories.form.name.exist'),})return false}+ }+ }- for (const categoryId in categories) {- if (categories[categoryId].name === this.category.name && categories[categoryId].parentId === this.category.parentId) {- if (this.categoryId) {- if (this.categoryId !== categoryId) {- this.$notify({- title: '😮',- text: this.$t('categories.form.name.exist'),- })- return false- }- }- else {- this.$notify({- title: '😮',- text: this.$t('categories.form.name.exist'),- })- return false- }- }- }+ return true+}++function prepareForm({ values, categoryChildIds }) {+ return {+ color: values.color,+ icon: values.icon,+ name: values.name,+ order: values.order,+ parentId: values.parentId,+ showInLastUsed: categoryChildIds ? false : values.showInLastUsed,+ showInQuickSelector: categoryChildIds ? false : values.showInQuickSelector,+ showStat: categoryChildIds ? false : values.showStat,+ }+}++async function onSave() {+ const categoriesItems = $store.state.categories.items++ const isFormValid = validate({ values: categoryForm.value, categoriesItems })+ if (!isFormValid)+ return- return true- },- },+ const uid = $store.state.user.user.uid+ const categoryChildIds = getChildCategoriesIds(editCategoryId)+ const categoryValues = prepareForm({ values: categoryForm.value, categoryChildIds })++ // Update category+ await saveData(`users/${uid}/categories/${editCategoryId}`, categoryValues)++ // Update child categories colors+ if (isUpdateChildCategoriesColor.value && categoryChildIds) {+ for (const childId of categoryChildIds)+ await saveData(`users/${uid}/categories/${childId}/color`, categoryValues.color)+ }++ emit('afterSave')}</script><template lang="pug">-.form- .header- template(v-if="!categoryId") {{ $t('categories.createNewTitle') }}- template(v-else) {{ $t('categories.editTitle') }}-- .content- .form-line._text- .inputText- .inputText__label {{ $t('categories.form.name.label') }}- input(- type="text"+div+ .pb-8.px-3+ UiTabs+ UiTabsItem(+ :isActive="activeTab === 'data'"+ @click="activeTab = 'data'"+ ) {{ $t('categories.form.data.label') }}++ UiTabsItem(+ v-if="$store.getters['categories/hasCategories']"+ :isActive="activeTab === 'parent'"+ @click="activeTab = 'parent'"+ ) {{ $t('categories.form.parent.label') }}++ UiTabsItem(+ :isActive="activeTab === 'colors'"+ @click="activeTab = 'colors'"+ ) {{ $t('categories.form.colors.label') }}++ UiTabsItem(+ :isActive="activeTab === 'icon'"+ @click="activeTab = 'icon'"+ ) {{ $t('categories.form.icon.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('categories.form.name.placeholder')"- v-model="category.name"- ).inputText__value-- //- can not change root category if inside this category already has some categories- template(v-if="$store.getters['categories/getChildCategoriesIds'](categoryId).length === 0 && $store.getters['categories/hasCategories']")- .form__btns__i._full- .form-line(@click="showParents = true")- .inputModal._flex- .inputModal__content- template(v-if="category.parentId !== 0")- .inputModal__icon- div(- :class="$store.state.categories.items[category.parentId].icon"- :style="{ color: $store.state.categories.items[category.parentId].color }"- )- .inputModal__name {{ $store.state.categories.items[category.parentId].name }}- template(v-else)- .inputModal__icon: .mdi.mdi-folder-star- .inputModal__name {{ $t('categories.form.parent.no') }}- .inputModal__label {{ $t('categories.form.parent.label') }}-- .form__btns- //- Colors- .form__btns__i.cursor-pointer- .form-line(@click="showColors = true")- .inputModal._flex- .inputModal__value: .inputModal__color(:style="{ background: category.color }")- .inputModal__label {{ $t('categories.form.colors.label') }}-- //- icons- .form__btns__i.cursor-pointer- .form-line(@click="showIcons = true")- .inputModal._flex- .inputModal__icon: div(:class="category.icon", :style="{ color: category.color }")- .inputModal__label {{ $t('categories.form.icons.label') }}-- template(v-if="$store.getters['categories/getChildCategoriesIds'](categoryId).length")- .form-line._p0._clean- SharedContextMenuItem(- :checkboxValue="applyChildColor"- :title="$t('categories.form.childColor')"- showCheckbox- @onClick="applyChildColor = !applyChildColor"+ :value="categoryForm.name"+ type="text"+ @input="event => emit('updateValue', 'name', event.target.value)")- template(v-if="$store.getters['categories/getChildCategoriesIds'](categoryId).length === 0")- SharedContextMenuItem(- :checkboxValue="category.showInLastUsed"+ LazySharedContextMenuItem(+ v-if="getChildCategoriesIds(categoryId)"+ :checkboxValue="isUpdateChildCategoriesColor"+ :title="$t('categories.form.childColor')"+ showCheckbox+ @onClick="isUpdateChildCategoriesColor = !isUpdateChildCategoriesColor"+ )+ LazySharedContextMenuItem(+ v-if="!getChildCategoriesIds(categoryId)"+ :checkboxValue="categoryForm.showInLastUsed":title="$t('categories.form.lastUsed')"showCheckbox- @onClick="category.showInLastUsed = !category.showInLastUsed"+ @onClick="categoryForm.showInLastUsed = !categoryForm.showInLastUsed")SharedContextMenuItem(- :checkboxValue="category.showInQuickSelector"+ v-if="!getChildCategoriesIds(categoryId)"+ :checkboxValue="categoryForm.showInQuickSelector":title="$t('categories.form.quickSelector')"showCheckbox- @onClick="category.showInQuickSelector = !category.showInQuickSelector"+ @onClick="categoryForm.showInQuickSelector = !categoryForm.showInQuickSelector")- .col(style="padding-top: 16px; text-align: center")+ //- Colors+ //---------------------------------+ template(v-if="activeTab === 'colors'")+ div+ div+ .pb-1(+ v-for="(colorsGroup, groupIdx) in allColors"+ :key="groupIdx"+ )+ .colors+ .iconItem(+ v-for="(color, idx) in colorsGroup"+ :key="idx"+ :class="{ _active: color === categoryForm.color, 'pointer-events-none': !color }"+ :style="{ background: color === categoryForm.color ? color : 'transparent' }"+ @click="emit('updateValue', 'color', color)"+ )+ template(v-if="findCategoryWithThisColor(color)")+ Icon(+ :icon="color === categoryForm.color ? categoryForm.icon : findCategoryWithThisColor(color)"+ :background="color"+ round+ )+ template(v-else-if="color === categoryForm.color")+ Icon(+ :icon="categoryForm.icon"+ background="transparent"+ big+ )+ template(v-else-if="color")+ .colorPreview(:style="{ background: color }")++ .pb-2.text-sm.text-skin-item-base-down {{ $t('wallets.form.colors.custom') }}+ input.cursor-pointer.w-full.h-12.p-0.border-0(v-model="categoryForm.color" type="color")++ //- Parent+ //---------------------------------+ template(v-if="activeTab === 'parent'")+ template(v-if="!isAllowChangeParent")+ //- TODO: translate+ .p-4 You can not change parent category because edited category has childs categories.++ template(v-if="isAllowChangeParent")+ .cursor-pointer.mb-4.py-3.px-3.gap-x-3.flex-center.rounded-md.text-center.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(+ :class="{ '!cursor-default !bg-skin-item-main-active': categoryForm.parentId === 0 }"+ @click="emit('updateValue', 'parentId', 0)"+ ) {{ $t('categories.form.parent.no') }}++ CategoriesList(+ :activeItemId="categoryForm.parentId"+ :ids="$store.getters['categories/categoriesForBeParent'].filter(cId => cId !== categoryId)"+ :slider="() => ({})"+ class="!gap-x-1"+ @onClick="onParentSelect"+ )++ //- Icon+ //---------------------------------+ template(v-if="activeTab === 'icon'")+ .flex.flex-wrap.pb-8.gap-3(v-for="iconGroup in icons")+ .cursor-pointer.w-10.h-10.rounded-full.flex-center.border-2.border-transparent(+ v-for="icon in iconGroup"+ :key="icon"+ :class="{ 'border-skin-accent-base': icon === categoryForm.icon }"+ :style="{ background: categoryForm.color }"+ @click="emit('updateValue', 'icon', icon)"+ )+ .text-2xl.text-skin-icon-base(:class="icon")++ //- Save+ //---------------------------------+ .pt-4.pb-6SharedButton(:class="['_text-center _blue2 _ml-big', { _inline: $store.state.ui.pc }]"- :title="$t('categories.form.save')"- @onClick="handleSubmit"+ :title="$t('wallets.form.save')"+ @onClick="onSave")-- //- Colors- LazyBaseBottomSheet(- v-if="showColors"- :maxHeight="$store.state.ui.height"- @closed="showColors = false"- )- template(#handler="{ close }")- BaseBottomSheetClose(@onClick="close")-- template(#header)- .header- .header__title {{ $t('colors') }}-- template(#default="{ close }")- .p-3.bg-white(class="dark_bg-dark3")- .inputText- .inputText__colors- .colors- .colorItem(- :class="{ _active: category.color === color }"- :style="{ background: color }"- v-for="color in colors"- @click="handleColorSelect(color)"- )- .customColor- .customColor__title {{ $t('categories.form.colors.custom') }}- input.customColor__value(v-model="category.color" type="color")-- //- Icons- LazyBaseBottomSheet(- v-if="showIcons"- :maxHeight="$store.state.ui.height"- @onClose="showIcons = false"- )- template(#handler="{ close }")- BaseBottomSheetClose(@onClick="close")-- template(#header)- .header- .header__title {{ $t('categories.form.icons.label') }}-- template(#default="{ close }")- .p-3.bg-white(class="dark_bg-dark3")- .icons- .icons__group(- v-for="iconGroup in icons"- )- .iconItem(- v-for="icon in iconGroup"- :class="{ _active: category.icon === icon }"- :style="{ color: category.color }"- @click="handleIconSelect(icon)"- )- div(:class="icon")</template><style lang="stylus" scoped>-.content- +media(600px)- border-radius 0 0 $m7 $m7--.header- padding $m8- flex-grow 1- fontFamilyNunito()- color var(--c-font-2)- font-size 28px- font-weight 700- text-align center- background var(--c-bg-3)- border-radius $m7 $m7 0 0--.icons- &__group- display grid- grid-template-columns repeat(auto-fill, minmax(50px, 1fr))- padding-bottom 20px--.iconItem+.colorPreviewdisplay flexalign-items centerjustify-content center- min-height 50px- padding 8px- font-size 30px+ width 90%+ height 90%+ border-radius 50%- &._active- background var(--c-bg-2)- border-radius 4px- box-shadow 0 2px 10px 0 var(--shaddow)--.customColor- margin (- $m7)- margin-top 0- padding $m7- background var(--c-bg-3)-- @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--.padding-bottom+.colors+ display grid+ grid-template-columns repeat(8, minmax(auto, 1fr))padding-bottom $m8+ &:last-child+ padding-bottom 0-.content- padding $m8- background var(--c-bg-3)- +media(600px)- border-radius 0 0 $m7 $m7--.form__actions- @media $media-phone- text-align center+.iconItem+ display flex+ align-items center+ justify-content center+ width 40px+ height 40px+ max-width 40px+ max-height 40px+ font-size 24px+ border-radius 50%++ +media-hover()+ &:not(._empty)+ cursor pointer+ background var(--c-item-bd-hover)-.form__btns- display grid- grid-template-columns repeat(2, 1fr)- grid-column-gap $m9- grid-row-gap $m9- padding-bottom $m9-- @media $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--.inputModal- &._flex- flex 1- display flex- align-items center- justify-content space-between-- &__content- display flex-- &__label- margin 0+ &._activepadding 0- font-size 10px+ background var(--c-item-bd-hover)</style>diff --git a/components/categories/Item.vue b/components/categories/Item.vueindex 686b84dd..7687c005 100644--- a/components/categories/Item.vue+++ b/components/categories/Item.vue@@ -44,7 +44,7 @@ export default defineComponent({</script><template lang="pug">-.cursor-pointer.py-2.px-3.relative.gap-x-3.flex.items-center.rounded-md.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(+.cursor-pointer.py-2.px-3.gap-x-3.flex.items-center.rounded-md.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(v-if="category":class="{ '!cursor-default !bg-skin-item-main-active': activeItemId === id }"@click="onClickItem"@@ -60,7 +60,7 @@ export default defineComponent({class="dark_text-neutral-400") {{ parentCategory.name }}- .leading-none.text-sm.text-neutral-700.dark_text-neutral-300 {{ category.name }}+ .leading-none.text-sm.text-skin-item-base {{ category.name }}.font-unica.text-md.text-skin-item-base-down(v-if="childCategoriesIds.length > 0"diff --git a/components/categories/page/List.vue b/components/categories/page/List.vueindex c2024589..71dd5aef 100644--- a/components/categories/page/List.vue+++ b/components/categories/page/List.vue@@ -19,38 +19,25 @@ export default defineComponent({</script><template lang="pug">-.overflow-y-auto.h-full.grid.max-w-3xl(- class="md_pb-[52px] pb-[44px] lg_pb-0 grid-rows-[1fr_auto]"-)- div- //- Header- //---------------------------------- .flex- //- Title- .grow.py-6.px-3.font-nunito.text-neutral-800.dark_text-white.text-2xl.leading-none.font-semibold- | {{ $t('categories.name') }}+UiPage+ UiHeader+ UiHeaderTitle {{ $t('categories.name') }}+ template(#actions)+ UiHeaderLink(@click="$router.push('/categories/new')")+ UiIconAdd.group-hover_text-white.w-6.h-6- //- Actions- .flex-center.gap-3.pr-3- //- Add- .cursor-pointer.group.w-10.h-10.flex-center.rounded-full.bg-gray-50.dark_bg-dark5.hocus-text-white.hocus_bg-blue2(- @click="$store.dispatch('ui/setActiveTab', 'createCategory')"- )- svg.group-hover_text-white.w-6.h-6(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12")- path(fill="currentColor" d="M6 1.5a.5.5 0 0 0-1 0V5H1.5a.5.5 0 0 0 0 1H5v3.5a.5.5 0 0 0 1 0V6h3.5a.5.5 0 0 0 0-1H6V1.5Z")+ //- List+ .pb-12.px-3+ CategoriesList(+ :ids="catsIds"+ @onClick="catId => $router.push(`/categories/${catId}`)"+ )- //- List- //---------------------------------- .pb-12.px-3- CategoriesList(- :ids="catsIds"- @onClick="catId => $router.push(`/categories/${catId}`)"- )-- .pb-4.px-3.flex.justify-evenly.gap-6- //- Create- .cursor-pointer.grow.py-3.px-5.flex-center.rounded-full.text-sm.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(- class="basis-1/2 max-w-[280px]"- @click="$store.dispatch('ui/setActiveTab', 'createCategory')"- ) {{ $t('categories.new') }}+ template(#bottom)+ .pb-4.px-3.flex.justify-evenly.gap-6+ //- Create+ .cursor-pointer.grow.py-3.px-5.flex-center.rounded-full.text-sm.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(+ class="basis-1/2 max-w-[280px]"+ @click="$router.push('/categories/new')"+ ) {{ $t('categories.new') }}</template>diff --git a/components/categories/page/New.vue b/components/categories/page/New.vuenew file mode 100644index 00000000..9a85b466--- /dev/null+++ b/components/categories/page/New.vue@@ -0,0 +1,68 @@+<script setup lang="ts">+import { allColors } from '~/assets/js/colors'+import { random } from '~/assets/js/emo'+import icons from '~/assets/js/icons'++const { $store } = useNuxtApp()+const router = useRouter()++const categoryForm = ref({+ color: random(random(allColors)),+ icon: random(random(icons)),+ name: null,+ order: 1,+ parentId: 0,+ showInLastUsed: true,+ showInQuickSelector: false,+ showStat: true,+})++const parentCategory = computed(() => {+ if (categoryForm.value.parentId === 0)+ return false++ return $store.state.categories.items[categoryForm.value.parentId]+})++function updateValue(id, value) {+ categoryForm.value[id] = value+}++function afterSave() {+ router.push('/categories')+}+</script>++<script lang="ts">+export default defineComponent({+ head() {+ return {+ title: `${this.$t('base.add')}: ${this.categoryForm.name ? this.categoryForm.name : this.$t('categories.form.name.label')}`,+ }+ },+})+</script>++<template lang="pug">+UiPage+ UiHeader+ router-link(v-slot="{ href, navigate }" to="/categories" custom)+ a.grow.hocus_bg-skin-item-main-hover(:href="href" @click="navigate")+ UiHeaderTitle+ .pb-1.text-xs.font-medium.text-skin-item-base-down+ | {{ $t('categories.createNewTitle') }}+ template(v-if="parentCategory")+ |+ | in {{ parentCategory.name }}++ .flex.items-center.gap-4+ | {{ categoryForm.name ? categoryForm.name : $t("categories.form.name.label") }}+ .w-8.h-8.rounded-full.flex-center.text-xl.text-skin-icon-base(:style="{ background: categoryForm.color }")+ div(:class="categoryForm.icon")++ CategoriesForm(+ :categoryForm="categoryForm"+ @updateValue="updateValue"+ @afterSave="afterSave"+ )+</template>diff --git a/components/categories/page/id/Edit.vue b/components/categories/page/id/Edit.vueindex fd0f4523..733b1622 100644--- a/components/categories/page/id/Edit.vue+++ b/components/categories/page/id/Edit.vue@@ -1,644 +1,79 @@-<script lang="ts">-import { saveData } from '~/services/firebase/api'-import generateId from '~/utils/id'-import { allColors, popularColors } from '~/assets/js/colorsPopular'+<script setup lang="ts">+import { allColors } from '~/assets/js/colors'import { random } from '~/assets/js/emo'import icons from '~/assets/js/icons'-export default defineComponent({- setup() {- const { $store } = useNuxtApp()- const activeTab = ref('data')-- const category = ref({- color: '',- icon: '',- name: null,- parentId: 0,- showInLastUsed: true,- showInQuickSelector: false,- showStat: true,- })-- function findCategoryWithThisColor(color) {- const categories = $store.state.categories.items- if (categories) {- const categoryIdWithThisColor = $store.getters['categories/categoriesRootIds']?.find(id => categories[id]?.color === color)- if (categoryIdWithThisColor)- return categories[categoryIdWithThisColor]?.icon- }- }-- function onSelectColor(color) {- if (color)- category.value.color = color- }+const { $store } = useNuxtApp()+const router = useRouter()+const route = useRoute()++const categoryId = computed(() => route.params.id)+const category = computed(() => $store.state.categories.items[categoryId.value])++const categoryForm = ref({+ color: category.value?.color || random(allColors),+ icon: category.value?.icon || random(random(icons)),+ name: category.value?.name || null,+ order: category.value?.order || 1,+ parentId: category.value?.parentId || 0,+ showInLastUsed: category.value?.showInLastUsed !== undefined ? category.value.showInLastUsed : true,+ showInQuickSelector: category.value?.showInQuickSelector !== undefined ? category.value.showInQuickSelector : false,+ showStat: category.value?.showStat !== undefined ? category.value.showStat : true,+})- const documentHeight = ref('100%')- onMounted(() => {- documentHeight.value = `${document.documentElement.clientHeight}px`- })+const parentCategory = computed(() => {+ if (category.value.parentId === 0)+ return false- return {- activeTab,- category,- findCategoryWithThisColor,+ return $store.state.categories.items[categoryForm.value.parentId]+})- onSelectColor,+function updateValue(id, value) {+ categoryForm.value[id] = value+}- popularColors,- allColors,- documentHeight,- }- },+function afterSave() {+ router.replace(`/categories/${categoryId.value}`)+}+</script>- data() {+<script lang="ts">+export default defineComponent({+ head() {return {- originalParentId: null,- showParents: false,- showIcons: false,- applyChildColor: true,- }- },-- computed: {- categoryId() {- return this.$route.params.id- },- },-- watch: {- categoryId: {- handler(categoryId) {- if (categoryId) {- this.category = {- ...this.category,- ...this.$store.state.categories.items[this.categoryId],- }-- this.originalParentId = this.category.parentId- }- },- immediate: true,- },- },-- created() {- this.colors = allColors- this.icons = icons- if (!this.categoryId) {- this.category.icon = random(random(icons))- this.category.color = random(popularColors)+ title: `${this.$t('base.edit')}: ${this.categoryForm.name ? this.categoryForm.name : this.$t('wallets.form.name.label')}`,}},-- beforeUnmount() {- this.$store.commit('categories/setCategoryEditId', null)- },-- methods: {- closed() {- this.$store.commit('categories/setCategoryEditId', null)- this.$store.dispatch('ui/setActiveTab', null)- },-- handleIconSelect(icon) {- this.category.icon = icon- this.showIcons = false- },-- handleParenCategorySelect(categoryId) {- const parentCategory = this.$store.state.categories.items[categoryId]- if (parentCategory)- this.category.color = parentCategory.color-- this.category.parentId = categoryId- this.showParents = false- },-- handleSubmit() {- if (!this.validateForm())- return-- const uid = this.$store.state.user.user.uid- const id = this.categoryId || generateId()- const categories = this.$store.state.categories.items-- const categoriesValues = {- order: this.category.order || null,- color: this.category.color,- icon: this.category.icon,- name: this.category.name,- childIds: this.category.childIds || [],- parentId: this.category.parentId,- showInLastUsed: this.category.showInLastUsed,- showInQuickSelector: this.category.showInQuickSelector,- showStat: true,- }-- // ad or remove from parent- if (this.originalParentId !== this.category.parentId) {- // remove from old parent- if (this.originalParentId !== 0) {- const originalParent = categories[this.originalParentId]- if (originalParent) {- saveData(`users/${uid}/categories/${this.originalParentId}`, {- ...originalParent,- childIds: originalParent.childIds.filter(cId => cId !== id),- })- }- }-- // add to new parent- if (this.category.parentId !== 0) {- const parenCategory = categories[this.category.parentId]- const childIds = parenCategory.childIds- ? [...parenCategory.childIds.filter(cId => cId !== id), id]- : [id]-- saveData(`users/${uid}/categories/${this.category.parentId}`, {- ...parenCategory,- showInLastUsed: false,- showInQuickSelector: false,- childIds,- })- }- }-- const childIds = this.$store.getters['categories/getChildCategoriesIds'](id)-- // update category- saveData(`users/${uid}/categories/${id}`, {- ...categoriesValues,- })-- // update child categories colors- if (this.applyChildColor) {- for (const childId of childIds)- saveData(`users/${uid}/categories/${childId}/color`, categoriesValues.color)- }-- this.$router.replace(`/categories/${id}`)- },-- validateForm() {- const categories = this.$store.state.categories.items- if (!this.category.name) {- this.$notify({- title: '😮',- text: this.$t('categories.form.name.error'),- })- return false- }-- for (const categoryId in categories) {- if (categories[categoryId].name === this.category.name && categories[categoryId].parentId === this.category.parentId) {- if (this.categoryId) {- if (this.categoryId !== categoryId) {- this.$notify({- title: '😮',- text: this.$t('categories.form.name.exist'),- })- return false- }- }- else {- this.$notify({- title: '😮',- text: this.$t('categories.form.name.exist'),- })- return false- }- }- }-- return true- },- },})</script><template lang="pug">-.h-full.overflow.overflow-x-auto.max-w-3xl.h-full(- class="pb-[44px] md_pb-[52px] lg_pb-0"-)- template(v-if="category")- router-link(- v-slot='{ href, navigate }'- :to='`/categories/${categoryId}`'- custom- )- a.grow.cursor-pointer.block.py-5.pb-5.mb-3.px-3.font-nunito.hocus_bg-gray-100.dark_hocus_bg-neutral-800(+UiPage(v-if="category")+ UiHeader+ router-link(v-slot="{ href, navigate }" :to='`/categories/${categoryId}`' custom)+ a.grow.hocus_bg-skin-item-main-hover(:href='href'@click='navigate')- .pb-2.text-xs.font-medium(class="dark_text-white/50") {{ $t('categories.editTitle') }}-- .flex.items-center.gap-3- .text-neutral-800.dark_text-white.text-2xl.leading-none.font-semibold {{ category.name }}- .w-8.h-8.rounded-full.flex-center.text-xl.text-neutral-50(- :style="{ background: category.color }"- )- div(:class="category.icon")-- //- 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 === 'colors' }"- @click="activeTab = 'colors'"- ) {{ $t('categories.form.colors.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 === 'icons' }"- @click="activeTab = 'icons'"- ) {{ $t('categories.form.icons.label') }}-- //- Content- //------------------------------------ .px-3.max-w-md- template(v-if="activeTab === 'data'")- .form- .inputText- .inputText__label {{ $t('categories.form.name.label') }}- input(- type="text"- :placeholder="$t('categories.form.name.placeholder')"- v-model="category.name"- ).inputText__value-- //- can not change root category if inside this category already has some categories- div(- v-if="$store.getters['categories/getChildCategoriesIds'](categoryId).length === 0 && $store.getters['categories/hasCategories']"- style="paddingBottom: 8px"- )- .inputText__label {{ $t('categories.form.parent.label') }}-- div(@click="showParents = true")- template(v-if="category.parentId !== 0")- CategoriesItem(- :category="$store.state.categories.items[category.parentId]"- :id="category.parentId"- )- template(v-else)- .categoryParentItem- .categoryParentItem__icon- Icon(icon="mdi mdi-folder-star")- .categoryParentItem__name {{ $t('categories.form.parent.no') }}-- LazySharedContextMenuItem(- v-if="$store.getters['categories/getChildCategoriesIds'](categoryId).length"- :checkboxValue="applyChildColor"- :title="$t('categories.form.childColor')"- showCheckbox- @onClick="applyChildColor = !applyChildColor"- )- LazySharedContextMenuItem(- v-if="$store.getters['categories/getChildCategoriesIds'](categoryId).length === 0"- :checkboxValue="category.showInLastUsed"- :title="$t('categories.form.lastUsed')"- showCheckbox- @onClick="category.showInLastUsed = !category.showInLastUsed"- )- SharedContextMenuItem(- :checkboxValue="category.showInQuickSelector"- :title="$t('categories.form.quickSelector')"- showCheckbox- @onClick="category.showInQuickSelector = !category.showInQuickSelector"- )-- //- Colors- //---------------------------------- template(v-if="activeTab === 'colors'")- .form- .subTitle {{ $t('popularColors') }}- .colors- .iconItem(- v-for="(color, idx) in popularColors"- :key="idx"- :class="{ _active: color === category.color }"- :style="{ background: color === category.color ? color : 'transparent' }"- @click="onSelectColor(color)"- )- template(v-if="color")- template(v-if="findCategoryWithThisColor(color)")- Icon(- :icon="findCategoryWithThisColor(color)"- :color="color === category.color ? null : color"- big- )- template(v-else-if="color === category.color")- Icon(- :icon="category.icon"- background="transparent"- big- )- template(v-else)- .colorPreview(:style="{ background: color }")-- .subTitle {{ $t('palette') }}- .colors- .iconItem(- v-for="(color, idx) in allColors"- :key="idx"- :class="{ _active: color === category.color, _empty: !color }"- :style="{ background: color === category.color ? color : 'transparent' }"- @click="onSelectColor(color)"- )-- template(v-if="color")- template(v-if="findCategoryWithThisColor(color)")- Icon(- :icon="findCategoryWithThisColor(color)"- :color="color === category.color ? null : color"- big- )- template(v-else-if="color === category.color")- Icon(- :icon="category.icon"- background="transparent"- big- )- template(v-else)- .colorPreview(:style="{ background: color }")-- .subTitle {{ $t('categories.form.colors.custom') }}- .customColor- input.customColor__value(v-model="category.color" type="color")-- //- Icons- //---------------------------------- template(v-if="activeTab === 'icons'")- .form- .icons- .icons__group(- v-for="iconGroup in icons"- )- .iconItem(- v-for="icon in iconGroup"- :class="{ _active: category.icon === icon }"- :style="{ color: category.color }"- @click="handleIconSelect(icon)"- )- div(:class="icon")-- //- Submit- .pt-4.pb-6- SharedButton(- :class="['_text-center _blue2 _ml-big', { _inline: $store.state.ui.pc }]"- :title="$t('categories.form.save')"- @onClick="handleSubmit()"- )-- //-- //- Parent Modal- //-- Portal(to="modal")- LazyBaseBottomSheet(- v-if="showParents"- @closed="showParents = false"- )- template(#handler="{ close }")- BaseBottomSheetClose(@onClick="close")-- template()- .content(:style="{ maxHeight: documentHeight }")- .scrollerBlock- .wrap- //- Header- .header {{ $t('categories.form.parent.label') }}-- .padding-bottom- ModalButton(- :name="$t('categories.form.parent.no')"- icon="mdi mdi-folder-star"- @onClick="() => handleParenCategorySelect(0)")-- CategoriesList(- :activeItemId="category.parentId"- :ids="$store.getters['categories/categoriesForBeParent'].filter(cId => cId !== categoryId)"- @onClick="handleParenCategorySelect"- )+ UiHeaderTitle+ .pb-1.text-xs.font-medium.text-skin-item-base-down+ | {{ $t('categories.title') }}+ template(v-if="parentCategory")+ |+ | • {{ parentCategory.name }}++ .flex.items-center.gap-4+ | {{ categoryForm.name }}+ .w-8.h-8.rounded-full.flex-center.text-xl.text-skin-icon-base(:style="{ background: categoryForm.color }")+ div(:class="categoryForm.icon")++ template(#actions)+ CategoriesDelete(:categoryId="categoryId")++ CategoriesForm(+ :categoryId="categoryId"+ :categoryForm="categoryForm"+ @updateValue="updateValue"+ @afterSave="afterSave"+ )</template>--<style lang="stylus" scoped>-.subTitle- padding 0 $m5- padding-bottom $m6- color var(--c-font-4)- font-size 13px- font-weight 500--.categoryParentItem- overflow hidden- cursor pointer- position relative- display flex- flex-flow row nowrap- align-items center- justify-content center- min-height 48px- padding $m6- color var(--c-font-1)- background var(--c-item-bg-main)- border 1px solid transparent- border-radius $m5- anim()- +media-hover()- color var(--c-text-1)- background var(--c-item-bg-hover)- border 1px solid var(--c-item-bd-hover)- /.light &- color var(--c-font-2)--.menu- overflow hidden- z-index 10- display flex- align-items center- justify-content space-between- max-width 480px- overflow-x auto- margin 0 auto- padding $m5 $m6-- +media(600px)- overflow initial--.menuItem- cursor pointer- display flex- align-items center- justify-content center- min-height 38px- min-width 70px- margin 0 $m5- padding $m6 $m7- color var(--c-font-4)- font-size 12px- font-weight 500- font-roboto()- text-align center- border-radius $m6- anim()-- +media(400px)- min-width 80px- margin 0 $m5- padding-right $m7- padding-left $m7-- +media(600px)- padding-right $m9- padding-left $m9-- +media-hover()- &:not(._active)- cursor pointer- color var(--c-font-3)- background var(--c-item2-bg-hover)-- &._active- cursor default- color var(--c-blue-1)- background var(--c-item-bg-active)--.wrap- padding 0 $m8- padding-top $m6--.form- .inputText- margin-bottom 0- padding-bottom $m8-- h2- padding-bottom $m6--.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--.icons- &__group- display grid- grid-template-columns repeat(auto-fill, minmax(40px, 1fr))- padding-bottom $m8--.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--.padding-bottom- padding-bottom $m8--.content- overflow hidden- display grid- padding-top $m7- background var(--c-bg-3)- border-radius $m8 $m8 0 0-- +media(600px)- border-radius 16px--.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 $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--.inputModal- &._flex- flex 1- display flex- align-items center- justify-content space-between-- &__content- display flex-- &__label- margin 0- padding 0- font-size 10px-</style>--<style lang="stylus">-@import '~assets/stylus/variables'-</style>diff --git a/components/categories/page/id/Index.vue b/components/categories/page/id/Index.vueindex 05218737..d912438c 100644--- a/components/categories/page/id/Index.vue+++ b/components/categories/page/id/Index.vue@@ -26,7 +26,7 @@ const categoryChildIds = computed(() => category.value.childIds?.sort((a, b) =>const trnsIds = computed(() =>getTrnsIds({- categoriesIds: category.value?.childIds ? category.value?.childIds : [categoryId.value],+ categoriesIds: category.value?.childIds?.length > 0 ? category.value?.childIds : [categoryId.value],trnType: filter.trnType,trnsItems: trnsItems.value,}))@@ -43,70 +43,61 @@ function handleEditClick() {</script><template lang="pug">-.h-full.overflow.overflow-x-auto.max-w-3xl.h-full(- class="pb-[44px] md_pb-[52px] lg_pb-0"-)- template(v-if="category")- router-link(- v-slot='{ href, navigate }'- :to='backLink'- 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")+UiPage(v-if="category")+ UiHeader+ router-link(v-slot="{ href, navigate }" :to="backLink" custom)+ a.grow.hocus_bg-skin-item-main-hover(:href="href" @click="navigate")+ UiHeaderTitle+ .pb-1.text-xs.font-medium.text-skin-item-base-down| {{ $t('categories.title') }}template(v-if="category.parentId")|| • {{ $store.state.categories.items[category.parentId].name }}- .flex.items-center.gap-3- .text-neutral-800.dark_text-white.text-2xl.leading-none.font-semibold {{ category.name }}- .w-8.h-8.rounded-full.flex-center.text-xl.text-neutral-50(- :style="{ background: category.color }"- )+ .flex.items-center.gap-4+ | {{ category.name }}+ .w-8.h-8.rounded-full.flex-center.text-xl.text-skin-icon-base(:style="{ background: category.color }")div(:class="category.icon")- .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"- )-- //- Open stat- .pb-12- .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="handleSetFilterCategory"- )- .mdi.mdi-poll.text-xl- .text-xs.leading-none {{ $t('statBy') }} {{ category.name }}- .mdi.mdi-chevron-right.opacity-70.text-lg.leading-none-- //- Childs categories- .pb-12(v-if="category.childIds && category.childIds.length > 0")- .statTitle.flex.gap-2.px-3(class="!pb-3")- div {{ $t('categories.title') }}:- div {{ category.childIds.length }}-- .px-3- CategoriesList(- :ids="categoryChildIds"- :slider="() => ({})"- isHideParentCategory- @onClick="id => $router.push(`/categories/${id}`)"- )-- //- History+ template(#actions v-if="categoryId !== 'transfer'")+ UiHeaderLink(@click="handleEditClick")+ .mdi.mdi-pencil-outline.group-hover_text-white.text-xl+ UiHeaderLink(@click="$router.push('/categories/new')")+ UiIconAdd.group-hover_text-white.w-6.h-6++ //- Open stat+ .pb-12+ .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="handleSetFilterCategory"+ )+ .mdi.mdi-poll.text-xl+ .text-xs.leading-none {{ $t('statBy') }} {{ category.name }}+ .mdi.mdi-chevron-right.opacity-70.text-lg.leading-none++ //- Childs categories+ .pb-12(v-if="category.childIds && category.childIds.length > 0")+ .statTitle.flex.gap-2.px-3(class="!pb-3")+ div {{ $t('categories.title') }}:+ div {{ category.childIds.length }}+.px-3- TrnsHistory(- :trnsIds="trnsIds"- :trnType="filter.trnType"- hideTransfers- @setFilterTrnType="value => filter.trnType = value"+ CategoriesList(+ :ids="categoryChildIds"+ :slider="() => ({})"+ isHideParentCategory+ @onClick="id => $router.push(`/categories/${id}`)")++ //- History+ .px-3+ TrnsHistory(+ :trnsIds="trnsIds"+ :trnType="filter.trnType"+ hideTransfers+ @setFilterTrnType="value => filter.trnType = value"+ )</template><i18n lang="json5">@@ -114,6 +105,7 @@ function handleEditClick() {"en": {"statBy": "Statistics: ",},+"ru": {"statBy": "Статистика: ",},diff --git a/components/currencies/currencies.js b/components/currencies/currencies.tssimilarity index 98%rename from components/currencies/currencies.jsrename to components/currencies/currencies.tsindex 2dcfcdcc..acb5764a 100644--- a/components/currencies/currencies.js+++ b/components/currencies/currencies.ts@@ -1,5 +1,9 @@+import type { Currency } from '~/components/currencies/types'-export const currencies = [{+export const currencies: {+ code: Currency+ name: string+}[] = [{code: 'BTC',name: 'Bitcoin',}, {diff --git a/components/currencies/types.ts b/components/currencies/types.tsnew file mode 100644index 00000000..622314e3--- /dev/null+++ b/components/currencies/types.ts@@ -0,0 +1 @@+export type Currency = stringdiff --git a/components/layout/Modals.vue b/components/layout/Modals.vueindex 574d6708..baa5b529 100644--- a/components/layout/Modals.vue+++ b/components/layout/Modals.vue@@ -30,14 +30,11 @@ export default defineComponent({//- CurrenciesCurrenciesModal- //- category: create or edit- LazyCategoriesEditModal(v-if="activeTab === 'createCategory'")-- //- loading+ //- Loadingtemplate(v-if="!$store.state.app.status.ready")LoaderSharedLoader- //- notifications+ //- NotificationsNotifications(:max="2":position="$store.state.ui.width < 600 ? 'top center' : 'top center'"diff --git a/components/stat/Date.vue b/components/stat/Date.vueindex 7191c0f2..94066df2 100644--- a/components/stat/Date.vue+++ b/components/stat/Date.vue@@ -5,10 +5,10 @@ const isShowDateSelector = ref(false)<template lang="pug">.z-10.hocus_bg-gray-100.dark_hocus_bg-neutral-800//- Date- .menuDots.cursor-pointer.flex.items-center.text-lg(+ .menuDots.cursor-pointer.px-3.flex.items-center.text-lg(@click="isShowDateSelector = true")- .py-6.px-3.font-nunito.text-neutral-800.dark_text-white.text-2xl.leading-none.font-semibold+ .py-6.font-nunito.text-neutral-800.dark_text-white.text-2xl.leading-none.font-semiboldSharedDate.menuDots__dots: .mdi.mdi-dots-verticaldiff --git a/components/stat/Index.vue b/components/stat/Index.vueindex 3752d406..7c6003f4 100644--- a/components/stat/Index.vue+++ b/components/stat/Index.vue@@ -3,7 +3,8 @@ import useStat from '~/modules/stat/useStat'import useStatChart from '~/components/stat/useStatChart'import useStatPage from '~/components/stat/useStatPage'import useUIView from '~/components/layout/useUIView'-import { getTrnsIds } from '~/components/trns/functions/getTrns'+import useWallets from '~/components/wallets/useWallets'+const { walletsCurrencies } = useWallets()const { $store } = useNuxtApp()const { statPage } = useStatPage()@@ -36,13 +37,27 @@ const isShowGroupTrns = computed(() => {const p2 = statPage.average.total === 0return (p1 || p2) && statPage.activeTab !== 'history'})++const isShowCurrensiesList = ref(false)</script><template lang="pug">.overflow-y-auto.h-full.pb-8.js_scroll_page.max-w-4xl.pb-6StatPeriodArrows- StatDate++ .pr-3.flex.items-center.justify-between.gap-4+ StatDate.grow+ .cursor-pointer.py-2.px-4.text-sm.text-skin-item-base-down.rounded-md.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(+ v-if="walletsCurrencies.length > 1"+ :class="{ 'bg-skin-item-main-active': isShowCurrensiesList }"+ @click="isShowCurrensiesList = !isShowCurrensiesList"+ )+ | {{ $store.state.currencies.base }}++ .pb-4.px-3(v-if="isShowCurrensiesList")+ WalletsCurrenciesChanger+LazyStatChart(v-if="ui.showMainChart && statPage.isHasTrns").pb-3.lg_flexStatViewConfig.lg_order-2.lg_ml-auto@@ -51,7 +66,7 @@ const isShowGroupTrns = computed(() => {.py-6.px-3(v-if="statPage.filter.isShow")LazyStatFilter- .py-3.px-3+ .py-3.pb-8.px-3StatMenu.py-3.pb-3.px-3(v-if="statPage.activeTab === 'details'")diff --git a/components/stat/Menu.vue b/components/stat/Menu.vueindex 45bf94aa..655c0b38 100644--- a/components/stat/Menu.vue+++ b/components/stat/Menu.vue@@ -1,49 +1,37 @@-<script>-export default {- name: 'StatDashboardMenu',+<script setup lang="ts">+const { $store } = useNuxtApp()+const activeTabStat = computed(() => $store.state.ui.activeTabStat)- setup() {- const { $store } = useNuxtApp()- const activeTabStat = computed(() => $store.state.ui.activeTabStat)-- function onClickStatMenu(tabName) {- $store.dispatch('ui/setActiveTabStat', tabName)- }-- return {- activeTabStat,- onClickStatMenu,- }- },+function onClickStatMenu(tabName) {+ $store.dispatch('ui/setActiveTabStat', tabName)}</script><template lang="pug">-.overflow-hidden.rounded-md.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-4.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': activeTabStat === 'details' }"- @click="onClickStatMenu('details')"- ) {{ $t('stat.periods') }}-- .cursor-pointer.px-4.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': activeTabStat === 'expenses' }"- @click="onClickStatMenu('expenses')"- ) {{ $t('money.expenses') }}-- .cursor-pointer.px-4.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': activeTabStat === 'incomes' }"- @click="onClickStatMenu('incomes')"- ) {{ $t('money.incomes') }}-- .cursor-pointer.px-4.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': activeTabStat === 'trns' }"- @click="onClickStatMenu('trns')"- ) {{ $t('trns.shortTitle') }}-- .cursor-pointer.px-4.py-3.grow.flex-center.hocus_bg-gray-200.dark_hocus_bg-neutral-800(- @click="$router.push('history')"- )- span {{ $t('trns.history') }}- span.mdi.mdi-open-in-new.ml-1+UiTabs+ UiTabsItem(+ :isActive="activeTabStat === 'details'"+ @click="onClickStatMenu('details')"+ ) {{ $t('stat.periods') }}++ UiTabsItem(+ :isActive="activeTabStat === 'expenses'"+ @click="onClickStatMenu('expenses')"+ ) {{ $t('money.expenses') }}++ UiTabsItem(+ :isActive="activeTabStat === 'incomes'"+ @click="onClickStatMenu('incomes')"+ ) {{ $t('money.incomes') }}++ UiTabsItem(+ :isActive="activeTabStat === 'trns'"+ @click="onClickStatMenu('trns')"+ ) {{ $t('trns.shortTitle') }}++ UiTabsItem(+ @click="$router.push('history')"+ )+ span {{ $t('trns.history') }}+ span.mdi.mdi-open-in-new.ml-1</template>diff --git a/components/trnForm/SelectedWallet.vue b/components/trnForm/SelectedWallet.vueindex ab68824f..15f7d176 100644--- a/components/trnForm/SelectedWallet.vue+++ b/components/trnForm/SelectedWallet.vue@@ -15,26 +15,25 @@ const wallet = computed(() => walletsItemsSorted.value[props.walletId])v-if="wallet"@click="emit('click')")- .grow- .flex-center.gap-x-3- //- Icon- .w-6.h-6.rounded-md.flex-center.text-skin-icon-base.text-xs.leading-none(- :style="{ background: wallet.color }"- class="mt-[2px]"- ) {{ wallet.name.substring(0, 2) }}+ .grow.flex-center.gap-x-3+ //- Icon+ .w-6.h-6.rounded-md.flex-center.text-skin-icon-base.text-xs.leading-none(+ :style="{ background: wallet.color }"+ class="mt-[2px]"+ ) {{ wallet.name.substring(0, 2) }}- .grow- //- Name- .grow.text-sm.text-skin-item-base {{ wallet.name }}+ .grow+ //- Name+ .text-sm.text-skin-item-base {{ wallet.name }}- //- Amount- Amount(- :currency="wallet.currency"- :value="wallet.amount"- :showBase="false"- alwaysShowSymbol- vertical="left"- )+ //- Amount+ Amount(+ :currency="wallet.currency"+ :value="wallet.amount"+ :showBase="false"+ alwaysShowSymbol+ vertical="left"+ ).mdi.mdi-dots-vertical.-mr-1.text-lg.text-skin-item-base-down</template>diff --git a/components/trnForm/TrnForm.vue b/components/trnForm/TrnForm.vueindex 02387e9b..e1892df1 100644--- a/components/trnForm/TrnForm.vue+++ b/components/trnForm/TrnForm.vue@@ -246,7 +246,7 @@ function handleSubmitForm() {.cursor-pointer.relative.flex.items-center.py-2.px-3.rounded-md.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(v-for="(walletItem, walletId) in walletsItemsLimited":key="walletId"- :class="[{ 'cursor-default bg-skin-item-main-active': $store.state.trnForm.values.walletId === walletId }]"+ :class="[{ 'cursor-default !bg-skin-item-main-active': $store.state.trnForm.values.walletId === walletId }]"@click="onClickWallet(walletId)").grow.flex-center.gap-x-3@@ -255,17 +255,19 @@ function handleSubmitForm() {:style="{ background: walletItem.color }"class="mt-[2px]") {{ walletItem.name.substring(0, 2) }}- //- Name- .grow.text-sm.text-skin-item-base {{ walletItem.name }}-- //- Amount- Amount(- :currency="walletItem.currency"- :showBase="false"- :value="walletItem.amount"- alwaysShowSymbol- vertical="right"- )++ .grow+ //- Name+ .text-sm.text-skin-item-base {{ walletItem.name }}++ //- Amount+ Amount(+ :currency="walletItem.currency"+ :value="walletItem.amount"+ :showBase="false"+ alwaysShowSymbol+ vertical="left"+ )//- Favorite categories.pb-7(v-if="$store.getters['categories/quickSelectorCategoriesIds'] && $store.getters['categories/quickSelectorCategoriesIds'].length > 0")diff --git a/components/trns/Modal.vue b/components/trns/Modal.vueindex 866682d5..8b485308 100644--- a/components/trns/Modal.vue+++ b/components/trns/Modal.vue@@ -152,7 +152,7 @@ Portal(template(#icon)Icon(:icon="category.icon"- :background="category.color || $store.state.ui.defaultBgColor"+ :background="category.color"round)diff --git a/components/ui/Header.vue b/components/ui/Header.vuenew file mode 100644index 00000000..6a8b9d8b--- /dev/null+++ b/components/ui/Header.vue@@ -0,0 +1,11 @@+<script setup lang="ts">++</script>++<template lang="pug">+.flex+ slot++ .flex.gap-3.py-4.pr-3+ slot(name="actions")+</template>diff --git a/components/ui/HeaderLink.vue b/components/ui/HeaderLink.vuenew file mode 100644index 00000000..c5666d2e--- /dev/null+++ b/components/ui/HeaderLink.vue@@ -0,0 +1,6 @@+<template lang="pug">+.cursor-pointer.group.w-10.h-10.flex-center.rounded-full.bg-gray-50.dark_bg-dark5.hocus-text-white.hocus_bg-skin-accent-base(+ @click="$emit('click')"+)+ slot+</template>diff --git a/components/ui/HeaderTitle.vue b/components/ui/HeaderTitle.vuenew file mode 100644index 00000000..fe95d10b--- /dev/null+++ b/components/ui/HeaderTitle.vue@@ -0,0 +1,8 @@+<script setup lang="ts">++</script>++<template lang="pug">+.grow.py-6.px-3.font-nunito.text-neutral-800.dark_text-white.text-2xl.leading-none.font-semibold+ slot+</template>diff --git a/components/ui/Page.vue b/components/ui/Page.vuenew file mode 100644index 00000000..cbe14711--- /dev/null+++ b/components/ui/Page.vue@@ -0,0 +1,10 @@+<template lang="pug">+.overflow-x-hidden.overflow-y-auto.flex.flex-col.justify-between.w-full.h-full(+ class="md_pb-[52px] pb-[44px] lg_pb-0"+)+ .max-w-3xl+ slot++ .max-w-3xl+ slot(name="bottom")+</template>diff --git a/components/ui/Tabs.vue b/components/ui/Tabs.vuenew file mode 100644index 00000000..041b08d6--- /dev/null+++ b/components/ui/Tabs.vue@@ -0,0 +1,5 @@+<template lang="pug">+.overflow-hidden.rounded-md.bg-skin-item-main-bg.dark_shadow+ .overflow-hidden.overflow-x-auto.flex.items-center.text-sm.text-center.max-w-lg+ slot+</template>diff --git a/components/ui/TabsItem.vue b/components/ui/TabsItem.vuenew file mode 100644index 00000000..f6c6232d--- /dev/null+++ b/components/ui/TabsItem.vue@@ -0,0 +1,15 @@+<script setup lang="ts">+defineProps<{+ isActive?: boolean+}>()++const emit = defineEmits(['click'])+</script>++<template lang="pug">+.cursor-pointer.px-5.py-3.grow.whitespace-nowrap.hocus_bg-skin-item-main-hover(+ :class="{ 'cursor-default text-skin-accent-base !bg-gray-300 dark_!bg-232323': isActive }"+ @click="emit('click')"+)+ slot+</template>diff --git a/components/ui/icon/Add.vue b/components/ui/icon/Add.vuenew file mode 100644index 00000000..175bbccb--- /dev/null+++ b/components/ui/icon/Add.vue@@ -0,0 +1,14 @@+<script setup lang="ts">++</script>++<template lang="pug">+svg(+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 12 12"+)+ path(+ fill="currentColor"+ d="M6 1.5a.5.5 0 0 0-1 0V5H1.5a.5.5 0 0 0 0 1H5v3.5a.5.5 0 0 0 1 0V6h3.5a.5.5 0 0 0 0-1H6V1.5Z"+ )+</template>diff --git a/components/ui/icon/Sort.vue b/components/ui/icon/Sort.vuenew file mode 100644index 00000000..856ea52f--- /dev/null+++ b/components/ui/icon/Sort.vue@@ -0,0 +1,10 @@+<template lang="pug">+svg(+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 24 24"+)+ path(+ fill="currentColor"+ d="M7 20h2V8h3L8 4L4 8h3zm13-4h-3V4h-2v12h-3l4 4z"+ )+</template>diff --git a/components/wallets/CurrenciesChanger.vue b/components/wallets/CurrenciesChanger.vuenew file mode 100644index 00000000..3a527e23--- /dev/null+++ b/components/wallets/CurrenciesChanger.vue@@ -0,0 +1,38 @@+<script setup lang="ts">+import useWallets from '~/components/wallets/useWallets'+const { walletsCurrencies } = useWallets()+const { $store } = useNuxtApp()++function onSelect(value) {+ $store.dispatch('currencies/changeBaseCurrency', value)+}+</script>++<template lang="pug">+UiTabs(v-if="walletsCurrencies.length > 1")+ UiTabsItem(+ v-for="currency in walletsCurrencies"+ :key="currency"+ :isActive="currency === $store.state.currencies.base"+ @click="onSelect(currency)"+ ) {{ currency }}++ UiTabsItem(+ @click="$store.commit('currencies/showBaseCurrenciesModal')"+ )+ .flex-center+ span {{ $t('more') }}+ span.mdi.mdi-dots-vertical.ml-1+</template>++<i18n lang="json5">+{+ "en": {+ "more": "More"+ },++ "ru": {+ "more": "Еще"+ },+}+</i18n>diff --git a/components/wallets/Delete.vue b/components/wallets/Delete.vueindex fdda1db0..8ef37ca9 100644--- a/components/wallets/Delete.vue+++ b/components/wallets/Delete.vue@@ -28,6 +28,10 @@ const deleteDescText = computed(() => {return null})+function onClickDelete() {+ isShowDeleteConfirm.value = true+}+// TODO: translateasync function onDeleteConfirm() {// Disable reactive to have data when user have already redirected to wallets page@@ -54,9 +58,8 @@ async function onDeleteConfirm() {<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"- )+ UiHeaderLink(@click="onClickDelete")+ .mdi.mdi-delete-empty-outline.group-hover_text-white.text-xlModalBottomConfirm(:show="isShowDeleteConfirm"diff --git a/components/wallets/Form.vue b/components/wallets/Form.vueindex 32d6ba9e..585b5599 100644--- a/components/wallets/Form.vue+++ b/components/wallets/Form.vue@@ -1,53 +1,109 @@<script setup lang="ts">-import { allColors, popularColors } from '~/assets/js/colorsPopular'+import { allColors } from '~/assets/js/colors'+import generateId from '~/utils/id'+import type { WalletForm, WalletID } from '~/components/wallets/types'const props = defineProps<{- walletForm: {- name: string- color: string- currency: string- }+ walletId?: WalletID+ walletForm: WalletForm}>()-const { walletForm } = toRefs(props)-const emit = defineEmits(['updateValue', 'onSave'])+const { walletId, walletForm } = toRefs(props)+const emit = defineEmits(['updateValue', 'afterSave'])++const { $store, $notify, nuxt2Context: { i18n } } = useNuxtApp()+const editWalletId = walletId.value ?? generateId()-const { $store } = useNuxtApp()const activeTab = ref('data')-// function findWalletWithThisColor(color) {-// const walletsItems = $store.state.wallets.items-// if (!walletsItems)-// return false+/**+ * Validate+ */+function validate({ values, wallets }) {+ // name+ if (!values.name) {+ $notify({+ title: '😮',+ text: i18n.t('wallets.form.name.error'),+ })+ return false+ }++ // currency+ if (!values.currency) {+ $notify({+ title: '😮',+ text: i18n.t('wallets.form.currency.error'),+ })+ return false+ }++ for (const id in wallets) {+ if (wallets[id].name === values.name) {+ if (editWalletId) {+ if (editWalletId !== id) {+ $notify({+ title: '😮',+ text: i18n.t('wallets.form.name.exist'),+ })+ return false+ }+ }+ else {+ $notify({+ title: '😮',+ text: i18n.t('wallets.form.name.exist'),+ })+ return false+ }+ }+ }++ return true+}++function prepareForm({ values }) {+ return {+ color: values.color,+ countTotal: values.countTotal,+ currency: values.currency,+ isCredit: values.isCredit,+ name: values.name,+ order: values.order,+ }+}++function onSave() {+ const wallets = $store.state.wallets.items-// const walletIdWithThisColor = Object.keys(walletsItems)?.find(id => walletsItems[id]?.color === color)-// if (!walletIdWithThisColor)-// return false+ const isFormValid = validate({ values: walletForm.value, wallets })+ if (!isFormValid)+ return-// return true-// }+ const walletsValues = prepareForm({ values: walletForm.value })+ $store.dispatch('wallets/addWallet', { id: editWalletId, values: walletsValues })++ emit('afterSave')+}</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') }}+div(v-if="walletForm")+ .pb-8.px-3+ UiTabs+ UiTabsItem(+ :isActive="activeTab === 'data'"+ @click="activeTab = 'data'"+ ) {{ $t('categories.form.data.label') }}++ UiTabsItem(+ :isActive="activeTab === 'currencies'"+ @click="activeTab = 'currencies'"+ ) {{ $t('wallets.form.currencies.label') }}++ UiTabsItem(+ :isActive="activeTab === 'colors'"+ @click="activeTab = 'colors'"+ ) {{ $t('wallets.form.colors.label') }}//- Content//-----------------------------------@@ -89,19 +145,6 @@ div//- 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"@@ -121,7 +164,7 @@ divSharedButton(:class="['_text-center _blue2 _ml-big', { _inline: $store.state.ui.pc }]":title="$t('wallets.form.save')"- @onClick="emit('onSave')"+ @onClick="onSave")</template>diff --git a/components/wallets/FormWelcome.vue b/components/wallets/FormWelcome.vuedeleted file mode 100644index 7f70b40f..00000000--- a/components/wallets/FormWelcome.vue+++ /dev/null@@ -1,114 +0,0 @@-<script setup lang="ts">-import { popularColors } from '~/assets/js/colorsPopular'-import { random } from '~/assets/js/emo'-import generateId from '~/utils/id'--const props = defineProps<{- saved: Function-}>()--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/page/List.vue b/components/wallets/page/List.vueindex 5c7b0538..36287c2a 100644--- a/components/wallets/page/List.vue+++ b/components/wallets/page/List.vue@@ -1,6 +1,9 @@<script setup lang="ts">+import useWallets from '~/components/wallets/useWallets'+const { $store } = useNuxtApp()const activeTab = computed(() => $store.state.ui.activeTab)+const { walletsCurrencies } = useWallets()</script><script lang="ts">@@ -14,81 +17,67 @@ export default defineComponent({</script><template lang="pug">-.overflow-y-auto.h-full.grid.max-w-3xl(- class="grid-rows-[1fr_auto] md_pb-[52px] pb-[44px] lg_pb-0"-)- div- //- Header- //---------------------------------- .flex- //- Title- .grow.py-6.px-3.font-nunito.text-neutral-800.dark_text-white.text-2xl.leading-none.font-semibold- | {{ $t('wallets.name') }}+UiPage+ UiHeader+ UiHeaderTitle {{ $t('wallets.name') }}+ template(#actions)+ UiHeaderLink(@click="$store.dispatch('ui/setActiveTab', 'walletsSort')")+ UiIconSort.w-6.h-6.group-hover_text-white- //- Actions- .flex-center.gap-3.pr-3- //- Sort- .cursor-pointer.group.w-10.h-10.flex-center.rounded-full.bg-gray-50.dark_bg-dark5.hocus-text-white.hocus_bg-blue2(- @click="$store.dispatch('ui/setActiveTab', 'walletsSort')"- )- svg.group-hover_text-white.w-6.h-6(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24")- path(fill="currentColor" d="M7 20h2V8h3L8 4L4 8h3zm13-4h-3V4h-2v12h-3l4 4z")+ UiHeaderLink(@click="$router.push('/wallets/new')")+ UiIconAdd.w-6.h-6.group-hover_text-white- //- Add- .cursor-pointer.group.w-10.h-10.flex-center.rounded-full.bg-gray-50.dark_bg-dark5.hocus-text-white.hocus_bg-blue2(- @click="$router.push('/wallets/new')"- )- svg.group-hover_text-white.w-6.h-6(xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12")- path(fill="currentColor" d="M6 1.5a.5.5 0 0 0-1 0V5H1.5a.5.5 0 0 0 0 1H5v3.5a.5.5 0 0 0 1 0V6h3.5a.5.5 0 0 0 0-1H6V1.5Z")+ .pb-6.px-3(v-if="walletsCurrencies.length > 1")+ WalletsCurrenciesChanger- .pb-12.px-3- //- Total- WalletsTotalAlt(- isShowCredits- isShowSavings- )+ .pb-12.px-3+ WalletsTotalAlt(+ isShowCredits+ isShowSavings+ )- //- List- //---------------------------------- WalletsList(#default="{ walletsItemsSorted }")- .pb-12.px-3.grid.gap-y-1.gap-x-6.md_grid-cols-2- //- Wallet- .cursor-pointer.flex.items-center.py-2.px-3.rounded-md.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(- v-for="(walletItem, walletId) in walletsItemsSorted"- :key="walletId"- @click="$router.push(`/wallets/${walletId}`)"- )- .grow.gap-x-3.flex.items-center- .grow.flex-center.gap-x-3- //- Icon- .w-6.h-6.rounded-md.flex-center.text-skin-icon-base.text-xs.leading-none(- :style="{ background: walletItem.color }"- class="mt-[2px]"- ) {{ walletItem.name.substring(0, 2) }}- //- Name- .grow.text-sm.text-skin-item-base {{ walletItem.name }}+ //- List+ //---------------------------------+ WalletsList(#default="{ walletsItemsSorted }")+ .pb-12.px-3.grid.gap-y-1.gap-x-6.md_grid-cols-2+ //- Wallet+ .cursor-pointer.flex.items-center.py-2.px-3.rounded-md.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(+ v-for="(walletItem, walletId) in walletsItemsSorted"+ :key="walletId"+ @click="$router.push(`/wallets/${walletId}`)"+ )+ .grow.gap-x-3.flex.items-center+ .grow.flex-center.gap-x-3+ //- Icon+ .w-6.h-6.rounded-md.flex-center.text-skin-icon-base.text-xs.leading-none(+ :style="{ background: walletItem.color }"+ class="mt-[2px]"+ ) {{ walletItem.name.substring(0, 2) }}+ //- Name+ .grow.text-sm.text-skin-item-base {{ walletItem.name }}- //- Amount- Amount(- :currency="walletItem.currency"- :value="walletItem.amount"- alwaysShowSymbol- showBase- vertical="right"- )+ //- Amount+ Amount(+ :currency="walletItem.currency"+ :value="walletItem.amount"+ alwaysShowSymbol+ showBase+ vertical="right"+ )- .pb-4.px-3.flex.justify-evenly.gap-6- //- Sort- .cursor-pointer.grow.py-3.px-5.flex-center.rounded-full.text-sm.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(- class="basis-1/2 max-w-[280px]"- @click="$store.dispatch('ui/setActiveTab', 'walletsSort')"- ) {{ $t('base.sort') }}+ template(#bottom)+ .pb-4.px-3.flex.justify-evenly.gap-6+ //- Sort+ .cursor-pointer.grow.py-3.px-5.flex-center.rounded-full.text-sm.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(+ class="basis-1/2 max-w-[280px]"+ @click="$store.dispatch('ui/setActiveTab', 'walletsSort')"+ ) {{ $t('base.sort') }}- //- Create- .cursor-pointer.grow.py-3.px-5.flex-center.rounded-full.text-sm.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(- class="basis-1/2 max-w-[280px]"- @click="$router.push('/wallets/new')"- ) {{ $t('wallets.new') }}+ //- Create+ .cursor-pointer.grow.py-3.px-5.flex-center.rounded-full.text-sm.bg-skin-item-main-bg.hocus_bg-skin-item-main-hover(+ class="basis-1/2 max-w-[280px]"+ @click="$router.push('/wallets/new')"+ ) {{ $t('wallets.new') }}//- Sort//-----------------------------------diff --git a/components/wallets/page/New.vue b/components/wallets/page/New.vueindex 72526373..319245db 100644--- a/components/wallets/page/New.vue+++ b/components/wallets/page/New.vue@@ -1,15 +1,12 @@<script setup lang="ts">-import { popularColors } from '~/assets/js/colorsPopular'+import { allColors } from '~/assets/js/colors'import { random } from '~/assets/js/emo'-import generateId from '~/utils/id'+import type { WalletForm } from '~/components/wallets/types'-const { $store, $notify, nuxt2Context: { i18n } } = useNuxtApp()const router = useRouter()-const walletId = computed(() => generateId())--const walletForm = ref({- color: random(popularColors),+const walletForm = ref<WalletForm>({+ color: random(random(allColors)),countTotal: true,currency: 'USD',isCredit: false,@@ -21,60 +18,7 @@ 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 })+function afterSave() {router.push('/wallets/')}</script>@@ -83,29 +27,30 @@ function onSave() {export default defineComponent({head() {return {- title: `${this.$t('base.edit')}: ${this.wallet?.name}`,+ title: `${this.$t('base.add')}: ${this.walletForm.name ? this.walletForm.name : this.$t('wallets.form.name.label')}`,}},})</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 }}+UiPage+ UiHeader+ router-link(v-slot="{ href, navigate }" to="/wallets" custom)+ a.grow.hocus_bg-skin-item-main-hover(:href="href" @click="navigate")+ UiHeaderTitle+ .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"+ @afterSave="afterSave"@updateValue="updateValue")</template>diff --git a/components/wallets/page/id/Edit.vue b/components/wallets/page/id/Edit.vueindex 87122524..e1c7b019 100644--- a/components/wallets/page/id/Edit.vue+++ b/components/wallets/page/id/Edit.vue@@ -1,16 +1,17 @@<script setup lang="ts">-import { popularColors } from '~/assets/js/colorsPopular'+import { allColors } from '~/assets/js/colors'import { random } from '~/assets/js/emo'+import type { WalletForm } from '~/components/wallets/types'-const { $store, $notify, nuxt2Context: { i18n } } = useNuxtApp()+const { $store } = useNuxtApp()const route = useRoute()const router = useRouter()const walletId = computed(() => route.params.id)const wallet = computed(() => $store.state.wallets.items[walletId.value])-const walletForm = ref({- color: wallet.value?.color || random(popularColors),+const walletForm = ref<WalletForm>({+ color: wallet.value?.color || random(allColors),countTotal: wallet.value?.countTotal || true,currency: wallet.value?.currency || 'RUB',isCredit: wallet.value?.isCredit || false,@@ -22,60 +23,7 @@ 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 })+function afterSave() {router.push(`/wallets/${walletId.value}`)}</script>@@ -84,41 +32,34 @@ function onSave() {export default defineComponent({head() {return {- title: `${this.$t('base.edit')}: ${this.wallet?.name}`,+ title: `${this.$t('base.edit')}: ${this.walletForm.name ? this.walletForm.name : this.$t('wallets.form.name.label')}`,}},})</script><template lang="pug">-.overflow.overflow-x-auto.h-full.max-w-3xl(- v-if="wallet"- class="pb-[44px] md_pb-[52px] lg_pb-0"-)- .flex.items-start- router-link(- v-slot="{ href, navigate }"- custom- :to="`/wallets/${walletId}`"- )- 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.text-skin-item-base-down- | {{ $t("wallets.editTitle") }}-- .flex.items-center.gap-3- .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 }}-- WalletsDelete(:walletId="walletId")+UiPage(v-if="wallet")+ UiHeader+ router-link(v-slot="{ href, navigate }" :to="`/wallets/${walletId}`" custom)+ a.grow.hocus_bg-skin-item-main-hover(:href="href" @click="navigate")+ UiHeaderTitle+ .pb-1.text-xs.font-medium.text-skin-item-base-down+ | {{ $t("wallets.editTitle") }}++ .flex.items-center.gap-3+ .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 }}++ template(#actions)+ WalletsDelete(:walletId="walletId")WalletsForm(+ :walletId="walletId":walletForm="walletForm"- @onSave="onSave"+ @afterSave="afterSave"@updateValue="updateValue")</template>diff --git a/components/wallets/page/id/Index.vue b/components/wallets/page/id/Index.vueindex 7318ba6b..f0395c1a 100644--- a/components/wallets/page/id/Index.vue+++ b/components/wallets/page/id/Index.vue@@ -52,41 +52,32 @@ export default defineComponent({</script><template lang="pug">-.overflow.overflow-x-auto.h-full.max-w-3xl(- v-if="wallet"- class="pb-[44px] md_pb-[52px] lg_pb-0"-)- 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"- )+UiPage(v-if="wallet")+ UiHeader+ router-link(v-slot="{ href, navigate }" to="/wallets" custom)+ a.grow.hocus_bg-skin-item-main-hover(:href="href" @click="navigate")+ UiHeaderTitle+ .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"+ )++ template(#actions)+ UiHeaderLink(@click="handleEditClick")+ .mdi.mdi-pencil-outline.group-hover_text-white.text-xl.pb-6.px-3.flexdiff --git a/components/wallets/types.ts b/components/wallets/types.tsindex cc5471c3..58c8f9ec 100644--- a/components/wallets/types.ts+++ b/components/wallets/types.ts@@ -9,3 +9,12 @@ export interface WalletItem {export interface WalletItemWithAmount extends WalletItem {amount: number}++export interface WalletForm {+ color: string+ countTotal: boolean+ currency: string+ isCredit: boolean+ name: string+ order: number+}diff --git a/components/wallets/useWallets.ts b/components/wallets/useWallets.tsindex ecfb48b2..041824de 100644--- a/components/wallets/useWallets.ts+++ b/components/wallets/useWallets.ts@@ -1,5 +1,6 @@import type { ComputedRef } from '@vue/composition-api'import type { WalletID, WalletItemWithAmount } from '~/components/wallets/types'+import type { Currency } from '~/components/currencies/types'export default function useWallets() {const { $store } = useNuxtApp()@@ -14,7 +15,7 @@ export default function useWallets() {* Wallets items sorted**/- const walletsItemsSorted: ComputedRef<Record<WalletID, WalletItemWithAmount>> = computed(() => {+ const walletsItemsSorted = computed<Record<WalletID, WalletItemWithAmount>>(() => {const walletsIdsSorted: WalletID[] = $store.getters['wallets/walletsSortedIds']let wallets: Record<WalletID, WalletItemWithAmount> = {}@@ -31,8 +32,24 @@ export default function useWallets() {return wallets})+ /**+ * Wallets currencies+ */+ const walletsCurrencies = computed(() => {+ const currencies: Currency[] = []++ for (const walletId in walletsItemsSorted.value) {+ const walletCurrency = walletsItemsSorted.value[walletId].currency+ if (!currencies.includes(walletCurrency))+ currencies.push(walletCurrency)+ }++ return currencies+ })+return {walletsIdsSorted,walletsItemsSorted,+ walletsCurrencies,}}diff --git a/components/welcome/CategoryForm.vue b/components/welcome/CategoryForm.vuenew file mode 100644index 00000000..7235f9c6--- /dev/null+++ b/components/welcome/CategoryForm.vue@@ -0,0 +1,68 @@+<script setup lang="ts">+import { allColors } from '~/assets/js/colors'+import { random } from '~/assets/js/emo'+import icons from '~/assets/js/icons'++const { $store } = useNuxtApp()+const emit = defineEmits(['afterSave'])++const categoryForm = ref({+ color: random(random(allColors)),+ icon: random(random(icons)),+ name: null,+ order: 1,+ parentId: 0,+ showInLastUsed: true,+ showInQuickSelector: false,+ showStat: true,+})++const parentCategory = computed(() => {+ if (categoryForm.value.parentId === 0)+ return false++ return $store.state.categories.items[categoryForm.value.parentId]+})++function updateValue(id, value) {+ categoryForm.value[id] = value+}++function afterSave() {+ emit('afterSave')+}+</script>++<script lang="ts">+export default defineComponent({+ head() {+ return {+ title: `${this.$t('base.add')}: ${this.categoryForm.name ? this.categoryForm.name : this.$t('categories.form.name.label')}`,+ }+ },+})+</script>++<template lang="pug">+UiPage+ UiHeader+ router-link(v-slot="{ href, navigate }" to="/categories" custom)+ a.grow.hocus_bg-skin-item-main-hover(:href="href" @click="navigate")+ UiHeaderTitle+ .pb-1.text-xs.font-medium.text-skin-item-base-down+ | {{ $t('categories.createNewTitle') }}+ template(v-if="parentCategory")+ |+ | in {{ parentCategory.name }}++ .flex.items-center.gap-4+ | {{ categoryForm.name ? categoryForm.name : $t("categories.form.name.label") }}+ .w-8.h-8.rounded-full.flex-center.text-xl.text-skin-icon-base(:style="{ background: categoryForm.color }")+ div(:class="categoryForm.icon")+ .pb-12+ CategoriesForm(+ :categoryForm="categoryForm"+ @updateValue="updateValue"+ @afterSave="afterSave"+ )+</template>diff --git a/components/welcome/WalletForm.vue b/components/welcome/WalletForm.vuenew file mode 100644index 00000000..543978bb--- /dev/null+++ b/components/welcome/WalletForm.vue@@ -0,0 +1,54 @@+<script setup lang="ts">+import { allColors } from '~/assets/js/colors'+import { random } from '~/assets/js/emo'+import type { WalletForm } from '~/components/wallets/types'++const emit = defineEmits(['afterSave'])++const walletForm = ref<WalletForm>({+ color: random(random(allColors)),+ countTotal: true,+ currency: 'USD',+ isCredit: false,+ name: null,+ order: 1,+})++function updateValue(id, value) {+ walletForm.value[id] = value+}++function afterSave() {+ emit('afterSave')+}+</script>++<script lang="ts">+export default defineComponent({+ head() {+ return {+ title: `${this.$t('base.add')}: ${this.wallet?.name}`,+ }+ },+})+</script>++<template lang="pug">+UiPage+ .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 }}++ .pb-12+ WalletsForm(+ :walletForm="walletForm"+ @afterSave="afterSave"+ @updateValue="updateValue"+ )+</template>diff --git a/components/welcome/page/Welcome.vue b/components/welcome/page/Welcome.vuenew file mode 100644index 00000000..0ba43f16--- /dev/null+++ b/components/welcome/page/Welcome.vue@@ -0,0 +1,329 @@+<script lang="ts">+export default {+ data() {+ return {+ step: 1,+ showCategoryForm: false,+ showWalletForm: false,+ }+ },++ computed: {+ newUserData() {+ if (!this.$store.getters['wallets/hasWallets'] || !this.$store.getters['categories/hasCategories'])+ return true++ return false+ },+ },++ watch: {+ newUserData(newUserData) {+ if (!newUserData)+ this.$router.push('/')+ },+ },++ mounted() {+ if (!this.newUserData)+ this.$router.push('/')++ if (!this.$store.state.user.user)+ this.$store.dispatch('user/signOut')+ },++ methods: {+ changeLang(lang) {+ this.$store.dispatch('lang/setLang', lang)+ },+ },+}+</script>++<template lang="pug">+.tabs(v-if="newUserData && $store.state.user.user")+ //- welcome+ transition(name="fadeIn")+ template(v-if="step === 1")+ .tab+ .tab__content+ .header+ .header__title {{ $t('app.welcome') }}+ .header__desc {{ $t('app.desc') }}+ .header__user(@click="$store.dispatch('user/signOut')") {{ $t('userLogout') }} {{ $store.state.user.user.email }}++ .options+ .options__item+ .options__desc {{ $t('app.lang.select') }}+ .themeSelector+ .themeSelector__item(+ :class="{ _active: $store.state.lang.lang === 'ru' }"+ @click="changeLang('ru')"+ ) {{ $t('app.lang.ru') }}++ .themeSelector__item(+ :class="{ _active: $store.state.lang.lang === 'en' }"+ @click="changeLang('en')"+ ) {{ $t('app.lang.en') }}+ .options__desc {{ $t('app.theme.select') }}++ .themeSelector+ .themeSelector__item._dark(+ :class="{ _active: $colorMode.value === 'dark' }"+ @click="$store.dispatch('ui/changeTheme', 'dark')"+ )+ .themeSelector__icon+ template(v-if="$colorMode.value === 'dark'")+ .mdi.mdi-lightbulb-on+ template(v-else)+ .mdi.mdi-lightbulb-outline+ .themeSelector__title {{ $t('app.theme.dark') }}++ .themeSelector__item._light(+ :class="{ _active: $colorMode.value === 'light' }"+ @click="$store.dispatch('ui/changeTheme', 'light')"+ )+ .themeSelector__icon+ template(v-if="$colorMode.value === 'light'")+ .mdi.mdi-lightbulb-on+ template(v-else)+ .mdi.mdi-lightbulb-outline+ .themeSelector__title {{ $t('app.theme.light') }}++ SharedButton._blue2._center(+ :title="$t('buttons.nextStep')"+ @onClick="step = 2"+ )++ //-+ transition(name="fadeIn")+ template(v-if="step === 2")+ .tab+ .tab__content+ .header+ .header__title+ template(v-if="step === 1") {{ $t('app.welcome') }}+ template(v-else) {{ $t('appName') }}++ .header__desc(v-if="step === 1") {{ $t('app.desc') }}+ .header__user(+ v-if="step === 1"+ @click="$store.dispatch('user/signOut')"+ ) {{ $t('userLogout') }} {{ $store.state.user.user.email }}++ .options+ .options__item+ .options__desc {{ $t('welcome.create.text') }}+ SharedButton._blue2._center(+ :title="$t('welcome.create.btn')"+ @onClick="step = 3"+ )++ //- Wallet+ transition(name="fadeIn")+ template(v-if="(step !== 1 && step !== 2) && !showWalletForm && !$store.getters['wallets/hasWallets']")+ .tab+ .tab__content+ .tab__wrap+ .header+ .header__title {{ $t('appName') }}+ .options__desc {{ $t('welcome.createFirstWallet.text') }}+ SharedButton._center._blue2(+ :title="$t('welcome.createFirstWallet.btn')"+ @onClick="showWalletForm = true"+ )++ //- Wallet form+ transition(name="fadeIn")+ .h-full.mx-auto.md_max-w-xl(v-if="showWalletForm")+ WelcomeWalletForm(+ @afterSave="showWalletForm = false"+ )++ //- Category+ transition(name="fadeIn")+ template(v-if="(step !== 1 && step !== 2) && !showWalletForm && !showCategoryForm && $store.getters['wallets/hasWallets'] && !$store.getters['categories/hasCategories']")+ .tab+ .tab__content+ .icon: .mdi.mdi-folder-star+ .options__desc {{ $t('welcome.createFirstCategory.text') }}+ SharedButton._blue2._center(+ :title="$t('welcome.createFirstCategory.btn')"+ @onClick="showCategoryForm = true"+ )++ //- Category form+ transition(name="fadeIn")+ .h-full.mx-auto.md_max-w-xl(v-if="showCategoryForm")+ WelcomeCategoryForm(+ v-if="showCategoryForm"+ @afterSave="showCategoryForm = false"+ )++ .firefoxBackdropFix.z-10.w-full.fixed.left-0.bottom-0.backdrop-blur(+ class="bg-skin-layout-main/70"+ )+ SharedCopyright+</template>++<style lang="stylus" scoped>+.firefoxBackdropFix+ @supports (not (-webkit-backdrop-filter: none)) and (not (backdrop-filter: none))+ background theme('colors.dark3') !important+ /.light &+ background theme('colors.white') !important++.steps+ display flex+ width 100%+ padding-bottom $m10+ border-radius $m4++.stepItem+ flex-grow 1+ padding $m6+ text-align center+ background var(--c-bg-2)++ &._active+ background var(--c-bg-5)+ border-radius $m4++.tabs+ overflow hidden+ position absolute+ width 100%+ height 100%++.tab+ position absolute+ top 0+ left 0+ display grid+ width 100%+ height 100%+ padding-bottom $m10+ overflow-x hidden+ overflow-y scroll+ scrollbar()++ &__content+ width 100%+ flex-grow 1+ display flex+ flex-flow column+ flex-grow 1+ padding $m9+ padding-bottom 100px+ align-self center+ justify-self center++ +media(600px)+ width 550px++ .component+ padding 0++.header+ padding-bottom $mb1++ &__title+ padding-bottom $m8+ font-size 28px+ font-weight 500+ letter-spacing 1px+ text-align center++ &__desc+ padding-bottom $m5+ color var(--c-font-4)+ font-size 12px+ text-align center++ @media $media-laptop+ font-size 14px++ &__user+ cursor pointer+ padding-top $m9+ font-size 12px+ text-align center++ @media $media-laptop+ padding-top $m9+ font-size 14px++.options+ &__or+ position relative+ display flex+ align-items center+ justify-content center+ padding $m9 0+ color var(--c-font-4)+ text-align center+ &__text+ position relative+ padding $m7++ &__border+ position absolute+ top 50%+ left 0+ width 100%+ height 1px+ background var(--c-bg-6)++ &__desc+ padding-bottom $m7+ color var(--c-font-4)+ line-height 20px+ text-align center++.text+ padding-bottom $m8+ line-height 20px+ @media $media-laptop+ padding-bottom $m9++.icon+ padding-bottom $m5+ color var(--c-font-4)+ font-size 96px+ text-align center+ @media $media-laptop+ padding-bottom $m7++.themeSelector+ position relative+ display grid+ grid-template-columns 1fr 1fr+ grid-column-gap 40px+ padding-bottom $m10++ &__item+ flex-grow 1+ cursor pointer+ padding 16px 16px+ text-align center+ border 1px solid rgba(63, 63, 63, 1)+ border-radius 8px++ &._dark+ border-color rgba(63, 63, 63, 1)++ &._light+ border-color rgba(190, 190, 190, 1)++ &._active+ border 1px solid var(--c-blue-3)++ &__icon+ opacity .5+ padding-bottom 20px+ font-size 32px++ .themeSelector__item._active &+ opacity 1+ color var(--c-blue-3)+</style>diff --git a/layouts/default.vue b/layouts/default.vueindex 01c0ef46..8a173eca 100644--- a/layouts/default.vue+++ b/layouts/default.vue@@ -71,7 +71,7 @@ onMounted(() => {.h-full.grid(class="lg_grid-cols-[auto_1fr]")- .hidden.overflow-hidden.h-full.lg_block+ .hidden.overflow-hidden.h-full.w-72.lg_blockLayoutSidebar.overflow-hidden.h-full.grid.lg_px-8diff --git a/layouts/welcome.vue b/layouts/welcome.vueindex 555c51f1..5d1fb92d 100644--- a/layouts/welcome.vue+++ b/layouts/welcome.vue@@ -53,7 +53,7 @@ onMounted(() => {</script><template lang="pug">-.font-roboto.text-gray-500.leading-none.antialiased.overflow-hidden.relative.h-full.min-w-base.flex(+.font-roboto.text-gray-500.leading-none.antialiased.overflow-hidden.relative.h-full.min-w-base.flex.bg-skin-layout-main(:class="[touchClassNames, 'dark_text-gray-400']")LayoutModalsdiff --git a/locales/en-US.js b/locales/en-US.jsindex 2a96b51f..5826d643 100644--- a/locales/en-US.js+++ b/locales/en-US.js@@ -91,6 +91,7 @@ export default {on: 'On',ok: 'Ok',off: 'Off',+ add: 'Create',edit: 'Edit',delete: 'Delete',filter: 'Filter',@@ -177,7 +178,7 @@ export default {allTitle: 'All',lastUsedTitle: 'Recent',favoriteTitle: 'Favorite',- createNewTitle: 'Create new category',+ createNewTitle: 'Create category',editTitle: 'Edit category',form: {name: {@@ -187,16 +188,15 @@ export default {exist: 'Category with same name is exist',},parent: {- no: 'No parent',+ no: 'Root category',label: 'Parent category',- placeholder: 'Select parent category',},colors: {label: 'Colors',custom: 'Custom color',},- icons: {- label: 'Icons',+ icon: {+ label: 'Icon',},data: {label: 'Data',@@ -323,6 +323,4 @@ export default {},colors: 'Colors',- palette: 'Palette',- popularColors: 'Popular colors',}diff --git a/locales/ru-RU.js b/locales/ru-RU.jsindex 08d52bcf..bf2287b4 100644--- a/locales/ru-RU.js+++ b/locales/ru-RU.js@@ -93,6 +93,7 @@ export default {dublicate: 'Дублировать',setFilter: 'Фильтр',off: 'Нет',+ add: 'Создать',edit: 'Редактировать',delete: 'Удалить',filter: 'Фильтровать',@@ -191,14 +192,13 @@ export default {parent: {no: 'Корневая категория',label: 'Категория',- placeholder: 'Выберите категрию',},colors: {label: 'Цвета',custom: 'Кастомный цвет',},- icons: {- label: 'Иконки',+ icon: {+ label: 'Иконка',},data: {label: 'Данные',@@ -325,6 +325,4 @@ export default {},colors: 'Цвета',- palette: 'Палитра',- popularColors: 'Популярные',}diff --git a/package-lock.json b/package-lock.jsonindex a2a2b778..0f1fa01d 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "finapp",- "version": "3.5.3",+ "version": "3.6.2","lockfileVersion": 2,"requires": true,"packages": {"": {"name": "finapp",- "version": "3.5.3",+ "version": "3.6.2","dependencies": {"@nuxtjs/i18n": "^7.2.0","@simonwep/pickr": "1.8.2",diff --git a/package.json b/package.jsonindex 3a1c8c04..b8aa2df8 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "finapp",- "version": "3.6.1",+ "version": "3.6.2","scripts": {"dev": "cross-env NUXT_HOST=0.0.0.0 PORT=3010 nuxi dev","build": "nuxi generate",diff --git a/pages/categories/new.vue b/pages/categories/new.vuenew file mode 100644index 00000000..580fc873--- /dev/null+++ b/pages/categories/new.vue@@ -0,0 +1,3 @@+<template lang="pug">+CategoriesPageNew+</template>diff --git a/pages/dev/ref-sugar.vue b/pages/dev/ref-sugar.vuedeleted file mode 100644index d8273c18..00000000--- a/pages/dev/ref-sugar.vue+++ /dev/null@@ -1,17 +0,0 @@-<script setup lang="ts">-console.log(111)-const h = ref('ref 1')--const h2 = $ref('ref 2')--console.log('h', h.value)-console.log('h2', h2)--const hey = (param: string): void => {- console.log('sss', param)-}-</script>--<template lang="pug">-h1(@click="hey('ii')") hello {{ h }}-</template>diff --git a/pages/settings.vue b/pages/settings.vueindex 2a86fbfe..447d43f3 100644--- a/pages/settings.vue+++ b/pages/settings.vue@@ -1,4 +1,5 @@<script>+// TODO: move code to componentsimport pkg from '~/package'export default {@@ -29,9 +30,7 @@ export default {</script><template lang="pug">-.overflow-y-auto.h-full.max-w-3xl(- class="md_pb-[52px] pb-[44px] lg_pb-0"-)+UiPage.mb-6.py-6.px-3.text-skin-item-base-up.text-2xl.leading-none.font-nunito.font-semibold| {{ $t('settings.title') }}diff --git a/pages/welcome.vue b/pages/welcome.vueindex 852f99a9..6a28572f 100644--- a/pages/welcome.vue+++ b/pages/welcome.vue@@ -1,333 +1,9 @@-<script>+<script lang="ts">export default {layout: 'welcome',-- data() {- return {- step: 1,- showCategoryForm: false,- showWalletForm: false,- }- },-- computed: {- newUserData() {- if (!this.$store.getters['wallets/hasWallets'] || !this.$store.getters['categories/hasCategories'])- return true-- return false- },- },-- watch: {- newUserData(newUserData) {- if (!newUserData)- this.$router.push('/')- },- },-- mounted() {- if (!this.newUserData)- this.$router.push('/')-- if (!this.$store.state.user.user)- this.$store.dispatch('user/signOut')- },-- methods: {- categoryCreatedCallback() {- this.showCategoryForm = false- },-- changeLang(lang) {- this.$store.dispatch('lang/setLang', lang)- },- },}</script><template lang="pug">-.tabs(v-if="newUserData && $store.state.user.user")-- //- welcome- transition(name="fadeIn")- template(v-if="step === 1")- .tab- .tab__content- .header- .header__title {{ $t('app.welcome') }}- .header__desc {{ $t('app.desc') }}- .header__user(@click="$store.dispatch('user/signOut')") {{ $t('userLogout') }} {{ $store.state.user.user.email }}-- .options- .options__item- .options__desc {{ $t('app.lang.select') }}- .themeSelector- .themeSelector__item(- :class="{ _active: $store.state.lang.lang === 'ru' }"- @click="changeLang('ru')"- ) {{ $t('app.lang.ru') }}-- .themeSelector__item(- :class="{ _active: $store.state.lang.lang === 'en' }"- @click="changeLang('en')"- ) {{ $t('app.lang.en') }}- .options__desc {{ $t('app.theme.select') }}-- .themeSelector- .themeSelector__item._dark(- :class="{ _active: $colorMode.value === 'dark' }"- @click="$store.dispatch('ui/changeTheme', 'dark')"- )- .themeSelector__icon- template(v-if="$colorMode.value === 'dark'")- .mdi.mdi-lightbulb-on- template(v-else)- .mdi.mdi-lightbulb-outline- .themeSelector__title {{ $t('app.theme.dark') }}-- .themeSelector__item._light(- :class="{ _active: $colorMode.value === 'light' }"- @click="$store.dispatch('ui/changeTheme', 'light')"- )- .themeSelector__icon- template(v-if="$colorMode.value === 'light'")- .mdi.mdi-lightbulb-on- template(v-else)- .mdi.mdi-lightbulb-outline- .themeSelector__title {{ $t('app.theme.light') }}-- SharedButton._blue2._center(- :title="$t('buttons.nextStep')"- @onClick="step = 2"- )-- //-- transition(name="fadeIn")- template(v-if="step === 2")- .tab- .tab__content- .header- .header__title- template(v-if="step === 1") {{ $t('app.welcome') }}- template(v-else) {{ $t('appName') }}-- .header__desc(v-if="step === 1") {{ $t('app.desc') }}- .header__user(- v-if="step === 1"- @click="$store.dispatch('user/signOut')"- ) {{ $t('userLogout') }} {{ $store.state.user.user.email }}-- .options- .options__item- .options__desc {{ $t('welcome.create.text') }}- SharedButton._blue2._center(- :title="$t('welcome.create.btn')"- @onClick="step = 3"- )-- //- Wallet- transition(name="fadeIn")- template(v-if="(step !== 1 && step !== 2) && !showWalletForm && !$store.getters['wallets/hasWallets']")- .tab- .tab__content- .tab__wrap- .header- .header__title {{ $t('appName') }}- .options__desc {{ $t('welcome.createFirstWallet.text') }}- SharedButton._center._blue2(- :title="$t('welcome.createFirstWallet.btn')"- @onClick="showWalletForm = true"- )-- //- Wallet form- transition(name="fadeIn")- WalletsFormWelcome(- v-if="showWalletForm"- :saved="() => showWalletForm = false"- )-- //- Category- transition(name="fadeIn")- template(v-if="(step !== 1 && step !== 2) && !showWalletForm && !showCategoryForm && $store.getters['wallets/hasWallets'] && !$store.getters['categories/hasCategories']")- .tab- .tab__content- .icon: .mdi.mdi-folder-star- .options__desc {{ $t('welcome.createFirstCategory.text') }}- SharedButton._blue2._center(- :title="$t('welcome.createFirstCategory.btn')"- @onClick="showCategoryForm = true")-- transition(name="fadeIn")- .tab(v-if="showCategoryForm")- .tab__content- LazyCategoriesForm(@callback="categoryCreatedCallback")-- .firefoxBackdropFix.z-10.w-full.fixed.left-0.bottom-0.backdrop-blur(- class="bg-white/70 dark_bg-dark3/70"- )- SharedCopyright+Welcome</template>--<style lang="stylus" scoped>-.firefoxBackdropFix- @supports (not (-webkit-backdrop-filter: none)) and (not (backdrop-filter: none))- background theme('colors.dark3') !important- /.light &- background theme('colors.white') !important--.steps- display flex- width 100%- padding-bottom $m10- border-radius $m4--.stepItem- flex-grow 1- padding $m6- text-align center- background var(--c-bg-2)-- &._active- background var(--c-bg-5)- border-radius $m4--.tabs- overflow hidden- position absolute- width 100%- height 100%--.tab- position absolute- top 0- left 0- display grid- width 100%- height 100%- padding-bottom $m10- overflow-x hidden- overflow-y scroll- scrollbar()-- &__content- width 100%- flex-grow 1- display flex- flex-flow column- flex-grow 1- padding $m9- padding-bottom 100px- align-self center- justify-self center-- +media(600px)- width 550px-- .component- padding 0--.header- padding-bottom $mb1-- &__title- padding-bottom $m8- font-size 28px- font-weight 500- letter-spacing 1px- text-align center-- &__desc- padding-bottom $m5- color var(--c-font-4)- font-size 12px- text-align center-- @media $media-laptop- font-size 14px-- &__user- cursor pointer- padding-top $m9- font-size 12px- text-align center-- @media $media-laptop- padding-top $m9- font-size 14px--.options- &__or- position relative- display flex- align-items center- justify-content center- padding $m9 0- color var(--c-font-4)- text-align center- &__text- position relative- padding $m7- background var(--c-bg-3)-- &__border- position absolute- top 50%- left 0- width 100%- height 1px- background var(--c-bg-6)-- &__desc- padding-bottom $m7- color var(--c-font-4)- line-height 20px- text-align center--.text- padding-bottom $m8- line-height 20px- @media $media-laptop- padding-bottom $m9--.icon- padding-bottom $m5- color var(--c-font-4)- font-size 96px- text-align center- @media $media-laptop- padding-bottom $m7--.themeSelector- position relative- display grid- grid-template-columns 1fr 1fr- grid-column-gap 40px- padding-bottom $m10-- &__item- flex-grow 1- cursor pointer- padding 16px 16px- text-align center- border 1px solid rgba(63, 63, 63, 1)- border-radius 8px-- &._dark- border-color rgba(63, 63, 63, 1)-- &._light- border-color rgba(190, 190, 190, 1)-- &._active- border 1px solid var(--c-blue-3)-- &__icon- opacity .5- padding-bottom 20px- font-size 32px-- .themeSelector__item._active &- opacity 1- color var(--c-blue-3)-</style>diff --git a/services/firebase/api.js b/services/firebase/api.jsindex 9e9e3cb6..75594af4 100644--- a/services/firebase/api.js+++ b/services/firebase/api.js@@ -33,6 +33,6 @@ export const updateData = (path, updates) => update(ref(db, path), updates)export const removeData = path => remove(ref(db, path))-export const saveData = (path, value) => set(ref(db, path), value)+export const saveData = async(path, value) => await set(ref(db, path), value)export const unsubcribeData = path => off(ref(db, path))diff --git a/store/categories/index.js b/store/categories/index.jsindex 6b697cce..3b60a661 100644--- a/store/categories/index.js+++ b/store/categories/index.js@@ -1,4 +1,3 @@export const state = () => ({items: {},- editId: null,})diff --git a/store/categories/mutations.js b/store/categories/mutations.jsindex 0b631d96..8323f39f 100644--- a/store/categories/mutations.js+++ b/store/categories/mutations.js@@ -20,10 +20,4 @@ export default {},}},-- setCategoryEditId(state, id) {- state.editId === id- ? state.editId = null- : state.editId = id- },}diff --git a/store/currencies/actions.ts b/store/currencies/actions.tsindex 981802d6..a45a22bd 100644--- a/store/currencies/actions.ts+++ b/store/currencies/actions.ts@@ -38,6 +38,22 @@ export default {})},+ async changeBaseCurrency({ commit }, baseCurrency) {+ // Rates with date+ const today = dayjs().startOf('day').valueOf()+ const ratesBasedOnUsd = await getDataOnce(`ratesUsd/history/${today}`)++ // Convert rates based on USD to user base currency+ const ratesConvertedToBase = {}+ for (const id in ratesBasedOnUsd)+ ratesConvertedToBase[id] = ratesBasedOnUsd[id] / ratesBasedOnUsd[baseCurrency]++ commit('setCurrencies', {+ base: baseCurrency,+ rates: ratesConvertedToBase,+ })+ },+setBaseCurrency({ rootState, dispatch }, baseCurrency) {const uid = rootState.user.user.uidsaveData(`users/${uid}/settings/baseCurrency`, baseCurrency)diff --git a/store/ui/index.js b/store/ui/index.jsindex 06dfd0c8..762a94e0 100644--- a/store/ui/index.js+++ b/store/ui/index.js@@ -6,6 +6,4 @@ export const state = () => ({height: 0,mobile: false,pc: false,-- defaultBgColor: '#455a64',})diff --git a/store/wallets/mutations.js b/store/wallets/mutations.jsindex 547cb7f0..09eb3158 100644--- a/store/wallets/mutations.js+++ b/store/wallets/mutations.js@@ -7,10 +7,4 @@ export default {}state.items = freezedItems},-- setWalletEditId(state, id) {- state.editId === id- ? state.editId = null- : state.editId = id- },}diff --git a/tailwind.config.js b/tailwind.config.jsindex 5aaeefd9..167702f4 100644--- a/tailwind.config.js+++ b/tailwind.config.js@@ -16,7 +16,6 @@ module.exports = {colors: {232323: '#232323',blue1: '#58a6ff',- blue2: '#0366d6',blue3: '#3a7dff',blue4: '#2183f2',custom1: '#212121',diff --git a/tsconfig.json b/tsconfig.jsonindex 20366410..1359af13 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -8,8 +8,10 @@},"compilerOptions": {"types": [+ "@nuxt/types",+ "@nuxtjs/i18n",+ "unplugin-vue2-script-setup/ref-macros","unplugin-vue2-script-setup/types",- "unplugin-vue2-script-setup/ref-macros"]- }+ },}