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