Commit 07848d7e authored by Evan W. Patton's avatar Evan W. Patton

Fix backpack behavior in Blockly update

Backpack menu items in the workspace, i.e. Copy All to Backpack and
Paste All From Backpack were broken during the transition to the
latest Blockly. This commit changes any checks for the backpack
presence to use the hasBackpack() test added to WorkspaceSvg.

Change-Id: Iae7919d173f5a5f75003c0132d1f116af9839bd0
parent 0e9f7067
......@@ -246,7 +246,7 @@ Blockly.Backpack.prototype.pasteBackpack = function() {
var ok = true;
for (var j = 0; j < arr.length; j++) {
var type = arr[j];
if (! this.workspace_.getComponentDatabase().hasType(type)) {
if (!Blockly.Blocks[type] && ! this.workspace_.getComponentDatabase().hasType(type)) {
ok = false;
break;
}
......
......@@ -673,7 +673,7 @@ Blockly.WorkspaceSvg.prototype.customContextMenu = function(menuOptions) {
Blockly.getMainWorkspace().getBackpack().count() + ")";
backpackRetrieve.callback = function() {
if (Blockly.getMainWorkspace().hasBackpack()) {
Blockly.getMainWorkspace().getBackpack().pasteBackpack(this.backpack_);
Blockly.getMainWorkspace().getBackpack().pasteBackpack();
}
};
menuOptions.push(backpackRetrieve);
......@@ -682,7 +682,7 @@ Blockly.WorkspaceSvg.prototype.customContextMenu = function(menuOptions) {
var backpackCopyAll = {enabled: true};
backpackCopyAll.text = Blockly.Msg.COPY_ALLBLOCKS;
backpackCopyAll.callback = function() {
if (this.backpack_) {
if (Blockly.getMainWorkspace().hasBackpack()) {
Blockly.getMainWorkspace().getBackpack().addAllToBackpack();
}
};
......@@ -692,7 +692,9 @@ Blockly.WorkspaceSvg.prototype.customContextMenu = function(menuOptions) {
var backpackClear = {enabled: true};
backpackClear.text = Blockly.Msg.BACKPACK_EMPTY;
backpackClear.callback = function() {
Blockly.getMainWorkspace().getBackpack().clear();
if (Blockly.getMainWorkspace().hasBackpack()) {
Blockly.getMainWorkspace().getBackpack().clear();
}
backpackRetrieve.text = Blockly.Msg.BACKPACK_GET;
};
menuOptions.push(backpackClear);
......
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