mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-09-12 07:10:07 +02:00
- Add delete button to remove relationship
- Fix add button in the toolbar.
This commit is contained in:
parent
16bbc0a456
commit
f449eff9ce
@ -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;
|
||||
},
|
||||
|
||||
|
@ -21,7 +21,7 @@ mindplot.Relationship = new Class({
|
||||
getStrokeColor:function () {
|
||||
return '#9b74e6';
|
||||
},
|
||||
type: "Relationship"
|
||||
type:"Relationship"
|
||||
},
|
||||
initialize:function (sourceNode, targetNode, model) {
|
||||
$assert(sourceNode, "sourceNode can not be null");
|
||||
@ -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);
|
||||
}
|
||||
});
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user