Fix add links.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
mindplot.commands.AddLinkToTopicCommand = new Class({
|
||||
mindplot.commands.ChangeLinkToTopicCommand = new Class({
|
||||
Extends:mindplot.Command,
|
||||
initialize: function(topicId, url) {
|
||||
$assert(topicId, 'topicId can not be null');
|
||||
@@ -24,12 +24,25 @@ mindplot.commands.AddLinkToTopicCommand = new Class({
|
||||
this._url = url;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
topic.addLink(this._url, commandContext._designer);
|
||||
if (topic.hasLink()) {
|
||||
var model = topic.getModel();
|
||||
var link = model.getLinks()[0];
|
||||
this._oldUrl = link.getUrl();
|
||||
topic.removeLink();
|
||||
}
|
||||
topic.addLink(this._url);
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
topic.removeLink();
|
||||
if (this._oldtext) {
|
||||
topic.removeLink();
|
||||
topic.addLink(this._oldUrl);
|
||||
} else {
|
||||
topic.removeLink();
|
||||
}
|
||||
}
|
||||
});
|
@@ -25,7 +25,8 @@ mindplot.commands.ChangeNoteToTopicCommand = new Class({
|
||||
this._oldtext = null;
|
||||
this._id = mindplot.Command._nextUUID();
|
||||
},
|
||||
execute: function(commandContext) {
|
||||
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
if (topic.hasNote()) {
|
||||
var model = topic.getModel();
|
||||
@@ -35,6 +36,7 @@ mindplot.commands.ChangeNoteToTopicCommand = new Class({
|
||||
}
|
||||
topic.addNote(this._text);
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
if (this._oldtext) {
|
||||
|
@@ -22,11 +22,15 @@ mindplot.commands.RemoveLinkFromTopicCommand = new Class({
|
||||
$assert(topicId, 'topicId can not be null');
|
||||
this._objectsIds = topicId;
|
||||
},
|
||||
|
||||
execute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
this._url = topic._link.getUrl();
|
||||
var model = topic.getModel();
|
||||
var links = model.getLinks()[0];
|
||||
this._text = links.getUrl();
|
||||
topic.removeLink();
|
||||
},
|
||||
|
||||
undoExecute: function(commandContext) {
|
||||
var topic = commandContext.findTopics(this._objectsIds)[0];
|
||||
topic.addLink(this._url, commandContext._designer);
|
||||
|
Reference in New Issue
Block a user