Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix import tree 修复导入tree出错的问题 #31

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/app/pages/editor/modals/import.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
i.projectAsData(data);
}
else if (vm.type === 'tree' && vm.format === 'json') {
var project = editor.project.get();
if (!project) throw new Error("cannot find project");
project.trees.add(data.id);
i.treeAsData(data);
}
else if (vm.type === 'nodes' && vm.format === 'json') {
Expand Down
6 changes: 5 additions & 1 deletion src/editor/editor/managers/ImportManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ b3e.editor.ImportManager = function(editor) {
var project = editor.project.get();
if (!project) return;

var tree = project.trees.add(data.id);
var tree = project.trees.get(data.id);
var root = tree.blocks.getRoot();
var first = null;

Expand Down Expand Up @@ -98,6 +98,10 @@ b3e.editor.ImportManager = function(editor) {
};

this.treesAsData = function(data) {
var project = editor.project.get();
data.forEach(function(tree){
project.trees.add(tree.id);
});
for (var i=0; i<data.length; i++) {
this.treeAsData(data[i]);
}
Expand Down
10 changes: 5 additions & 5 deletions src/editor/tree/managers/BlockManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,22 @@ b3e.tree.BlockManager = function(editor, project, tree) {
if (typeof template.name !== 'undefined') {
block.name = template.name;
} else {
block.name = node.name || block.name;
block.name = block.name || node.name;
}
if (typeof template.title !== 'undefined') {
block.title = template.title;
} else {
block.title = node.title || block.title;
block.title = block.title || node.title;
}
if (typeof template.description !== 'undefined') {
block.description = template.description;
} else {
block.description = node.description || block.description;
block.description = block.description || node.description;
}
if (typeof template.properties !== 'undefined') {
block.properties = tine.merge({}, node.properties, template.properties);
} else {
block.properties = tine.merge({}, node.properties, block.properties);
//block.properties = tine.merge({}, node.properties, block.properties);
}
block._redraw();

Expand Down Expand Up @@ -224,4 +224,4 @@ b3e.tree.BlockManager = function(editor, project, tree) {
block._applySettings(settings);
});
};
};
};