mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-25 21:15:59 +00:00
handle no data, clear filter
This commit is contained in:
@@ -18,7 +18,7 @@ import stableStringify from 'json-stable-stringify';
|
|||||||
import { ChangeSetFieldDefinition, ChangeSetRowDefinition } from './ChangeSet';
|
import { ChangeSetFieldDefinition, ChangeSetRowDefinition } from './ChangeSet';
|
||||||
|
|
||||||
export class TableFormViewDisplay extends FormViewDisplay {
|
export class TableFormViewDisplay extends FormViewDisplay {
|
||||||
// use utility functions from GridDisplay and publish result in FromViewDisplat interface
|
// use utility functions from GridDisplay and publish result in FromViewDisplay interface
|
||||||
private gridDisplay: TableGridDisplay;
|
private gridDisplay: TableGridDisplay;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
<script context="module" lang="ts">
|
<script context="module" lang="ts">
|
||||||
async function loadDataPage(props, offset, limit) {
|
function buildCondition(props) {
|
||||||
const { conid, database, display } = props;
|
const filters = props?.display?.config?.filters;
|
||||||
|
|
||||||
const filters = display?.config?.filters;
|
|
||||||
|
|
||||||
const conditions = [];
|
const conditions = [];
|
||||||
for (const uniqueName in filters) {
|
for (const uniqueName in filters || {}) {
|
||||||
if (!filters[uniqueName]) continue;
|
if (!filters[uniqueName]) continue;
|
||||||
try {
|
try {
|
||||||
const ast = parseFilter(filters[uniqueName], 'mongo');
|
const ast = parseFilter(filters[uniqueName], 'mongo');
|
||||||
@@ -22,6 +20,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return conditions.length > 0
|
||||||
|
? {
|
||||||
|
$and: conditions,
|
||||||
|
}
|
||||||
|
: undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadDataPage(props, offset, limit) {
|
||||||
|
const { conid, database } = props;
|
||||||
|
|
||||||
const response = await axiosInstance.request({
|
const response = await axiosInstance.request({
|
||||||
url: 'database-connections/collection-data',
|
url: 'database-connections/collection-data',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@@ -34,12 +42,7 @@
|
|||||||
pureName: props.pureName,
|
pureName: props.pureName,
|
||||||
limit,
|
limit,
|
||||||
skip: offset,
|
skip: offset,
|
||||||
condition:
|
condition: buildCondition(props),
|
||||||
conditions.length > 0
|
|
||||||
? {
|
|
||||||
$and: conditions,
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -69,6 +72,7 @@
|
|||||||
options: {
|
options: {
|
||||||
pureName: props.pureName,
|
pureName: props.pureName,
|
||||||
countDocuments: true,
|
countDocuments: true,
|
||||||
|
condition: buildCondition(props),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -82,6 +86,7 @@
|
|||||||
import { parseFilter } from 'dbgate-filterparser';
|
import { parseFilter } from 'dbgate-filterparser';
|
||||||
import { scriptToSql } from 'dbgate-sqltree';
|
import { scriptToSql } from 'dbgate-sqltree';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
||||||
import ConfirmSqlModal from '../modals/ConfirmSqlModal.svelte';
|
import ConfirmSqlModal from '../modals/ConfirmSqlModal.svelte';
|
||||||
import ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
|
import ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
|
||||||
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
||||||
@@ -216,5 +221,4 @@
|
|||||||
frameSelection={!!macroPreview}
|
frameSelection={!!macroPreview}
|
||||||
{grider}
|
{grider}
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
isDynamicStructure
|
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
export let showReferences = false;
|
export let showReferences = false;
|
||||||
export let showMacros;
|
export let showMacros;
|
||||||
export let freeTableColumn = false;
|
export let freeTableColumn = false;
|
||||||
|
export let isDynamicStructure = false;
|
||||||
export let macroCondition;
|
export let macroCondition;
|
||||||
export let onRunMacro;
|
export let onRunMacro;
|
||||||
|
|
||||||
|
|||||||
@@ -246,6 +246,7 @@
|
|||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
||||||
import { dataGridRowHeight } from './DataGridRowHeightMeter.svelte';
|
import { dataGridRowHeight } from './DataGridRowHeightMeter.svelte';
|
||||||
|
import FormStyledButton from '../elements/FormStyledButton.svelte';
|
||||||
|
|
||||||
export let onLoadNextData = undefined;
|
export let onLoadNextData = undefined;
|
||||||
export let grider = undefined;
|
export let grider = undefined;
|
||||||
@@ -1033,6 +1034,13 @@
|
|||||||
<LoadingInfo wrapper message="Waiting for structure" />
|
<LoadingInfo wrapper message="Waiting for structure" />
|
||||||
{:else if errorMessage}
|
{:else if errorMessage}
|
||||||
<ErrorInfo message={errorMessage} alignTop />
|
<ErrorInfo message={errorMessage} alignTop />
|
||||||
|
{:else if isDynamicStructure && isLoadedAll && grider?.rowCount == 0}
|
||||||
|
<div>
|
||||||
|
<ErrorInfo alignTop message="No rows loaded, check filter or add new documents" />
|
||||||
|
{#if display.filterCount > 0}
|
||||||
|
<FormStyledButton value="Reset filter" on:click={() => display.clearFilters()} />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
{:else if grider.errors && grider.errors.length > 0}
|
{:else if grider.errors && grider.errors.length > 0}
|
||||||
<div>
|
<div>
|
||||||
{#each grider.errors as err}
|
{#each grider.errors as err}
|
||||||
|
|||||||
@@ -72,4 +72,5 @@
|
|||||||
{changeSetStore}
|
{changeSetStore}
|
||||||
{dispatchChangeSet}
|
{dispatchChangeSet}
|
||||||
gridCoreComponent={CollectionDataGridCore}
|
gridCoreComponent={CollectionDataGridCore}
|
||||||
|
isDynamicStructure
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user