show the starter block upon deleting a block and clearing block library (#548)

This commit is contained in:
Tina Quach
2016-08-15 11:18:15 -07:00
committed by picklesrus
parent c7dea98e88
commit 0d66c77357
2 changed files with 6 additions and 1 deletions

View File

@@ -76,6 +76,8 @@ BlockLibraryController.prototype.removeFromBlockLibrary = function() {
this.storage.removeBlock(blockType);
this.storage.saveToLocalStorage();
this.populateBlockLibrary();
// Show default block.
BlockFactory.showStarterBlock();
};
/**
@@ -102,7 +104,7 @@ BlockLibraryController.prototype.getSelectedBlockType =
/**
* Confirms with user before clearing the block library in local storage and
* updating the dropdown.
* updating the dropdown and displaying the starter block (factory_base).
*/
BlockLibraryController.prototype.clearBlockLibrary = function() {
var check = confirm(
@@ -116,6 +118,8 @@ BlockLibraryController.prototype.clearBlockLibrary = function() {
// Add a default, blank option to dropdown for when no block from library is
// selected.
BlockLibraryView.addDefaultOption('blockLibraryDropdown');
// Show default block.
BlockFactory.showStarterBlock();
}
};

View File

@@ -945,6 +945,7 @@ BlockFactory.disableEnableLink = function() {
* Render starter block (factory_base).
*/
BlockFactory.showStarterBlock = function() {
BlockFactory.mainWorkspace.clear();
var xml = '<xml><block type="factory_base" deletable="false" ' +
'movable="false"></block></xml>';
Blockly.Xml.domToWorkspace(