choose dictionary value editor

This commit is contained in:
Jan Prochazka
2021-11-13 17:18:30 +01:00
parent 54b476fc27
commit d792744bfb
6 changed files with 60 additions and 16 deletions

View File

@@ -204,7 +204,8 @@
driver, driver,
pureName: foreignKey.refTableName, pureName: foreignKey.refTableName,
schemaName: foreignKey.refSchemaName, schemaName: foreignKey.refSchemaName,
onConfirm: setFilter, multiselect: true,
onConfirm: keys => setFilter(keys.join(',')),
}); });
} }

View File

@@ -38,6 +38,8 @@
import ShowFormButton from '../formview/ShowFormButton.svelte'; import ShowFormButton from '../formview/ShowFormButton.svelte';
import { getBoolSettingsValue } from '../settings/settingsTools'; import { getBoolSettingsValue } from '../settings/settingsTools';
import { arrayToHexString } from 'dbgate-tools'; import { arrayToHexString } from 'dbgate-tools';
import { showModal } from '../modals/modalTools';
import DictionaryLookupModal from '../modals/DictionaryLookupModal.svelte';
export let rowIndex; export let rowIndex;
export let col; export let col;
@@ -58,6 +60,8 @@
export let onSetFormView; export let onSetFormView;
export let isDynamicStructure = false; export let isDynamicStructure = false;
export let isAutoFillMarker = false; export let isAutoFillMarker = false;
export let isCurrentCell = false;
export let onDictionaryLookup = null;
$: value = col.isStructured ? _.get(rowData || {}, col.uniquePath) : (rowData || {})[col.uniqueName]; $: value = col.isStructured ? _.get(rowData || {}, col.uniquePath) : (rowData || {})[col.uniqueName];
</script> </script>
@@ -119,9 +123,13 @@
> >
{/if} {/if}
{#if col.foreignKey && rowData && rowData[col.uniqueName]} {#if col.foreignKey && rowData && rowData[col.uniqueName] && !isCurrentCell}
<ShowFormButton on:click={() => onSetFormView(rowData, col)} /> <ShowFormButton on:click={() => onSetFormView(rowData, col)} />
{/if} {/if}
{#if col.foreignKey && isCurrentCell}
<ShowFormButton icon="icon dots-horizontal" on:click={onDictionaryLookup} />
{/if}
{/if} {/if}
{#if isAutoFillMarker} {#if isAutoFillMarker}

View File

@@ -191,7 +191,6 @@
if (allRowCount == null) return 'Loading row count...'; if (allRowCount == null) return 'Loading row count...';
return `Rows: ${allRowCount.toLocaleString()}`; return `Rows: ${allRowCount.toLocaleString()}`;
} }
</script> </script>
<script lang="ts"> <script lang="ts">
@@ -223,7 +222,7 @@
import keycodes from '../utility/keycodes'; import keycodes from '../utility/keycodes';
import { selectedCellsCallback } from '../stores'; import { selectedCellsCallback } from '../stores';
import axiosInstance from '../utility/axiosInstance'; import axiosInstance from '../utility/axiosInstance';
import { copyTextToClipboard ,extractRowCopiedValue} from '../utility/clipboard'; import { copyTextToClipboard, extractRowCopiedValue } from '../utility/clipboard';
import invalidateCommands from '../commands/invalidateCommands'; import invalidateCommands from '../commands/invalidateCommands';
import createRef from '../utility/createRef'; import createRef from '../utility/createRef';
import openReferenceForm, { openPrimaryKeyForm } from '../formview/openReferenceForm'; import openReferenceForm, { openPrimaryKeyForm } from '../formview/openReferenceForm';
@@ -716,6 +715,7 @@
if (event.target.closest('.buttonLike')) return; if (event.target.closest('.buttonLike')) return;
if (event.target.closest('.resizeHandleControl')) return; if (event.target.closest('.resizeHandleControl')) return;
if (event.target.closest('.collapseButtonMarker')) return; if (event.target.closest('.collapseButtonMarker')) return;
if (event.target.closest('.showFormButtonMarker')) return;
if (event.target.closest('input')) return; if (event.target.closest('input')) return;
shiftDragStartCell = null; shiftDragStartCell = null;
@@ -1260,6 +1260,9 @@
<DataGridRow <DataGridRow
{rowIndex} {rowIndex}
{grider} {grider}
{conid}
{database}
driver={display?.driver}
{visibleRealColumns} {visibleRealColumns}
{rowHeight} {rowHeight}
{autofillSelectedCells} {autofillSelectedCells}
@@ -1268,6 +1271,7 @@
autofillMarkerCell={filterCellForRow(autofillMarkerCell, rowIndex)} autofillMarkerCell={filterCellForRow(autofillMarkerCell, rowIndex)}
focusedColumn={display.focusedColumn} focusedColumn={display.focusedColumn}
inplaceEditorState={$inplaceEditorState} inplaceEditorState={$inplaceEditorState}
currentCellColumn={currentCell && currentCell[0] == rowIndex ? currentCell[1] : null}
{dispatchInsplaceEditor} {dispatchInsplaceEditor}
{frameSelection} {frameSelection}
onSetFormView={formViewAvailable && display?.baseTable?.primaryKey ? handleSetFormView : null} onSetFormView={formViewAvailable && display?.baseTable?.primaryKey ? handleSetFormView : null}

View File

@@ -1,5 +1,7 @@
<script lang="ts"> <script lang="ts">
import openReferenceForm from '../formview/openReferenceForm'; import openReferenceForm from '../formview/openReferenceForm';
import DictionaryLookupModal from '../modals/DictionaryLookupModal.svelte';
import { showModal } from '../modals/modalTools';
import DataGridCell from './DataGridCell.svelte'; import DataGridCell from './DataGridCell.svelte';
import { cellIsSelected } from './gridutil'; import { cellIsSelected } from './gridutil';
@@ -20,6 +22,10 @@
export let dispatchInsplaceEditor; export let dispatchInsplaceEditor;
export let onSetFormView; export let onSetFormView;
export let isDynamicStructure = false; export let isDynamicStructure = false;
export let currentCellColumn;
export let conid;
export let database;
export let driver;
$: rowData = grider.getRowData(rowIndex); $: rowData = grider.getRowData(rowIndex);
$: rowStatus = grider.getRowStatus(rowIndex); $: rowStatus = grider.getRowStatus(rowIndex);
@@ -31,6 +37,17 @@
return true; return true;
}) })
.map(col => col.uniqueName); .map(col => col.uniqueName);
function handleLookup(col) {
showModal(DictionaryLookupModal, {
conid,
database,
driver,
pureName: col.foreignKey.refTableName,
schemaName: col.foreignKey.refSchemaName,
onConfirm: value => grider.setCellValue(rowIndex, col.uniqueName, value),
});
}
</script> </script>
<tr style={`height: ${rowHeight}px`}> <tr style={`height: ${rowHeight}px`}>
@@ -51,8 +68,11 @@
{rowIndex} {rowIndex}
{rowData} {rowData}
{col} {col}
{conid}
{database}
allowHintField={hintFieldsAllowed?.includes(col.uniqueName)} allowHintField={hintFieldsAllowed?.includes(col.uniqueName)}
isSelected={frameSelection ? false : cellIsSelected(rowIndex, col.colIndex, selectedCells)} isSelected={frameSelection ? false : cellIsSelected(rowIndex, col.colIndex, selectedCells)}
isCurrentCell={col.colIndex == currentCellColumn}
isFrameSelected={frameSelection ? cellIsSelected(rowIndex, col.colIndex, selectedCells) : false} isFrameSelected={frameSelection ? cellIsSelected(rowIndex, col.colIndex, selectedCells) : false}
isAutofillSelected={cellIsSelected(rowIndex, col.colIndex, autofillSelectedCells)} isAutofillSelected={cellIsSelected(rowIndex, col.colIndex, autofillSelectedCells)}
isFocusedColumn={col.uniqueName == focusedColumn} isFocusedColumn={col.uniqueName == focusedColumn}
@@ -68,6 +88,7 @@
autofillMarkerCell[1] == col.colIndex && autofillMarkerCell[1] == col.colIndex &&
autofillMarkerCell[0] == rowIndex && autofillMarkerCell[0] == rowIndex &&
grider.editable} grider.editable}
onDictionaryLookup={() => handleLookup(col)}
/> />
{/if} {/if}
{/each} {/each}

