support configuring the data source of the data table in insights explorer
This commit is contained in:
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Urednik",
|
||||
"Expression": "Izraz",
|
||||
"Failed to generate expression": "Izraza ni bilo mogoče ustvariti",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Os / Kategorija",
|
||||
"Series": "Serije",
|
||||
"Transaction Date": "Datum transakcije",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "Editor",
|
||||
"Expression": "Expression",
|
||||
"Failed to generate expression": "Failed to generate expression",
|
||||
"Data Source": "Data Source",
|
||||
"All Queries": "All Queries",
|
||||
"Axis / Category": "Axis / Category",
|
||||
"Series": "Series",
|
||||
"Transaction Date": "Transaction Date",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "编辑器",
|
||||
"Expression": "表达式",
|
||||
"Failed to generate expression": "生成表达式失败",
|
||||
"Data Source": "数据源",
|
||||
"All Queries": "所有查询",
|
||||
"Axis / Category": "轴 / 分类",
|
||||
"Series": "系列",
|
||||
"Transaction Date": "交易日期",
|
||||
|
||||
@@ -1745,6 +1745,8 @@
|
||||
"Editor": "編輯器",
|
||||
"Expression": "表達式",
|
||||
"Failed to generate expression": "產生表達式失敗",
|
||||
"Data Source": "資料來源",
|
||||
"All Queries": "所有查詢",
|
||||
"Axis / Category": "軸 / 類別",
|
||||
"Series": "系列",
|
||||
"Transaction Date": "交易日期",
|
||||
|
||||
+33
-13
@@ -64,6 +64,7 @@ export class InsightsExplorer implements InsightsExplorerInfoResponse {
|
||||
public hidden: boolean;
|
||||
public queries: TransactionExplorerQuery[];
|
||||
public timezoneUsedForDateRange: number;
|
||||
public datatableQuerySource: string;
|
||||
public countPerPage: number;
|
||||
public chartType: TransactionExplorerChartTypeValue;
|
||||
public categoryDimension: TransactionExplorerDataDimensionType;
|
||||
@@ -78,6 +79,7 @@ export class InsightsExplorer implements InsightsExplorerInfoResponse {
|
||||
false,
|
||||
[],
|
||||
TimezoneTypeForStatistics.Default.type,
|
||||
'',
|
||||
15,
|
||||
TransactionExplorerChartType.Default.value,
|
||||
TransactionExplorerDataDimension.CategoryDimensionDefault.value,
|
||||
@@ -86,13 +88,14 @@ export class InsightsExplorer implements InsightsExplorerInfoResponse {
|
||||
ChartSortingType.Default.type
|
||||
);
|
||||
|
||||
private constructor(id: string, name: string, displayOrder: number, hidden: boolean, queries: TransactionExplorerQuery[], timezoneUsedForDateRange: number, countPerPage: number, chartType: TransactionExplorerChartTypeValue, categoryDimension: TransactionExplorerDataDimensionType, seriesDimension: TransactionExplorerDataDimensionType, valueMetric: TransactionExplorerValueMetricType, chartSortingType: number) {
|
||||
private constructor(id: string, name: string, displayOrder: number, hidden: boolean, queries: TransactionExplorerQuery[], timezoneUsedForDateRange: number, datatableQuerySource: string, countPerPage: number, chartType: TransactionExplorerChartTypeValue, categoryDimension: TransactionExplorerDataDimensionType, seriesDimension: TransactionExplorerDataDimensionType, valueMetric: TransactionExplorerValueMetricType, chartSortingType: number) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.displayOrder = displayOrder;
|
||||
this.hidden = hidden;
|
||||
this.queries = queries;
|
||||
this.timezoneUsedForDateRange = timezoneUsedForDateRange;
|
||||
this.datatableQuerySource = datatableQuerySource;
|
||||
this.countPerPage = countPerPage;
|
||||
this.chartType = chartType;
|
||||
this.categoryDimension = categoryDimension;
|
||||
@@ -105,6 +108,7 @@ export class InsightsExplorer implements InsightsExplorerInfoResponse {
|
||||
return {
|
||||
queries: this.queries.map(q => q.toJsonObject()),
|
||||
timezoneUsedForDateRange: this.timezoneUsedForDateRange,
|
||||
datatableQuerySource: this.datatableQuerySource,
|
||||
countPerPage: this.countPerPage,
|
||||
chartType: this.chartType,
|
||||
categoryDimension: this.categoryDimension,
|
||||
@@ -135,30 +139,24 @@ export class InsightsExplorer implements InsightsExplorerInfoResponse {
|
||||
const data = explorerResponse.data;
|
||||
const queries: TransactionExplorerQuery[] = [];
|
||||
let timezoneUsedForDateRange = InsightsExplorer.Default.timezoneUsedForDateRange;
|
||||
let datatableQuerySource = InsightsExplorer.Default.datatableQuerySource;
|
||||
let countPerPage = InsightsExplorer.Default.countPerPage;
|
||||
let chartType = InsightsExplorer.Default.chartType;
|
||||
let categoryDimension = InsightsExplorer.Default.categoryDimension;
|
||||
let seriesDimension = InsightsExplorer.Default.seriesDimension;
|
||||
let valueMetric = InsightsExplorer.Default.valueMetric;
|
||||
let chartSortingType = InsightsExplorer.Default.chartSortingType;
|
||||
let hasDatatableQuerySource = false;
|
||||
|
||||
if (data) {
|
||||
if (Array.isArray(data['queries'])) {
|
||||
const queryItems = data['queries'] as object[];
|
||||
|
||||
for (const queryItem of queryItems) {
|
||||
const query = TransactionExplorerQuery.parse(queryItem);
|
||||
|
||||
if (query) {
|
||||
queries.push(query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof data['timezoneUsedForDateRange'] === 'number') {
|
||||
timezoneUsedForDateRange = data['timezoneUsedForDateRange'] as number;
|
||||
}
|
||||
|
||||
if (typeof data['datatableQuerySource'] === 'string') {
|
||||
datatableQuerySource = data['datatableQuerySource'] as string;
|
||||
}
|
||||
|
||||
if (typeof data['countPerPage'] === 'number') {
|
||||
countPerPage = data['countPerPage'] as number;
|
||||
}
|
||||
@@ -182,6 +180,26 @@ export class InsightsExplorer implements InsightsExplorerInfoResponse {
|
||||
if (typeof data['chartSortingType'] === 'number') {
|
||||
chartSortingType = data['chartSortingType'] as number;
|
||||
}
|
||||
|
||||
if (Array.isArray(data['queries'])) {
|
||||
const queryItems = data['queries'] as object[];
|
||||
|
||||
for (const queryItem of queryItems) {
|
||||
const query = TransactionExplorerQuery.parse(queryItem);
|
||||
|
||||
if (query) {
|
||||
queries.push(query);
|
||||
}
|
||||
|
||||
if (query && query.id === datatableQuerySource) {
|
||||
hasDatatableQuerySource = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasDatatableQuerySource) {
|
||||
datatableQuerySource = '';
|
||||
}
|
||||
}
|
||||
|
||||
return new InsightsExplorer(
|
||||
@@ -191,6 +209,7 @@ export class InsightsExplorer implements InsightsExplorerInfoResponse {
|
||||
explorerResponse.hidden,
|
||||
queries,
|
||||
timezoneUsedForDateRange,
|
||||
datatableQuerySource,
|
||||
countPerPage,
|
||||
chartType,
|
||||
categoryDimension,
|
||||
@@ -208,6 +227,7 @@ export class InsightsExplorer implements InsightsExplorerInfoResponse {
|
||||
false,
|
||||
[TransactionExplorerQuery.create(newQueryId)],
|
||||
InsightsExplorer.Default.timezoneUsedForDateRange,
|
||||
InsightsExplorer.Default.datatableQuerySource,
|
||||
InsightsExplorer.Default.countPerPage,
|
||||
InsightsExplorer.Default.chartType,
|
||||
InsightsExplorer.Default.categoryDimension,
|
||||
|
||||
@@ -551,7 +551,7 @@ export const useExplorersStore = defineStore('explorers', () => {
|
||||
return result;
|
||||
});
|
||||
|
||||
const filteredTransactions = computed<TransactionInsightDataItem[]>(() => {
|
||||
const filteredTransactionsInDataTable = computed<TransactionInsightDataItem[]>(() => {
|
||||
if (!allTransactions.value || allTransactions.value.length < 1) {
|
||||
return [];
|
||||
}
|
||||
@@ -564,6 +564,10 @@ export const useExplorersStore = defineStore('explorers', () => {
|
||||
|
||||
for (const transaction of allTransactions.value) {
|
||||
for (const query of currentInsightsExplorer.value.queries) {
|
||||
if (currentInsightsExplorer.value.datatableQuerySource && currentInsightsExplorer.value.datatableQuerySource !== query.id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (query.match(transaction)) {
|
||||
result.push(transaction);
|
||||
break;
|
||||
@@ -1165,7 +1169,7 @@ export const useExplorersStore = defineStore('explorers', () => {
|
||||
currentInsightsExplorer,
|
||||
insightsExplorerListStateInvalid,
|
||||
// computed
|
||||
filteredTransactions,
|
||||
filteredTransactionsInDataTable,
|
||||
categoriedTransactionExplorerData,
|
||||
// functions
|
||||
updateTransactionExplorerInvalidState,
|
||||
|
||||
@@ -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