mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 11:16:01 +00:00
selected cells refactor
This commit is contained in:
@@ -135,12 +135,13 @@
|
||||
|
||||
export let macroPreview;
|
||||
export let macroValues;
|
||||
export let selectedCellsPublished;
|
||||
export let setLoadedRows = null;
|
||||
export let onPublishedCellsChanged;
|
||||
|
||||
// export let onChangeGrider = undefined;
|
||||
|
||||
let loadedRows = [];
|
||||
let publishedCells = [];
|
||||
|
||||
export const activator = createActivator('CollectionDataGridCore', false);
|
||||
|
||||
@@ -152,7 +153,7 @@
|
||||
display,
|
||||
macroPreview,
|
||||
macroValues,
|
||||
selectedCellsPublished()
|
||||
publishedCells
|
||||
);
|
||||
// $: console.log('GRIDER', grider);
|
||||
// $: if (onChangeGrider) onChangeGrider(grider);
|
||||
@@ -239,7 +240,12 @@
|
||||
{dataPageAvailable}
|
||||
{loadRowCount}
|
||||
setLoadedRows={handleSetLoadedRows}
|
||||
bind:selectedCellsPublished
|
||||
onPublishedCellsChanged={value => {
|
||||
publishedCells = value;
|
||||
if (onPublishedCellsChanged) {
|
||||
onPublishedCellsChanged(value);
|
||||
}
|
||||
}}
|
||||
frameSelection={!!macroPreview}
|
||||
onOpenQuery={openQuery}
|
||||
{grider}
|
||||
|
||||
@@ -91,11 +91,13 @@
|
||||
export let setLoadedRows = null;
|
||||
export let hideGridLeftColumn = false;
|
||||
|
||||
export let onPublishedCellsChanged;
|
||||
|
||||
let loadedRows;
|
||||
let publishedCells = [];
|
||||
|
||||
export const activator = createActivator('DataGrid', false);
|
||||
|
||||
export let selectedCellsPublished = () => [];
|
||||
let domColumnManager;
|
||||
|
||||
const selectedMacro = writable(null);
|
||||
@@ -111,7 +113,7 @@
|
||||
$: isJsonView = !!config?.isJsonView;
|
||||
|
||||
const handleExecuteMacro = () => {
|
||||
onRunMacro($selectedMacro, extractMacroValuesForMacro($macroValues, $selectedMacro), selectedCellsPublished());
|
||||
onRunMacro($selectedMacro, extractMacroValuesForMacro($macroValues, $selectedMacro), publishedCells);
|
||||
$selectedMacro = null;
|
||||
};
|
||||
|
||||
@@ -123,7 +125,7 @@
|
||||
|
||||
export function switchToView(view) {
|
||||
if (view == 'form') {
|
||||
display.switchToFormView(selectedCellsPublished()[0]?.row);
|
||||
display.switchToFormView(publishedCells[0]?.row);
|
||||
}
|
||||
if (view == 'table') {
|
||||
setConfig(cfg => ({
|
||||
@@ -220,7 +222,12 @@
|
||||
macroValues={extractMacroValuesForMacro($macroValues, $selectedMacro)}
|
||||
macroPreview={$selectedMacro}
|
||||
{setLoadedRows}
|
||||
bind:selectedCellsPublished
|
||||
onPublishedCellsChanged={value => {
|
||||
publishedCells = value;
|
||||
if (onPublishedCellsChanged) {
|
||||
onPublishedCellsChanged(value);
|
||||
}
|
||||
}}
|
||||
onChangeSelectedColumns={cols => {
|
||||
if (domColumnManager) domColumnManager.setSelectedColumns(cols);
|
||||
}}
|
||||
|
||||
@@ -411,6 +411,7 @@
|
||||
export let isLoading = false;
|
||||
export let allRowCount = undefined;
|
||||
export let onReferenceSourceChanged = undefined;
|
||||
export let onPublishedCellsChanged = undefined;
|
||||
export let onReferenceClick = undefined;
|
||||
export let onChangeSelectedColumns = undefined;
|
||||
// export let onSelectedCellsPublishedChanged = undefined;
|
||||
@@ -427,7 +428,7 @@
|
||||
export let loadedTime;
|
||||
export let changeSetStore;
|
||||
export let isDynamicStructure = false;
|
||||
export let selectedCellsPublished = () => [];
|
||||
// export let selectedCellsPublished = () => [];
|
||||
export let collapsedLeftColumnStore;
|
||||
export let multipleGridsOnTab = false;
|
||||
export let tabControlHiddenTab = false;
|
||||
@@ -1079,13 +1080,24 @@
|
||||
const lastPublishledSelectedCellsRef = createRef('');
|
||||
$: {
|
||||
const stringified = stableStringify(selectedCells);
|
||||
if (lastPublishledSelectedCellsRef.get() != stringified) {
|
||||
console.log('GRID CORE SELECTED CELLS', selectedCells);
|
||||
console.log('grider', grider);
|
||||
if (lastPublishledSelectedCellsRef.get() != stringified && realColumnUniqueNames?.length > 0) {
|
||||
lastPublishledSelectedCellsRef.set(stringified);
|
||||
const cellsValue = () => getCellsPublished(selectedCells);
|
||||
selectedCellsPublished = cellsValue;
|
||||
// selectedCellsPublished = cellsValue;
|
||||
$selectedCellsCallback = cellsValue;
|
||||
|
||||
if (onChangeSelectedColumns) onChangeSelectedColumns(getSelectedColumns().map(x => x.columnName));
|
||||
console.log('PUBLISH GRID CORE', selectedCells, cellsValue());
|
||||
|
||||
if (onChangeSelectedColumns) {
|
||||
onChangeSelectedColumns(getSelectedColumns().map(x => x.columnName));
|
||||
}
|
||||
|
||||
if (onPublishedCellsChanged) {
|
||||
onPublishedCellsChanged(getCellsPublished(selectedCells));
|
||||
}
|
||||
|
||||
// if (onSelectedCellsPublishedChanged) onSelectedCellsPublishedChanged(getCellsPublished(selectedCells));
|
||||
}
|
||||
}
|
||||
@@ -1109,10 +1121,12 @@
|
||||
|
||||
function getCellsPublished(cells) {
|
||||
const regular = cellsToRegularCells(cells);
|
||||
console.log('REGULAR CELLS', cells);
|
||||
const res = regular
|
||||
.map(cell => {
|
||||
const row = cell[0];
|
||||
const rowData = grider.getRowData(row);
|
||||
console.log('REAL COLUMN UNIQUE NAMES', realColumnUniqueNames);
|
||||
const column = realColumnUniqueNames[cell[1]];
|
||||
return {
|
||||
row,
|
||||
|
||||
@@ -69,11 +69,13 @@
|
||||
|
||||
export let macroPreview;
|
||||
export let macroValues;
|
||||
export let selectedCellsPublished = () => [];
|
||||
export let onPublishedCellsChanged
|
||||
export const activator = createActivator('JslDataGridCore', false);
|
||||
|
||||
export let setLoadedRows;
|
||||
|
||||
let publishedCells = [];
|
||||
|
||||
let loadedRows = [];
|
||||
let domGrid;
|
||||
|
||||
@@ -113,7 +115,7 @@
|
||||
display,
|
||||
macroPreview,
|
||||
macroValues,
|
||||
selectedCellsPublished(),
|
||||
publishedCells,
|
||||
true
|
||||
);
|
||||
}
|
||||
@@ -199,7 +201,12 @@
|
||||
bind:this={domGrid}
|
||||
{...$$props}
|
||||
setLoadedRows={handleSetLoadedRows}
|
||||
bind:selectedCellsPublished
|
||||
onPublishedCellsChanged={value => {
|
||||
publishedCells = value;
|
||||
if (onPublishedCellsChanged) {
|
||||
onPublishedCellsChanged(value);
|
||||
}
|
||||
}}
|
||||
{loadDataPage}
|
||||
{dataPageAvailable}
|
||||
{loadRowCount}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
export let grider;
|
||||
export let display;
|
||||
export let masterLoadedTime = undefined;
|
||||
export let selectedCellsPublished;
|
||||
export let rowCountLoaded = null;
|
||||
|
||||
export let preprocessLoadedRow = null;
|
||||
@@ -128,7 +127,6 @@
|
||||
<DataGridCore
|
||||
{...$$props}
|
||||
bind:this={domGrid}
|
||||
bind:selectedCellsPublished
|
||||
onLoadNextData={handleLoadNextData}
|
||||
{errorMessage}
|
||||
{isLoading}
|
||||
|
||||
@@ -95,7 +95,9 @@
|
||||
|
||||
export let macroPreview;
|
||||
export let macroValues;
|
||||
export let selectedCellsPublished = () => [];
|
||||
export let onPublishedCellsChanged;
|
||||
|
||||
let publishedCells = [];
|
||||
|
||||
// export let onChangeGrider = undefined;
|
||||
|
||||
@@ -116,7 +118,7 @@
|
||||
display,
|
||||
macroPreview,
|
||||
macroValues,
|
||||
selectedCellsPublished()
|
||||
publishedCells
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -224,7 +226,12 @@
|
||||
{dataPageAvailable}
|
||||
{loadRowCount}
|
||||
setLoadedRows={handleSetLoadedRows}
|
||||
bind:selectedCellsPublished
|
||||
onPublishedCellsChanged={value => {
|
||||
publishedCells = value;
|
||||
if (onPublishedCellsChanged) {
|
||||
onPublishedCellsChanged(value);
|
||||
}
|
||||
}}
|
||||
frameSelection={!!macroPreview}
|
||||
{grider}
|
||||
{display}
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
export let cache;
|
||||
export let setCache;
|
||||
export let multipleGridsOnTab = false;
|
||||
export let selectedCellsPublished = () => [];
|
||||
|
||||
$: connection = useConnectionInfo({ conid });
|
||||
$: dbinfo = useDatabaseInfo({ conid, database });
|
||||
@@ -173,7 +172,6 @@
|
||||
}
|
||||
setChildConfig(createGridConfig(), value);
|
||||
}}
|
||||
bind:selectedCellsPublished
|
||||
/>
|
||||
</svelte:fragment>
|
||||
<div slot="2" class="reference-container">
|
||||
|
||||
Reference in New Issue
Block a user