mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 07:57:33 +08:00
support configuring the data source of the data table in insights explorer
This commit is contained in:
@@ -103,7 +103,7 @@
|
||||
</template>
|
||||
<v-list-item :prepend-icon="mdiExport"
|
||||
:title="tt('Export Results')"
|
||||
:disabled="loading || updating || !filteredTransactions || filteredTransactions.length < 1"
|
||||
:disabled="loading || updating || (activeTab === 'table' && (!filteredTransactionsInDataTable || filteredTransactionsInDataTable.length < 1))"
|
||||
@click="exportResults"
|
||||
v-if="activeTab === 'table' || activeTab === 'chart'"></v-list-item>
|
||||
<v-divider class="my-2" v-if="currentExplorer.id" />
|
||||
@@ -309,7 +309,7 @@ const allExplorers = computed<InsightsExplorerBasicInfo[]>(() => {
|
||||
});
|
||||
const currentFilter = computed<TransactionExplorerFilter>(() => explorersStore.transactionExplorerFilter);
|
||||
const currentExplorer = computed<InsightsExplorer>(() => explorersStore.currentInsightsExplorer);
|
||||
const filteredTransactions = computed<TransactionInsightDataItem[]>(() => explorersStore.filteredTransactions);
|
||||
const filteredTransactionsInDataTable = computed<TransactionInsightDataItem[]>(() => explorersStore.filteredTransactionsInDataTable);
|
||||
|
||||
const allDateRanges = computed<LocalizedDateRange[]>(() => getAllDateRanges(DateRangeScene.InsightsExplorer, true));
|
||||
const allTimezoneTypesUsedForDateRange = computed<TypeAndDisplayName[]>(() => getAllTimezoneTypesUsedForStatistics());
|
||||
@@ -539,7 +539,7 @@ function removeExplorer(): void {
|
||||
}
|
||||
|
||||
function exportResults(): void {
|
||||
if (activeTab.value === 'table' && filteredTransactions.value) {
|
||||
if (activeTab.value === 'table' && filteredTransactionsInDataTable.value) {
|
||||
const results = explorerDataTableTab.value?.buildExportResults();
|
||||
|
||||
if (results) {
|
||||
|
||||
@@ -3,6 +3,17 @@
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
<div class="d-flex overflow-x-auto align-center gap-2 pt-2">
|
||||
<v-select
|
||||
class="flex-0-0"
|
||||
min-width="150"
|
||||
item-title="name"
|
||||
item-value="value"
|
||||
density="compact"
|
||||
:disabled="loading || disabled"
|
||||
:label="tt('Data Source')"
|
||||
:items="allDataTableQuerySources"
|
||||
v-model="currentExplorer.datatableQuerySource"
|
||||
/>
|
||||
<v-select
|
||||
class="flex-0-0"
|
||||
min-width="150"
|
||||
@@ -117,7 +128,7 @@ import { useSettingsStore } from '@/stores/setting.ts';
|
||||
import { useUserStore } from '@/stores/user.ts';
|
||||
import { useExplorersStore } from '@/stores/explorer.ts';
|
||||
|
||||
import type { NameNumeralValue } from '@/core/base.ts';
|
||||
import { type NameValue, type NameNumeralValue, itemAndIndex } from '@/core/base.ts';
|
||||
import type { NumeralSystem } from '@/core/numeral.ts';
|
||||
import { TransactionType } from '@/core/transaction.ts';
|
||||
|
||||
@@ -169,7 +180,32 @@ const defaultCurrency = computed<string>(() => userStore.currentUserDefaultCurre
|
||||
|
||||
const currentExplorer = computed<InsightsExplorer>(() => explorersStore.currentInsightsExplorer);
|
||||
|
||||
const filteredTransactions = computed<TransactionInsightDataItem[]>(() => explorersStore.filteredTransactions);
|
||||
const filteredTransactions = computed<TransactionInsightDataItem[]>(() => explorersStore.filteredTransactionsInDataTable);
|
||||
|
||||
const allDataTableQuerySources = computed<NameValue[]>(() => {
|
||||
const sources: NameValue[] = [];
|
||||
|
||||
sources.push({
|
||||
name: tt('All Queries'),
|
||||
value: ''
|
||||
});
|
||||
|
||||
for (const [query, index] of itemAndIndex(currentExplorer.value.queries)) {
|
||||
if (query.name) {
|
||||
sources.push({
|
||||
name: query.name,
|
||||
value: query.id
|
||||
});
|
||||
} else {
|
||||
sources.push({
|
||||
name: tt('format.misc.queryIndex', { index: index + 1 }),
|
||||
value: query.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return sources;
|
||||
});
|
||||
|
||||
const allPageCounts = computed<NameNumeralValue[]>(() => {
|
||||
const pageCounts: NameNumeralValue[] = [];
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
</v-switch>
|
||||
<v-btn class="ms-2" density="compact" color="default" variant="text" size="small"
|
||||
:icon="true" :disabled="loading || disabled || !!editingQuery || queries.length < 1 || (queries.length === 1 && (!element.conditions || element.conditions.length < 1))"
|
||||
@click="removeQuery(index)">
|
||||
@click="removeQuery(element, index)">
|
||||
<v-icon :icon="mdiClose" size="18" />
|
||||
<v-tooltip activator="parent">{{ tt('Remove Query') }}</v-tooltip>
|
||||
</v-btn>
|
||||
@@ -388,7 +388,7 @@ import { useTransactionCategoriesStore } from '@/stores/transactionCategory.ts';
|
||||
import { useTransactionTagsStore } from '@/stores/transactionTag.ts';
|
||||
import { useExplorersStore } from '@/stores/explorer.ts';
|
||||
|
||||
import { type NameValue, entries, values } from '@/core/base.ts';
|
||||
import { type NameValue, values } from '@/core/base.ts';
|
||||
import { AccountType } from '@/core/account.ts';
|
||||
import { TransactionType } from '@/core/transaction.ts';
|
||||
import {
|
||||
@@ -576,25 +576,15 @@ function duplicateQuery(query: TransactionExplorerQuery): void {
|
||||
queries.value.push(query.clone(generateRandomUUID()));
|
||||
}
|
||||
|
||||
function removeQuery(queryIndex: number): void {
|
||||
function removeQuery(query: TransactionExplorerQuery, queryIndex: number): void {
|
||||
if (queries.value.length > 0) {
|
||||
queries.value.splice(queryIndex, 1);
|
||||
}
|
||||
|
||||
const newShowExpression: Record<number, boolean> = {};
|
||||
|
||||
for (const [key, state] of entries(showExpression.value)) {
|
||||
const index = parseInt(key);
|
||||
|
||||
if (queryIndex > index) {
|
||||
newShowExpression[index] = state;
|
||||
} else if (queryIndex < index) {
|
||||
newShowExpression[index - 1] = state;
|
||||
}
|
||||
if (explorersStore.currentInsightsExplorer.datatableQuerySource === query.id) {
|
||||
explorersStore.currentInsightsExplorer.datatableQuerySource = '';
|
||||
}
|
||||
|
||||
showExpression.value = newShowExpression;
|
||||
|
||||
if (queries.value.length < 1) {
|
||||
queries.value.push(TransactionExplorerQuery.create(generateRandomUUID()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user