Commit 51eaa58a authored by techird's avatar techird

Merge branch 'dev' of https://github.com/fex-team/kityminder-core into dev

parents 534574da 1cb43263
...@@ -509,7 +509,7 @@ define(function(require, exports, module) { ...@@ -509,7 +509,7 @@ define(function(require, exports, module) {
} }
apply(root, root.parent ? root.parent.getGlobalLayoutTransform() : new kity.Matrix()); apply(root, root.parent ? root.parent.getGlobalLayoutTransform() : new kity.Matrix());
return this; return this;
}, }
}); });
module.exports = Layout; module.exports = Layout;
......
...@@ -77,7 +77,8 @@ define(function(require, exports, module) { ...@@ -77,7 +77,8 @@ define(function(require, exports, module) {
}, },
queryState: function(km) { queryState: function(km) {
return km.getSelectedNode() ? 0 : -1; var node = km.getSelectedNode();
return node && !node.isRoot() && !node.isExpanded() ? 0 : -1;
} }
}); });
...@@ -100,6 +101,31 @@ define(function(require, exports, module) { ...@@ -100,6 +101,31 @@ define(function(require, exports, module) {
enableReadOnly: true enableReadOnly: true
}); });
/**
* @command Collapse
* @description 收起当前节点的子树
* @state
* 0: 当前有选中的节点
* -1: 当前没有选中的节点
*/
var CollapseCommand = kity.createClass('CollapseCommand', {
base: Command,
execute: function(km) {
var node = km.getSelectedNode();
if (!node) return;
node.collapse();
node.renderTree();
km.layout();
},
queryState: function(km) {
var node = km.getSelectedNode();
return node && !node.isRoot() && node.isExpanded() ? 0 : -1;
}
});
var Expander = kity.createClass('Expander', { var Expander = kity.createClass('Expander', {
base: kity.Group, base: kity.Group,
...@@ -175,10 +201,12 @@ define(function(require, exports, module) { ...@@ -175,10 +201,12 @@ define(function(require, exports, module) {
this.expander.setTranslate(position); this.expander.setTranslate(position);
} }
}); });
return { return {
commands: { commands: {
'expand': ExpandCommand, 'expand': ExpandCommand,
'expandtolevel': ExpandToLevelCommand 'expandtolevel': ExpandToLevelCommand,
'collapse': CollapseCommand
}, },
events: { events: {
'layoutapply': function(e) { 'layoutapply': function(e) {
......
...@@ -117,7 +117,7 @@ define(function(require, exports, module) { ...@@ -117,7 +117,7 @@ define(function(require, exports, module) {
}); });
return { return {
'commands': { 'commands': {
'priority': PriorityCommand, 'priority': PriorityCommand
}, },
'renderers': { 'renderers': {
left: kity.createClass('PriorityRenderer', { left: kity.createClass('PriorityRenderer', {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment