do not switch expression when there are no conditions
This commit is contained in:
@@ -105,6 +105,10 @@ export class TransactionExploreQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public toExpression(allCategoriesMap: Record<string, TransactionCategory>, allAccountsMap: Record<string, Account>, allTagsMap: Record<string, TransactionTag>): string {
|
public toExpression(allCategoriesMap: Record<string, TransactionCategory>, allAccountsMap: Record<string, Account>, allTagsMap: Record<string, TransactionTag>): string {
|
||||||
|
if (!this.conditions || this.conditions.length < 1) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
const postfixExprTokens = this.getPostfixExprTokens();
|
const postfixExprTokens = this.getPostfixExprTokens();
|
||||||
const stack: ExpressionNode[] = [];
|
const stack: ExpressionNode[] = [];
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
<span class="text-subtitle-1">{{ tt('Query') }} {{ `#${queryIndex + 1}` }}</span>
|
<span class="text-subtitle-1">{{ tt('Query') }} {{ `#${queryIndex + 1}` }}</span>
|
||||||
<v-spacer />
|
<v-spacer />
|
||||||
<v-switch class="bidirectional-switch ms-2" color="secondary"
|
<v-switch class="bidirectional-switch ms-2" color="secondary"
|
||||||
|
:disabled="!query.conditions || query.conditions.length < 1"
|
||||||
:label="tt('Expression')"
|
:label="tt('Expression')"
|
||||||
v-model="showExpression"
|
v-model="showExpression"
|
||||||
@click="showExpression = !showExpression">
|
@click="showExpression = !showExpression">
|
||||||
@@ -40,7 +41,7 @@
|
|||||||
{{ tt('No conditions defined. All transactions will match.') }}
|
{{ tt('No conditions defined. All transactions will match.') }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="!showExpression">
|
<div v-else-if="query.conditions && query.conditions.length > 0 && !showExpression">
|
||||||
<div :key="conditionIndex" v-for="(conditionWithRelation, conditionIndex) in query.conditions">
|
<div :key="conditionIndex" v-for="(conditionWithRelation, conditionIndex) in query.conditions">
|
||||||
<div class="d-flex align-center gap-2 mb-4">
|
<div class="d-flex align-center gap-2 mb-4">
|
||||||
<v-select
|
<v-select
|
||||||
@@ -268,7 +269,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="showExpression">
|
<div v-else-if="query.conditions && query.conditions.length > 0 && showExpression">
|
||||||
<div class="w-100 code-container">
|
<div class="w-100 code-container">
|
||||||
<v-textarea class="w-100 always-cursor-text mb-4" :readonly="true"
|
<v-textarea class="w-100 always-cursor-text mb-4" :readonly="true"
|
||||||
:value="getExpression(queryIndex)"></v-textarea>
|
:value="getExpression(queryIndex)"></v-textarea>
|
||||||
@@ -592,7 +593,7 @@ function updateTransactionCategories(changed: boolean, selectedCategoryIds?: str
|
|||||||
function getExpression(queryIndex: number): string {
|
function getExpression(queryIndex: number): string {
|
||||||
const query = queries.value[queryIndex];
|
const query = queries.value[queryIndex];
|
||||||
|
|
||||||
if (!query) {
|
if (!query || !query.conditions || query.conditions.length < 1) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user