mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 03:06:00 +00:00
datagrid
This commit is contained in:
@@ -155,10 +155,10 @@ export default class ChangeSetGrider extends Grider {
|
||||
return this.insertedRows.length > 0;
|
||||
}
|
||||
|
||||
static factory({ sourceRows, changeSetState, dispatchChangeSet, display }): ChangeSetGrider {
|
||||
return new ChangeSetGrider(sourceRows, changeSetState, dispatchChangeSet, display);
|
||||
}
|
||||
static factoryDeps({ sourceRows, changeSetState, dispatchChangeSet, display }) {
|
||||
return [sourceRows, changeSetState ? changeSetState.value : null, dispatchChangeSet, display];
|
||||
}
|
||||
// static factory({ sourceRows, changeSetState, dispatchChangeSet, display }): ChangeSetGrider {
|
||||
// return new ChangeSetGrider(sourceRows, changeSetState, dispatchChangeSet, display);
|
||||
// }
|
||||
// static factoryDeps({ sourceRows, changeSetState, dispatchChangeSet, display }) {
|
||||
// return [sourceRows, changeSetState ? changeSetState.value : null, dispatchChangeSet, display];
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
export let isInserted = false;
|
||||
export let isDeleted = false;
|
||||
|
||||
$: value = rowData[col.uniqueName];
|
||||
$: value = (rowData || {})[col.uniqueName];
|
||||
</script>
|
||||
|
||||
<td
|
||||
|
||||
@@ -4,40 +4,39 @@
|
||||
export let loadDataPage;
|
||||
export let dataPageAvailable;
|
||||
export let loadRowCount;
|
||||
export let griderFactory;
|
||||
export let grider;
|
||||
// export let griderFactory;
|
||||
|
||||
let loadProps = {
|
||||
isLoading: false,
|
||||
loadedRows: [],
|
||||
isLoadedAll: false,
|
||||
loadedTime: new Date().getTime(),
|
||||
allRowCount: null,
|
||||
errorMessage: null,
|
||||
loadNextDataToken: 0,
|
||||
};
|
||||
export let loadedRows = [];
|
||||
let isLoading = false;
|
||||
let isLoadedAll = false;
|
||||
let loadedTime = new Date().getTime();
|
||||
let allRowCount = null;
|
||||
let errorMessage = null;
|
||||
let loadNextDataToken = 0;
|
||||
|
||||
async function loadNextData() {
|
||||
if (loadProps.isLoading) return;
|
||||
loadProps.isLoading = true;
|
||||
if (isLoading) return;
|
||||
isLoading = true;
|
||||
|
||||
const loadStart = new Date().getTime();
|
||||
|
||||
// loadedTimeRef.current = loadStart;
|
||||
|
||||
const nextRows = await loadDataPage($$props, loadProps.loadedRows.length, 100);
|
||||
const nextRows = await loadDataPage($$props, loadedRows.length, 100);
|
||||
// if (loadedTimeRef.current !== loadStart) {
|
||||
// // new load was dispatched
|
||||
// return;
|
||||
// }
|
||||
|
||||
loadProps.isLoading = false;
|
||||
isLoading = false;
|
||||
|
||||
if (nextRows.errorMessage) {
|
||||
loadProps.errorMessage = nextRows.errorMessage;
|
||||
errorMessage = nextRows.errorMessage;
|
||||
} else {
|
||||
// if (allRowCount == null) handleLoadRowCount();
|
||||
loadProps.loadedRows = [...loadProps.loadedRows, ...nextRows];
|
||||
loadProps.isLoadedAll = nextRows.length === 0;
|
||||
loadedRows = [loadedRows, ...nextRows];
|
||||
isLoadedAll = nextRows.length === 0;
|
||||
// const loadedInfo = {
|
||||
// loadedRows: [...loadedRows, ...nextRows],
|
||||
// loadedTime,
|
||||
@@ -52,11 +51,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
$: griderProps = { ...$$props, sourceRows: loadProps.loadedRows };
|
||||
$: grider = griderFactory(griderProps);
|
||||
// $: griderProps = { ...$$props, sourceRows: loadProps.loadedRows };
|
||||
// $: grider = griderFactory(griderProps);
|
||||
|
||||
const handleLoadNextData = () => {
|
||||
if (!loadProps.isLoadedAll && !loadProps.errorMessage && !grider.disableLoadNextPage) {
|
||||
if (!isLoadedAll && !errorMessage && !grider.disableLoadNextPage) {
|
||||
if (dataPageAvailable($$props)) {
|
||||
// If not, callbacks to load missing metadata are dispatched
|
||||
loadNextData();
|
||||
|
||||
@@ -50,16 +50,14 @@
|
||||
import LoadingDataGridCore from './LoadingDataGridCore.svelte';
|
||||
|
||||
export let conid;
|
||||
export let display;
|
||||
export let database;
|
||||
export let schemaName;
|
||||
export let pureName;
|
||||
export let config;
|
||||
let loadedRows = [];
|
||||
|
||||
$: grider = new ChangeSetGrider(loadedRows, null, null, display);
|
||||
</script>
|
||||
|
||||
<LoadingDataGridCore
|
||||
{...$$props}
|
||||
{loadDataPage}
|
||||
{dataPageAvailable}
|
||||
{loadRowCount}
|
||||
griderFactory={ChangeSetGrider.factory}
|
||||
/>
|
||||
<LoadingDataGridCore {...$$props} {loadDataPage} {dataPageAvailable} {loadRowCount} bind:loadedRows {grider} />
|
||||
|
||||
Reference in New Issue
Block a user