- Add delete button to remove relationship

- Fix add button in the toolbar.
This commit is contained in:
Paulo Gustavo Veiga 2012-07-16 00:15:59 -03:00
parent 16bbc0a456
commit f449eff9ce
3 changed files with 40 additions and 27 deletions

View File

@ -661,12 +661,30 @@ mindplot.Designer = new Class({
// Build relationship line ....
var result = new mindplot.Relationship(sourceTopic, targetTopic, model);
result.addEvent('onfocus', function (event) {
this.onObjectFocusEvent(result, event);
result.addEvent('ontblur', function () {
var topics = this.getModel().filterSelectedTopics();
var rels = this.getModel().filterSelectedRelationships();
if (topics.length == 0 || rels.length == 0) {
this.fireEvent('onblur');
}
}.bind(this));
result.addEvent('ontfocus', function () {
var topics = this.getModel().filterSelectedTopics();
var rels = this.getModel().filterSelectedRelationships();
if (topics.length == 1 || rels.length == 1) {
this.fireEvent('onfocus');
}
}.bind(this));
// Append it to the workspace ...
dmodel.addRelationship(result);
return result;
},

View File

@ -202,8 +202,7 @@ mindplot.Relationship = new Class({
this._controlPointsController.setVisibility(focus);
this._onFocus = focus;
console.log("foucus:....");
this.fireEvent(focus ? 'ontfocus' : 'ontblur', this);
}
},
@ -316,5 +315,10 @@ mindplot.Relationship = new Class({
getId:function () {
return this._model.getId();
},
fireEvent:function (type, event) {
var elem = this._line2d;
elem.fireEvent(type, event);
}
});

View File

@ -268,7 +268,7 @@ mindplot.widget.Menu = new Class({
}.bind(this));
}
this._addButton('addTopics', true, false, function () {
this._addButton('addTopic', true, false, function () {
designer.createChildForSelectedNode();
});
this._registerTooltip('addTopics', $msg('ADD_TOPIC'), "Enter");
@ -459,25 +459,14 @@ mindplot.widget.Menu = new Class({
var rels = designer.getModel().filterSelectedRelationships();
this._toolbarElems.each(function (button) {
var buttonId = button.getButtonId();
if (buttonId != "undoEdition" && buttonId != "redoEdition") {
var isTopicAction = button.isTopicAction();
var isRelAction = button.isRelAction();
var disable = false;
if (button.isTopicAction() && button.isRelAction()) {
disable = rels.length == 0 && topics.length == 0;
} else if (!button.isTopicAction() && !button.isRelAction()) {
disable = false;
}
else if (button.isTopicAction() && topics.length == 0) {
disable = true;
} else if (button.isRelAction() && rels.length == 0) {
disable = true;
}
if (disable) {
button.disable();
} else {
if (isTopicAction || isRelAction) {
if ((isTopicAction && topics.length != 0) || (isRelAction && rels.length != 0)) {
button.enable();
} else {
button.disable();
}
}
})
@ -488,14 +477,16 @@ mindplot.widget.Menu = new Class({
var rels = designer.getModel().filterSelectedRelationships();
this._toolbarElems.each(function (button) {
var buttonId = button.getButtonId();
if (buttonId != "undoEdition" && buttonId != "redoEdition") {
var isTopicAction = button.isTopicAction();
var isRelAction = button.isRelAction();
if (button.isTopicAction() && topics.length > 0) {
if (isTopicAction || isRelAction) {
if (isTopicAction && topics.length > 0) {
button.enable();
}
if (button.isRelAction() && rels.length > 0) {
if (isRelAction && rels.length > 0) {
button.enable();
}
}