Skip to content

Commit 6d35c25

Browse files
authored
Add compat for drag-and-drop with webgme's default layout. Closes #1171 (#1172)
* Add compat for drag-and-drop with webgme's default layout. Closes #1171 * WIP #1171 improved drag-and-drop sensitivity
1 parent d923594 commit 6d35c25

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/visualizers/panels/PipelineIndex/PipelineIndexControl.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
/*jshint browser: true*/
33

44
define([
5+
'js/DragDrop/DragHelper',
56
'js/Constants',
67
'js/NodePropertyNames'
78
], function (
9+
DragHelper,
810
CONSTANTS,
911
nodePropertyNames
1012
) {
@@ -72,6 +74,22 @@ define([
7274
this._client.completeTransaction();
7375
}
7476
};
77+
78+
this._widget.onBackgroundDrop = (event, dragInfo) => {
79+
if (!this._currentNodeId) { // no active node. Cannot add pipeline
80+
return;
81+
}
82+
const effects = DragHelper.getDragEffects(dragInfo);
83+
const items = DragHelper.getDragItems(dragInfo);
84+
85+
if (effects.includes(DragHelper.DRAG_EFFECTS.DRAG_CREATE_INSTANCE)) {
86+
const parentId = this._currentNodeId;
87+
const msg = `Creating ${items.length} new pipeline(s)`;
88+
this._client.startTransaction(msg);
89+
items.forEach(baseId => this._client.createNode({parentId, baseId}));
90+
this._client.completeTransaction();
91+
}
92+
};
7593
};
7694

7795
/* * * * * * * * Visualizer content update callbacks * * * * * * * */

src/visualizers/widgets/PipelineIndex/PipelineIndexWidget.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
/*jshint browser: true*/
33

44
define([
5+
'js/DragDrop/DropTarget',
56
'text!./cards/Pipeline.ejs',
67
'text!./cards/Architecture.ejs',
78
'underscore',
89
'css!./styles/PipelineIndexWidget.css'
910
], function (
11+
DropTarget,
1012
PipelineHtml,
1113
ArchitectureHtml,
1214
_
@@ -34,11 +36,11 @@ define([
3436
this.$backgroundText = null;
3537
this.updateBackgroundText();
3638

37-
this._initializeEventHandlers();
39+
this._initializeEventHandlers(container);
3840
this.logger.debug('ctor finished');
3941
};
4042

41-
PipelineIndexWidget.prototype._initializeEventHandlers = function () {
43+
PipelineIndexWidget.prototype._initializeEventHandlers = function (container) {
4244
this.$el.on('click', '.open-pipeline', this.openPipeline);
4345
this.$el.on('click', '.preview.card-image', this.openPipeline);
4446

@@ -60,6 +62,12 @@ define([
6062
}
6163
});
6264
});
65+
66+
DropTarget.makeDroppable(container, {
67+
drop: (event, dragInfo) => {
68+
this.onBackgroundDrop(event, dragInfo);
69+
}
70+
});
6371
};
6472

6573
PipelineIndexWidget.prototype.getEmptyMsg = function() {

0 commit comments

Comments
 (0)