From 5a42e8c9aea55f7fea9a33c7a5f21a05a3659f9b Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Wed, 30 Dec 2020 13:00:48 +0100 Subject: [PATCH] designer fixes --- packages/web/src/designer/Designer.js | 19 +++++++++++++++++-- packages/web/src/designer/DesignerTable.js | 8 ++++++-- packages/web/src/modals/DropDownMenu.js | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/packages/web/src/designer/Designer.js b/packages/web/src/designer/Designer.js index 89433760..2111addb 100644 --- a/packages/web/src/designer/Designer.js +++ b/packages/web/src/designer/Designer.js @@ -26,6 +26,21 @@ const EmptyInfo = styled.div` font-size: 20px; `; +function fixPositions(tables) { + const minLeft = _.min(tables.map((x) => x.left)); + const minTop = _.min(tables.map((x) => x.top)); + if (minLeft < 0 || minTop < 0) { + const dLeft = minLeft < 0 ? -minLeft : 0; + const dTop = minTop < 0 ? -minTop : 0; + return tables.map((tbl) => ({ + ...tbl, + left: tbl.left + dLeft, + top: tbl.top + dTop, + })); + } + return tables; +} + export default function Designer({ value, onChange, conid, database }) { const { tables, references } = value || {}; const theme = useTheme(); @@ -105,7 +120,7 @@ export default function Designer({ value, onChange, conid, database }) { (table) => { onChange((current) => ({ ...current, - tables: (current.tables || []).map((x) => (x.designerId == table.designerId ? table : x)), + tables: fixPositions((current.tables || []).map((x) => (x.designerId == table.designerId ? table : x))), })); }, [onChange] @@ -288,7 +303,7 @@ export default function Designer({ value, onChange, conid, database }) { return ( - {(tables || []).length == 0 && Drag & drop tables or views from left panel list here} + {(tables || []).length == 0 && Drag & drop tables or views from left panel here} e.preventDefault()} onDrop={handleDrop} ref={wrapperRef}> {(references || []).map((ref) => ( // @ts-ignore props.isDragTarget && ` - background-color: ${props.theme.designtable_background_volcano[4]}; + background-color: ${props.theme.designtable_background_cyan[2]}; `} `; @@ -349,6 +349,10 @@ export default function DesignerTable({ setSourceDragColumn(dragData); e.dataTransfer.setData('designer_column_drag_data', JSON.stringify(dragData)); }} + onDragEnd={(e) => { + setTargetDragColumn(null); + setSourceDragColumn(null); + }} onDragOver={(e) => { if (sourceDragColumn) { e.preventDefault(); diff --git a/packages/web/src/modals/DropDownMenu.js b/packages/web/src/modals/DropDownMenu.js index 74ea12f1..6c71df6e 100644 --- a/packages/web/src/modals/DropDownMenu.js +++ b/packages/web/src/modals/DropDownMenu.js @@ -17,6 +17,7 @@ const ContextMenuStyled = styled.ul` text-align: left; min-width: 160px; z-index: 1050; + cursor: default; `; const KeyTextSpan = styled.span`