Skip to content

Commit

Permalink
Added pivoting btwn op defs and pipeline. Fixes #232
Browse files Browse the repository at this point in the history
WIP #232 Added jump to op def button in selection

WIP #232 Added returning to pipeline
  • Loading branch information
brollb committed Jun 8, 2016
1 parent ab3ba50 commit 57a60d6
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/visualizers/panels/ForgeActionButton/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ define([
});
};

var returnToLastPipeline = () =>
WebGMEGlobal.State.registerActiveObject(window.DeepForge.lastPipeline);
return {
// Meta nodes
MyPipelines_META: [
Expand Down Expand Up @@ -215,6 +217,14 @@ define([
action: uploadArtifact
}
],
Operation_META: [
{
name: 'Return to Pipeline',
icon: 'input',
filter: () => window.DeepForge && window.DeepForge.lastPipeline,
action: returnToLastPipeline
}
],

// Instances
Data: [
Expand Down
9 changes: 7 additions & 2 deletions src/visualizers/panels/ForgeActionButton/ForgeActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ define([
base = this.client.getNode(node.getMetaTypeId()),
isMeta = base && base.getId() === node.getId(),
suffix = isMeta ? '_META' : '',
actions,
basename;

while (base && !ACTIONS[basename]) {
while (base && !(actions && actions.length)) {
basename = base.getAttribute('name') + suffix;
base = this.client.getNode(base.getBaseId());
actions = ACTIONS[basename];
if (actions) {
actions = actions.filter(action => !action.filter || action.filter());
}
}

return ACTIONS[basename] || [];
return actions || [];
};

ForgeActionButton.prototype.onNodeLoad = function(nodeId) {
Expand Down
82 changes: 82 additions & 0 deletions src/visualizers/widgets/PipelineEditor/Buttons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*globals define, WebGMEGlobal*/
define([
'widgets/EasyDAG/Buttons'
], function(
EasyDAGButtons
) {

// Create a GoToBase button
var client = WebGMEGlobal.Client,
LocalOps = {
ArtifactLoader: true,
Save: true
};

var GoToBase = function(params) {
// Check if it should be disabled
var baseId = this._getBaseId(params.item),
base = client.getNode(baseId);

params.disabled = base ? base.isLibraryElement() : false;
EasyDAGButtons.ButtonBase.call(this, params);
};

GoToBase.SIZE = 10;
GoToBase.BORDER = 5;
GoToBase.prototype.BTN_CLASS = 'add';
GoToBase.prototype = new EasyDAGButtons.ButtonBase();

GoToBase.prototype._render = function() {
var lineRadius = GoToBase.SIZE - GoToBase.BORDER,
btnColor = '#90caf9',
lineColor = '#7986cb';

if (this.disabled) {
btnColor = '#e0e0e0';
lineColor = '#9e9e9e';
}

this.$el
.append('circle')
.attr('r', GoToBase.SIZE)
.attr('fill', btnColor);

this.$el
.append('circle')
//.attr('cx', -)
//.attr('cy', 0)
.attr('r', GoToBase.SIZE/3)
.attr('stroke-width', 3)
.attr('stroke', lineColor);

this.$el
.append('line')
.attr('y1', 0)
.attr('y2', 0)
.attr('x1', -lineRadius)
.attr('x2', lineRadius)
.attr('stroke-width', 3)
.attr('stroke', lineColor);

};

GoToBase.prototype._onClick = function(item) {
var node = client.getNode(item.id),
baseId = node.getBaseId();

window.DeepForge = window.DeepForge || {};
window.DeepForge.lastPipeline = item.desc.parentId;

WebGMEGlobal.State.registerActiveObject(baseId);
};

GoToBase.prototype._getBaseId = function(item) {
var n = client.getNode(item.id);
return n.getBaseId();
};

return {
DeleteOne: EasyDAGButtons.DeleteOne,
GoToBase: GoToBase
};
});
13 changes: 11 additions & 2 deletions src/visualizers/widgets/PipelineEditor/SelectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

define([
'widgets/EasyDAG/SelectionManager',
'widgets/EasyDAG/Buttons',
'./Buttons',
'underscore'
], function(
EasyDAGSelectionManager,
Expand All @@ -17,7 +17,7 @@ define([

_.extend(SelectionManager.prototype, EasyDAGSelectionManager.prototype);

SelectionManager.prototype.createActionButtons = function(/*width, height*/) {
SelectionManager.prototype.createActionButtons = function(width/*, height*/) {
// move the 'x' to the top left
new Buttons.DeleteOne({
context: this._widget,
Expand All @@ -26,6 +26,15 @@ define([
x: 0,
y: 0
});
// If the operation has a user-defined base type,
// show a button for jumping to the base def
new Buttons.GoToBase({
context: this._widget,
$pEl: this.$selection,
item: this.selectedItem,
x: width,
y: 0
});
};

SelectionManager.prototype.deselect = function() {
Expand Down

0 comments on commit 57a60d6

Please sign in to comment.