From 1e5e11a30905c63e80ecd5072ea0d6c5071f014d Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Thu, 27 Sep 2012 20:18:12 -0300 Subject: [PATCH] - Fix wrong state issue when the topic is restored. --- mindplot/src/main/javascript/Designer.js | 8 ++------ .../src/main/javascript/StandaloneActionDispatcher.js | 4 ++-- mindplot/src/main/javascript/Topic.js | 8 +++----- mindplot/src/main/javascript/commands/DeleteCommand.js | 5 +++++ 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/mindplot/src/main/javascript/Designer.js b/mindplot/src/main/javascript/Designer.js index b3018be1..f2be351f 100644 --- a/mindplot/src/main/javascript/Designer.js +++ b/mindplot/src/main/javascript/Designer.js @@ -116,7 +116,6 @@ mindplot.Designer = new Class({ }, - addEvent:function (type, listener) { if (type == mindplot.TopicEvent.EDIT || type == mindplot.TopicEvent.CLICK) { var editor = mindplot.TopicEventDispatcher.getInstance(); @@ -207,12 +206,8 @@ mindplot.Designer = new Class({ _buildNodeGraph:function (model, readOnly) { - var workspace = this._workspace; - // Create node graph ... var topic = mindplot.NodeGraph.create(model, {readOnly:readOnly}); - - // Append it to the workspace ... this.getModel().addTopic(topic); // Add Topic events ... @@ -248,7 +243,7 @@ mindplot.Designer = new Class({ } } $assert(targetTopic, "Could not find a topic to connect"); - topic.connectTo(targetTopic, workspace); + topic.connectTo(targetTopic, this._workspace); } topic.addEvent('ontblur', function () { @@ -602,6 +597,7 @@ mindplot.Designer = new Class({ }); var nodeGraph = this._buildNodeGraph(nodeModel, this.isReadOnly()); + nodeGraph.setVisibility(false); this._workspace.appendChild(nodeGraph); for (var i = 0; i < children.length; i++) { diff --git a/mindplot/src/main/javascript/StandaloneActionDispatcher.js b/mindplot/src/main/javascript/StandaloneActionDispatcher.js index fb33988e..4d648740 100644 --- a/mindplot/src/main/javascript/StandaloneActionDispatcher.js +++ b/mindplot/src/main/javascript/StandaloneActionDispatcher.js @@ -269,8 +269,8 @@ mindplot.CommandContext = new Class({ return mindmap.createNode(mindplot.NodeModel.MAIN_TOPIC_TYPE); }, - connect:function (childTopic, parentTopic, isVisible) { - childTopic.connectTo(parentTopic, this._designer._workspace, isVisible); + connect:function (childTopic, parentTopic) { + childTopic.connectTo(parentTopic, this._designer._workspace); }, disconnect:function (topic) { diff --git a/mindplot/src/main/javascript/Topic.js b/mindplot/src/main/javascript/Topic.js index 17d4c29e..5fb97820 100644 --- a/mindplot/src/main/javascript/Topic.js +++ b/mindplot/src/main/javascript/Topic.js @@ -1023,7 +1023,7 @@ mindplot.Topic = new Class({ model.setOrder(value); }, - connectTo:function (targetTopic, workspace, isVisible) { + connectTo:function (targetTopic, workspace) { $assert(!this._outgoingLine, 'Could not connect an already connected node'); $assert(targetTopic != this, 'Circular connection are not allowed'); $assert(targetTopic, 'Parent Graph can not be null'); @@ -1040,9 +1040,8 @@ mindplot.Topic = new Class({ // Create a connection line ... var outgoingLine = new mindplot.ConnectionLine(this, targetTopic); - if ($defined(isVisible)) { - outgoingLine.setVisibility(isVisible); - } + outgoingLine.setVisibility(this.isVisible()); + this._outgoingLine = outgoingLine; workspace.appendChild(outgoingLine); @@ -1074,7 +1073,6 @@ mindplot.Topic = new Class({ if (this.isInWorkspace()) { mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeConnectEvent, {parentNode:targetTopic.getModel(), childNode:this.getModel()}); } - }, appendChild:function (child) { diff --git a/mindplot/src/main/javascript/commands/DeleteCommand.js b/mindplot/src/main/javascript/commands/DeleteCommand.js index 3eb366f3..94f1918d 100644 --- a/mindplot/src/main/javascript/commands/DeleteCommand.js +++ b/mindplot/src/main/javascript/commands/DeleteCommand.js @@ -96,6 +96,11 @@ mindplot.commands.DeleteCommand = new Class({ commandContext.addRelationship(model); }.bind(this)); + // Finally display the topics ... + this._deletedTopicModels.each(function (topicModel) { + var topics = commandContext.findTopics(topicModel.getId()); + topics[0].setBranchVisibility(true); + }, this); // Focus on last recovered topic .. if (this._deletedTopicModels.length > 0) {