use primary color & icon as default when creating secondary category

This commit is contained in:
MaysWind
2025-04-06 22:38:49 +08:00
parent f97cca6dcc
commit 68b08c1e8a
5 changed files with 55 additions and 7 deletions
+9
View File
@@ -155,6 +155,7 @@ import { useCategoryEditPageBase } from '@/views/base/categories/CategoryEditPag
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
import type { ColorValue } from '@/core/color.ts';
import { CategoryType } from '@/core/category.ts';
import { ALL_CATEGORY_ICONS } from '@/consts/icon.ts';
import { ALL_CATEGORY_COLORS } from '@/consts/color.ts';
@@ -230,6 +231,14 @@ function init(): void {
return;
}
if (query['color']) {
category.value.color = query['color'] as ColorValue;
}
if (query['icon']) {
category.value.icon = query['icon'];
}
clientSessionId.value = generateRandomUUID();
loading.value = false;
}
+3 -3
View File
@@ -5,7 +5,7 @@
<f7-nav-title :title="tt(title)"></f7-nav-title>
<f7-nav-right class="navbar-compact-icons">
<f7-link icon-f7="ellipsis" :class="{ 'disabled': !categories.length }" v-if="!sortable" @click="showMoreActionSheet = true"></f7-link>
<f7-link :href="'/category/add?type=' + categoryType + '&parentId=' + primaryCategoryId" icon-f7="plus" v-if="!sortable"></f7-link>
<f7-link :href="'/category/add?type=' + categoryType + '&parentId=' + primaryCategoryId + (currentPrimaryCategory ? `&color=${currentPrimaryCategory.color}&icon=${currentPrimaryCategory.icon}` : '')" icon-f7="plus" v-if="!sortable"></f7-link>
<f7-link :text="tt('Done')" :class="{ 'disabled': displayOrderSaving }" @click="saveSortResult" v-else-if="sortable"></f7-link>
</f7-nav-right>
</f7-navbar>
@@ -92,6 +92,7 @@ import type { Router } from 'framework7/types';
import { useI18n } from '@/locales/helpers.ts';
import { useI18nUIComponents, showLoading, hideLoading, onSwipeoutDeleted } from '@/lib/ui/mobile.ts';
import { useCategoryListPageBase } from '@/views/base/categories/CategoryListPageBase.ts';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
@@ -111,13 +112,12 @@ const props = defineProps<{
const { tt } = useI18n();
const { showAlert, showToast, routeBackOnError } = useI18nUIComponents();
const { loading, primaryCategoryId, currentPrimaryCategory } = useCategoryListPageBase();
const transactionCategoriesStore = useTransactionCategoriesStore();
const hasSubCategories = ref<boolean>(false);
const categoryType = ref<CategoryType | 0>(0);
const primaryCategoryId = ref<string>('0');
const loading = ref<boolean>(true);
const loadingError = ref<unknown | null>(null);
const showHidden = ref<boolean>(false);
const sortable = ref<boolean>(false);