View File

@@ -1,9 +1,11 @@
<script lang="ts"> <script lang="ts">
import FontIcon from '../icons/FontIcon.svelte'; import FontIcon from '../icons/FontIcon.svelte';
export let icon = 'icon form';
</script> </script>
<div on:click|stopPropagation> <div on:click|stopPropagation class='showFormButtonMarker'>
<FontIcon icon="icon form" /> <FontIcon {icon} />
</div> </div>
<style> <style>

View File

@@ -22,6 +22,7 @@
export let pureName; export let pureName;
export let schemaName; export let schemaName;
export let driver; export let driver;
export let multiselect = false;
let rows = null; let rows = null;
let tableInfo; let tableInfo;
@@ -143,11 +144,16 @@
clickable clickable
on:clickrow={e => { on:clickrow={e => {
const value = e.detail[tableInfo.primaryKey.columns[0].columnName]; const value = e.detail[tableInfo.primaryKey.columns[0].columnName];
if (checkedKeys.includes(value)) checkedKeys = checkedKeys.filter(x => x != value); if (multiselect) {
else checkedKeys = [...checkedKeys, value]; if (checkedKeys.includes(value)) checkedKeys = checkedKeys.filter(x => x != value);
else checkedKeys = [...checkedKeys, value];
} else {
closeCurrentModal();
onConfirm(value);
}
}} }}
columns={[ columns={[
{ multiselect && {
fieldName: 'checked', fieldName: 'checked',
header: '', header: '',
width: '30px', width: '30px',
@@ -183,13 +189,15 @@
{/if} {/if}
<svelte:fragment slot="footer"> <svelte:fragment slot="footer">
<FormSubmit {#if multiselect}
value="OK" <FormSubmit
on:click={() => { value="OK"
closeCurrentModal(); on:click={() => {
onConfirm(checkedKeys.join(',')); closeCurrentModal();
}} onConfirm(checkedKeys);
/> }}
/>
{/if}
<FormStyledButton type="button" value="Close" on:click={closeCurrentModal} /> <FormStyledButton type="button" value="Close" on:click={closeCurrentModal} />
<FormStyledButton type="button" value="Customize" on:click={defineDescription} /> <FormStyledButton type="button" value="Customize" on:click={defineDescription} />
</svelte:fragment> </svelte:fragment>