Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.editor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.editor
Commits
c2bb9d2a
Commit
c2bb9d2a
authored
6 years ago
by
Jaden DIEFENBAUGH
Browse files
Options
Downloads
Patches
Plain Diff
let user click on output/input to create conn, closes
#79
parent
134e1a10
No related branches found
No related tags found
1 merge request
!27
Toolchain Editor UX Improvements
Pipeline
#24513
passed
6 years ago
Stage: build
Stage: browser-tests
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
conda/js/src/components/toolchain/GraphicalEditor.jsx
+62
-27
62 additions, 27 deletions
conda/js/src/components/toolchain/GraphicalEditor.jsx
with
62 additions
and
27 deletions
conda/js/src/components/toolchain/GraphicalEditor.jsx
+
62
−
27
View file @
c2bb9d2a
...
@@ -510,7 +510,9 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> {
...
@@ -510,7 +510,9 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> {
},
50
);
},
50
);
};
};
// d3 behaviour for dragging lines from an output to an input and creating a connection
// d3 behaviour for connecting an output and input and creating a connection
// allows users to drag from output to input,
// or click an output and click an input
initD3Connections
=
()
=>
{
initD3Connections
=
()
=>
{
// creating connections
// creating connections
setTimeout
(()
=>
{
setTimeout
(()
=>
{
...
@@ -519,8 +521,17 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> {
...
@@ -519,8 +521,17 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> {
const
channelColors
=
this
.
props
.
repData
.
channel_colors
;
const
channelColors
=
this
.
props
.
repData
.
channel_colors
;
const
{
datasets
,
blocks
}
=
this
.
props
;
const
{
datasets
,
blocks
}
=
this
.
props
;
let
startBlock
;
let
startBlock
;
// the user has started dragging from an output block
let
startX
=
0
;
let
startY
=
0
;
// the user has started dragging from an output block,
// or it might be starting a click event!
// to see if the user is clicking or dragging,
// check in endDrag() if the distance travelled is small
// enough to be considered a click or not
function
startDrag
(
d
)
{
function
startDrag
(
d
)
{
console
.
log
(
'
startDrag
'
);
startX
=
d3
.
event
.
x
;
startY
=
d3
.
event
.
y
;
// find the block that the user started from
// find the block that the user started from
const
rawId
=
d3
.
select
(
this
).
attr
(
'
id
'
);
const
rawId
=
d3
.
select
(
this
).
attr
(
'
id
'
);
const
bName
=
rawId
.
split
(
'
-output-
'
)[
0
];
const
bName
=
rawId
.
split
(
'
-output-
'
)[
0
];
...
@@ -533,37 +544,57 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> {
...
@@ -533,37 +544,57 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> {
.
append
(
'
line
'
)
.
append
(
'
line
'
)
.
classed
(
'
tmp
'
,
true
)
.
classed
(
'
tmp
'
,
true
)
.
attr
(
'
stroke
'
,
'
black
'
)
.
attr
(
'
stroke
'
,
'
black
'
)
.
attr
(
'
x1
'
,
d3
.
event
.
x
)
.
attr
(
'
x1
'
,
startX
)
.
attr
(
'
y1
'
,
d3
.
event
.
y
)
.
attr
(
'
y1
'
,
startY
)
.
attr
(
'
x2
'
,
d3
.
event
.
x
)
.
attr
(
'
x2
'
,
startX
)
.
attr
(
'
y2
'
,
d3
.
event
.
y
);
.
attr
(
'
y2
'
,
startY
);
}
}
// create a connection if the user ended the drag on an input block,
const
processEndBlock
=
(
endInput
:
HTMLElement
)
=>
{
// else just remove the temp svg line
function
endDrag
()
{
const
{
x
,
y
}
=
d3
.
event
;
d3
.
select
(
'
.tmp
'
)
.
remove
();
if
(
!
startBlock
)
if
(
!
startBlock
)
return
;
return
;
// with the location of the end event,
console
.
log
(
endInput
);
// compare the location to the location & dims of all input blocks
// in the svg.
const
endInput
=
Array
.
from
(
document
.
querySelectorAll
(
'
.iBlock
'
))
.
find
(
n
=>
{
const
nx
=
n
.
x
.
baseVal
.
value
;
const
ny
=
n
.
y
.
baseVal
.
value
;
const
width
=
n
.
width
.
baseVal
.
value
;
const
height
=
n
.
height
.
baseVal
.
value
;
return
nx
<=
x
&&
x
<=
nx
+
width
&&
ny
<=
y
&&
y
<=
ny
+
height
;
});
if
(
endInput
===
undefined
)
return
;
const
endId
=
endInput
.
id
.
replace
(
'
-input-
'
,
'
.
'
);
const
endId
=
endInput
.
id
.
replace
(
'
-input-
'
,
'
.
'
);
// create a new connection
// create a new connection
assuming theres a given func that does it
if
(
createConnection
)
if
(
createConnection
)
createConnection
(
startId
,
endId
,
startBlock
.
synchronized_channel
||
startBlock
.
name
);
createConnection
(
startId
,
endId
,
startBlock
.
synchronized_channel
||
startBlock
.
name
);
startBlock
=
undefined
;
};
// create a connection if the user ended the drag on an input block,
// else just remove the temp svg line
function
endDrag
(
d
)
{
//console.log('endDrag');
const
{
x
,
y
}
=
d3
.
event
;
if
(
Math
.
abs
(
startX
-
x
)
<
10
&&
Math
.
abs
(
startY
-
y
)
<
10
)
{
// click event not drag
}
else
{
// probably not a click event
d3
.
select
(
'
.tmp
'
).
remove
();
// with the location of the end event,
// compare the location to the location & dims of all input blocks
// in the svg.
const
endInput
=
Array
.
from
(
document
.
querySelectorAll
(
'
.iBlock
'
))
.
find
(
n
=>
{
const
nx
=
n
.
x
.
baseVal
.
value
;
const
ny
=
n
.
y
.
baseVal
.
value
;
const
width
=
n
.
width
.
baseVal
.
value
;
const
height
=
n
.
height
.
baseVal
.
value
;
return
nx
<=
x
&&
x
<=
nx
+
width
&&
ny
<=
y
&&
y
<=
ny
+
height
;
});
if
(
endInput
===
undefined
){
startBlock
=
undefined
;
}
else
{
processEndBlock
(
endInput
);
}
}
}
// create a connection if the user clicked an input block,
// else just reset the startBlock
function
endClick
()
{
processEndBlock
(
this
);
}
}
// update the temp line
// update the temp line
...
@@ -573,12 +604,16 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> {
...
@@ -573,12 +604,16 @@ export default class GraphicalEditor extends React.PureComponent<Props, State> {
.
attr
(
'
y2
'
,
d3
.
event
.
y
);
.
attr
(
'
y2
'
,
d3
.
event
.
y
);
}
}
d3
.
selectAll
(
'
.oBlock
'
).
call
(
d3
.
selectAll
(
'
.oBlock
'
)
.
call
(
d3
.
drag
()
d3
.
drag
()
.
on
(
'
start
'
,
startDrag
)
.
on
(
'
start
'
,
startDrag
)
.
on
(
'
end
'
,
endDrag
)
.
on
(
'
end
'
,
endDrag
)
.
on
(
'
drag
'
,
dragged
)
.
on
(
'
drag
'
,
dragged
)
);
);
d3
.
selectAll
(
'
.iBlock
'
)
.
on
(
'
click
'
,
endClick
);
},
50
);
},
50
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment