Skip to content

Commit 96daa00

Browse files
author
Mark Robinson
committed
Fix various bugs in selection of nodes/rows
Panning triggered click event, full screen graph created duplicate IDs, scrolling caused page scroll due to lack of preventDefault
1 parent 9bab060 commit 96daa00

File tree

3 files changed

+40
-17
lines changed

3 files changed

+40
-17
lines changed

src/main/resources/static/css/main.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,15 @@ body {
157157
}
158158

159159
tr.selected, .table-hover tbody tr.selected:hover td, .table-hover tbody tr.selected:hover th {
160-
background-color: #adffaf !important;
160+
background-color: #b9ffbb !important;
161161
}
162162

163163
tr.hover, .table-hover tbody tr:hover td, .table-hover tbody tr:hover th {
164164
background-color: #c9ffcb !important;
165165
}
166166

167167
polygon.selected, polygon.hover.selected {
168-
fill: #adffaf;
168+
fill: #b9ffbb;
169169
}
170170

171171
polygon.hover {

src/main/resources/static/js/workflow.js

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ requirejs.config({
4343
* Make the graph pannable and zoomable
4444
*/
4545
require(['jquery', 'bootstrap.modal', 'svg-pan-zoom', 'hammerjs', 'jquery.svg'],
46-
function ($, modal, svgPanZoom, hammerjs) {
46+
function ($, modal, svgPanZoom, Hammer) {
4747
/**
4848
* Custom hammer event handler to add mobile support
4949
* Based on example in svg-pan-zoom/demo/mobile.html
@@ -106,9 +106,6 @@ require(['jquery', 'bootstrap.modal', 'svg-pan-zoom', 'hammerjs', 'jquery.svg'],
106106
loadURL: $("#graph").attr("data-svgurl"),
107107
onLoad: enablePanZoom
108108
});
109-
/*$("#graphFullscreen").svg({
110-
loadURL: $("#graph").attr("data-svgurl")
111-
});*/
112109

113110
/**
114111
* Enable svg-pan-zoom on the graph
@@ -117,8 +114,12 @@ require(['jquery', 'bootstrap.modal', 'svg-pan-zoom', 'hammerjs', 'jquery.svg'],
117114
var graph = svgPanZoom('#graph svg', {
118115
zoomEnabled: true,
119116
controlIconsEnabled: true,
120-
customEventsHandler: eventHandler,
121-
preventMouseEventsDefault: false
117+
customEventsHandler: eventHandler
118+
});
119+
120+
// Add deselect to reset control
121+
$("#svg-pan-zoom-reset-pan-zoom").click(function() {
122+
$("polygon.selected, tr.selected").removeClass("selected");
122123
});
123124

124125
// Resizing window also resizes the graph
@@ -132,7 +133,7 @@ require(['jquery', 'bootstrap.modal', 'svg-pan-zoom', 'hammerjs', 'jquery.svg'],
132133
$('#fullScreenGraphModal').on('shown.bs.modal', function (e) {
133134
// Timeout allows for modal to show
134135
setTimeout(function() {
135-
var fullGraph = svgPanZoom('#graphFullscreen svg', {
136+
var fullGraph = svgPanZoom('#graphFullscreen', {
136137
zoomEnabled: true,
137138
controlIconsEnabled: true,
138139
customEventsHandler: eventHandler
@@ -261,10 +262,12 @@ require(['jquery', 'jquery.svg', 'jquery.svgdom'],
261262
*/
262263
$("tr").not('thead tr').on({
263264
click: function(event) {
265+
var matchingGraphBox = getGraphBox(this);
264266
if (!event.ctrlKey) {
265-
$("polygon.selected, tr.selected").not($(this)).removeClass("selected");
267+
$("polygon.selected, tr.selected").not($(this))
268+
.not(matchingGraphBox).removeClass("selected");
266269
}
267-
getGraphBox(this).toggleClass("selected");
270+
matchingGraphBox.toggleClass("selected");
268271
$(this).toggleClass("selected");
269272
},
270273
mouseenter: function() {
@@ -290,17 +293,35 @@ require(['jquery', 'jquery.svg', 'jquery.svgdom'],
290293
});
291294
}
292295

296+
/**
297+
* Keep track of whether the graph is being dragged to
298+
* be able to disable click events during pan
299+
*/
300+
var draggingGraph = false;
301+
$(document).on({
302+
mousedown: function() {
303+
draggingGraph = false;
304+
},
305+
mousemove: function() {
306+
draggingGraph = true;
307+
}
308+
}, "#graph");
309+
293310
/**
294311
* When a graph box is hovered over/clicked, highlight
295312
*/
296313
$(document).on({
297314
click: function(event) {
298-
var thisPolygon = $(this).find("polygon");
299-
if (!event.ctrlKey) {
300-
$("polygon.selected, tr.selected").not(thisPolygon).removeClass("selected");
315+
if (!draggingGraph) {
316+
var thisPolygon = $(this).find("polygon");
317+
var matchingTableRow = getTableRow(this);
318+
if (!event.ctrlKey) {
319+
$("polygon.selected, tr.selected").not(thisPolygon)
320+
.not(matchingTableRow).removeClass("selected");
321+
}
322+
matchingTableRow.toggleClass("selected");
323+
thisPolygon.toggleClass("selected");
301324
}
302-
getTableRow(this).toggleClass("selected");
303-
thisPolygon.toggleClass("selected");
304325
},
305326
mouseenter: function() {
306327
getTableRow(this).addClass("hover");

src/main/resources/templates/workflow.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ <h4 class="modal-title" id="fullScreenGraphLabel">Workflow Graph</h4>
111111
</div>
112112
<div class="modal-body">
113113
<span id="fullscreen-close" data-dismiss="modal" class="close glyphicon glyphicon-resize-small graphControl" data-tooltip="true" title="Close"></span>
114-
<div id="graphFullscreen"></div>
114+
<object id="graphFullscreen" th:data="@{'/workflows/' + ${workflow.id} + '/graph/svg'}" type="image/svg+xml">
115+
<img th:src="@{'/workflows/' + ${workflow.id} + '/graph/png'}" alt="fullscreen" />
116+
</object>
115117
</div>
116118
</div>
117119
</div>

0 commit comments

Comments
 (0)