mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-23 20:45:59 +00:00
designer fixes
This commit is contained in:
@@ -26,6 +26,21 @@ const EmptyInfo = styled.div`
|
|||||||
font-size: 20px;
|
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 }) {
|
export default function Designer({ value, onChange, conid, database }) {
|
||||||
const { tables, references } = value || {};
|
const { tables, references } = value || {};
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -105,7 +120,7 @@ export default function Designer({ value, onChange, conid, database }) {
|
|||||||
(table) => {
|
(table) => {
|
||||||
onChange((current) => ({
|
onChange((current) => ({
|
||||||
...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]
|
[onChange]
|
||||||
@@ -288,7 +303,7 @@ export default function Designer({ value, onChange, conid, database }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper theme={theme}>
|
<Wrapper theme={theme}>
|
||||||
{(tables || []).length == 0 && <EmptyInfo>Drag & drop tables or views from left panel list here</EmptyInfo>}
|
{(tables || []).length == 0 && <EmptyInfo>Drag & drop tables or views from left panel here</EmptyInfo>}
|
||||||
<Canvas onDragOver={(e) => e.preventDefault()} onDrop={handleDrop} ref={wrapperRef}>
|
<Canvas onDragOver={(e) => e.preventDefault()} onDrop={handleDrop} ref={wrapperRef}>
|
||||||
{(references || []).map((ref) => (
|
{(references || []).map((ref) => (
|
||||||
<DesignerReference
|
<DesignerReference
|
||||||
|
|||||||
@@ -78,14 +78,14 @@ const ColumnLine = styled.div`
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
props.isDragSource &&
|
props.isDragSource &&
|
||||||
`
|
`
|
||||||
background-color: ${props.theme.designtable_background_green[4]};
|
background-color: ${props.theme.designtable_background_cyan[2]};
|
||||||
`}
|
`}
|
||||||
|
|
||||||
${(props) =>
|
${(props) =>
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
props.isDragTarget &&
|
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);
|
setSourceDragColumn(dragData);
|
||||||
e.dataTransfer.setData('designer_column_drag_data', JSON.stringify(dragData));
|
e.dataTransfer.setData('designer_column_drag_data', JSON.stringify(dragData));
|
||||||
}}
|
}}
|
||||||
|
onDragEnd={(e) => {
|
||||||
|
setTargetDragColumn(null);
|
||||||
|
setSourceDragColumn(null);
|
||||||
|
}}
|
||||||
onDragOver={(e) => {
|
onDragOver={(e) => {
|
||||||
if (sourceDragColumn) {
|
if (sourceDragColumn) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const ContextMenuStyled = styled.ul`
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
min-width: 160px;
|
min-width: 160px;
|
||||||
z-index: 1050;
|
z-index: 1050;
|
||||||
|
cursor: default;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const KeyTextSpan = styled.span`
|
const KeyTextSpan = styled.span`
|
||||||
|
|||||||
Reference in New Issue
Block a user