Merge pull request #234 from dfst/232-jump-to-op-def
Added pivoting btwn op defs and pipeline. Fixes #232
Esse commit está contido em:
@@ -178,6 +178,8 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
var returnToLastPipeline = () =>
|
||||
WebGMEGlobal.State.registerActiveObject(window.DeepForge.lastPipeline);
|
||||
return {
|
||||
// Meta nodes
|
||||
MyPipelines_META: [
|
||||
@@ -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: [
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
};
|
||||
});
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
define([
|
||||
'widgets/EasyDAG/SelectionManager',
|
||||
'widgets/EasyDAG/Buttons',
|
||||
'./Buttons',
|
||||
'underscore'
|
||||
], function(
|
||||
EasyDAGSelectionManager,
|
||||
@@ -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,
|
||||
@@ -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() {
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário