Skip to content

Commit

Permalink
Added 'Create Class' node in OperationEditor. Fixes #171
Browse files Browse the repository at this point in the history
WIP #171 Adding support for new classes

WIP #171. Fixed "New Class" tooltip

WIP #171 Fixed eslint error
  • Loading branch information
brollb committed Jun 29, 2016
1 parent e30ebf3 commit 5fba36b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ define([
OpIntDecorator.prototype.initialize = function() {
if (this._node.baseName === 'Operation') {
this.color = '#2196f3';
} else {
} else if (this._node.baseName) {
// On hover, show the type
this.enableTooltip(this._node.baseName, 'dark');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ define([
this._widget.addRefTo = this.addRefTo.bind(this);
this._widget.changePtrName = this.changePtrName.bind(this);
this._widget.removePtr = this.removePtr.bind(this);
this._widget.getNewClassNode = this.getNewClassNode.bind(this);
};

OperationInterfaceEditorEvents.prototype.getNewClassNode = function(id) {
var Decorator = this._client.decoratorManager.getDecoratorForWidget(
this.DEFAULT_DECORATOR, 'EasyDAG');

return {
node: {
id: id,
class: 'create-node',
name: 'New Class...',
Decorator: Decorator,
attributes: {}
}
};
};

OperationInterfaceEditorEvents.prototype.allValidReferences = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
*/

define([
'deepforge/globals',
'widgets/EasyDAG/EasyDAGWidget',
'widgets/EasyDAG/AddNodeDialog',
'./SelectionManager',
'./Item',
'underscore',
'css!./styles/OperationInterfaceEditorWidget.css'
], function (
DeepForge,
EasyDAG,
AddNodeDialog,
SelectionManager,
Expand All @@ -22,7 +24,8 @@ define([
'use strict';

var OperationInterfaceEditorWidget,
WIDGET_CLASS = 'operation-interface-editor';
WIDGET_CLASS = 'operation-interface-editor',
NEW_CLASS_ID = '__NEW_CLASS__';

OperationInterfaceEditorWidget = function (logger, container) {
EasyDAG.call(this, logger, container);
Expand All @@ -45,22 +48,19 @@ define([

OperationInterfaceEditorWidget.prototype.onAddButtonClicked = function(item, isInput) {
var successorPairs = this.getValidSuccessorNodes(item.id),
successor = successorPairs[0];
newClass = this.getNewClassNode(NEW_CLASS_ID);

if (successorPairs.length > 1) {
// Create the modal view with all possible subsequent nodes
var dialog = new AddNodeDialog(),
title = this._getAddSuccessorTitle(item);
// Add the 'Create Class' node
successorPairs.push(newClass);

dialog.show(title, successorPairs);
dialog.onSelect = pair => {
if (pair) {
this.onAddItemSelected(pair, isInput);
AddNodeDialog.prompt(successorPairs)
.then(selected => {
if (selected.node.id === NEW_CLASS_ID) {
DeepForge.create.Complex();
} else {
this.onAddItemSelected(selected, isInput);
}
};
} else if (successor) {
this.onAddItemSelected(successor, isInput);
}
});
};

OperationInterfaceEditorWidget.prototype.onDeactivate = function() {
Expand Down

0 comments on commit 5fba36b

Please sign in to comment.