simplified flow of selectedCellsPublished

This commit is contained in:
Jan Prochazka
2021-04-04 08:16:51 +02:00
parent 0413f4b4d9
commit 0548bae7af
6 changed files with 25 additions and 12 deletions

View File

@@ -43,7 +43,7 @@
export let loadedRows; export let loadedRows;
let selectedCellsPublished = []; let selectedCellsPublished = () => [];
const selectedMacro = writable(null); const selectedMacro = writable(null);
setContext('selectedMacro', selectedMacro); setContext('selectedMacro', selectedMacro);
@@ -55,7 +55,7 @@
$: isFormView = !!(formDisplay && formDisplay.config && formDisplay.config.isFormView); $: isFormView = !!(formDisplay && formDisplay.config && formDisplay.config.isFormView);
const handleExecuteMacro = () => { const handleExecuteMacro = () => {
onRunMacro($selectedMacro, extractMacroValuesForMacro($macroValues, $selectedMacro), selectedCellsPublished); onRunMacro($selectedMacro, extractMacroValuesForMacro($macroValues, $selectedMacro), selectedCellsPublished());
$selectedMacro = null; $selectedMacro = null;
// const newChangeSet = runMacroOnChangeSet( // const newChangeSet = runMacroOnChangeSet(
@@ -117,11 +117,10 @@
this={gridCoreComponent} this={gridCoreComponent}
{...$$props} {...$$props}
formViewAvailable={!!formViewComponent && !!formDisplay} formViewAvailable={!!formViewComponent && !!formDisplay}
onSelectionChanged={value => (selectedCellsPublished = value)}
macroValues={extractMacroValuesForMacro($macroValues, $selectedMacro)} macroValues={extractMacroValuesForMacro($macroValues, $selectedMacro)}
macroPreview={$selectedMacro} macroPreview={$selectedMacro}
{selectedCellsPublished}
bind:loadedRows bind:loadedRows
bind:selectedCellsPublished
/> />
{/if} {/if}
</svelte:fragment> </svelte:fragment>

View File

@@ -258,7 +258,7 @@
export let allRowCount = undefined; export let allRowCount = undefined;
export let onReferenceSourceChanged = undefined; export let onReferenceSourceChanged = undefined;
export let onReferenceClick = undefined; export let onReferenceClick = undefined;
export let onSelectionChanged = undefined; // export let onSelectedCellsPublishedChanged = undefined;
export let onSave; export let onSave;
export let focusOnVisible = false; export let focusOnVisible = false;
export let onExportGrid = null; export let onExportGrid = null;
@@ -271,6 +271,7 @@
export let loadedTime; export let loadedTime;
export let changeSetStore; export let changeSetStore;
export let isDynamicStructure = false; export let isDynamicStructure = false;
export let selectedCellsPublished = () => [];
// export let generalAllowSave = false; // export let generalAllowSave = false;
const wheelRowCount = 5; const wheelRowCount = 5;
@@ -575,8 +576,10 @@
const stringified = stableStringify(selectedCells); const stringified = stableStringify(selectedCells);
if (lastPublishledSelectedCellsRef.get() != stringified) { if (lastPublishledSelectedCellsRef.get() != stringified) {
lastPublishledSelectedCellsRef.set(stringified); lastPublishledSelectedCellsRef.set(stringified);
if (onSelectionChanged) onSelectionChanged(getCellsPublished(selectedCells)); const cellsValue = () => getCellsPublished(selectedCells);
$selectedCellsCallback = () => getCellsPublished(selectedCells); selectedCellsPublished = cellsValue;
$selectedCellsCallback = cellsValue;
// if (onSelectedCellsPublishedChanged) onSelectedCellsPublishedChanged(getCellsPublished(selectedCells));
} }
} }

View File

@@ -9,6 +9,8 @@
export let grider; export let grider;
export let display; export let display;
export let masterLoadedTime = undefined; export let masterLoadedTime = undefined;
export let selectedCellsPublished;
// export let griderFactory; // export let griderFactory;
export let loadedRows = []; export let loadedRows = [];
@@ -120,4 +122,5 @@
{allRowCount} {allRowCount}
{isLoadedAll} {isLoadedAll}
{loadedTime} {loadedTime}
bind:selectedCellsPublished
/> />

View File

@@ -68,7 +68,7 @@
export let macroPreview; export let macroPreview;
export let macroValues; export let macroValues;
export let selectedCellsPublished; export let selectedCellsPublished = () => [];
// export let onChangeGrider = undefined; // export let onChangeGrider = undefined;
@@ -82,7 +82,7 @@
display, display,
macroPreview, macroPreview,
macroValues, macroValues,
selectedCellsPublished selectedCellsPublished()
); );
// $: console.log('GRIDER', grider); // $: console.log('GRIDER', grider);
// $: if (onChangeGrider) onChangeGrider(grider); // $: if (onChangeGrider) onChangeGrider(grider);
@@ -177,6 +177,7 @@
onOpenQuery={openQuery} onOpenQuery={openQuery}
onOpenActiveChart={openActiveChart} onOpenActiveChart={openActiveChart}
bind:loadedRows bind:loadedRows
bind:selectedCellsPublished
frameSelection={!!macroPreview} frameSelection={!!macroPreview}
{grider} {grider}
onSave={handleSave} onSave={handleSave}

View File

@@ -21,7 +21,7 @@
const cache = writable(createGridCache()); const cache = writable(createGridCache());
$: grider = macroPreview $: grider = macroPreview
? new MacroPreviewGrider(modelState.value, macroPreview, macroValues, selectedCellsPublished) ? new MacroPreviewGrider(modelState.value, macroPreview, macroValues, selectedCellsPublished())
: new FreeTableGrider(modelState, dispatchModel); : new FreeTableGrider(modelState, dispatchModel);
$: display = new FreeTableGridDisplay(grider.model || modelState.value, config, setConfig, $cache, cache.update); $: display = new FreeTableGridDisplay(grider.model || modelState.value, config, setConfig, $cache, cache.update);
@@ -36,4 +36,12 @@
} }
</script> </script>
<DataGridCore {...$$props} {grider} {display} frameSelection={!!macroPreview} {exportGrid} onExportGrid={exportGrid} /> <DataGridCore
{...$$props}
{grider}
{display}
frameSelection={!!macroPreview}
{exportGrid}
onExportGrid={exportGrid}
bind:selectedCellsPublished
/>

View File

@@ -4,7 +4,6 @@
import ErrorInfo from '../elements/ErrorInfo.svelte'; import ErrorInfo from '../elements/ErrorInfo.svelte';
import LoadingInfo from '../elements/LoadingInfo.svelte'; import LoadingInfo from '../elements/LoadingInfo.svelte';
import FreeTableGrid from '../freetable/FreeTableGrid.svelte';
import FreeTableGridCore from '../freetable/FreeTableGridCore.svelte'; import FreeTableGridCore from '../freetable/FreeTableGridCore.svelte';
import { showModal } from '../modals/modalTools'; import { showModal } from '../modals/modalTools';
import SaveArchiveModal from '../modals/SaveArchiveModal.svelte'; import SaveArchiveModal from '../modals/SaveArchiveModal.svelte';