From 1ee550aa2461c430aab4655e4cf4cffb0e454ce1 Mon Sep 17 00:00:00 2001 From: CoryDCode Date: Tue, 13 Jun 2017 09:47:27 -0700 Subject: [PATCH] Fixing the accessible variable stuff so it interacts correctly with (#1170) variableMap. --- accessible/field-segment.component.js | 9 ++++----- accessible/variable-modal.service.js | 3 ++- accessible/variable-remove-modal.component.js | 3 ++- core/workspace.js | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/accessible/field-segment.component.js b/accessible/field-segment.component.js index 4f2852a4e..cdf48993d 100644 --- a/accessible/field-segment.component.js +++ b/accessible/field-segment.component.js @@ -156,17 +156,16 @@ blocklyApp.FieldSegmentComponent = ng.core.Component({ }, // Confirm a selection for dropdown fields. selectOption: function() { - if (this.optionValue != Blockly.Msg.RENAME_VARIABLE && this.optionValue != - Blockly.Msg.DELETE_VARIABLE.replace('%1', this.mainField.getValue())) { + if (this.optionValue != Blockly.RENAME_VARIABLE_ID && this.optionValue != + Blockly.DELETE_VARIABLE_ID) { this.mainField.setValue(this.optionValue); } - if (this.optionValue == Blockly.Msg.RENAME_VARIABLE) { + if (this.optionValue == Blockly.RENAME_VARIABLE_ID) { this.variableModalService.showRenameModal_(this.mainField.getValue()); } - if (this.optionValue == - Blockly.Msg.DELETE_VARIABLE.replace('%1', this.mainField.getValue())) { + if (this.optionValue == Blockly.DELETE_VARIABLE_ID) { this.variableModalService.showRemoveModal_(this.mainField.getValue()); } }, diff --git a/accessible/variable-modal.service.js b/accessible/variable-modal.service.js index 5c425069b..c7b72ee2c 100644 --- a/accessible/variable-modal.service.js +++ b/accessible/variable-modal.service.js @@ -71,7 +71,8 @@ blocklyApp.VariableModalService = ng.core.Class({ this.preRemoveShowHook(oldName, count); this.modalIsShown = true; } else { - blocklyApp.workspace.deleteVariableInternal_(oldName); + var variable = blocklyApp.workspace.getVariable(oldName); + blocklyApp.workspace.deleteVariableInternal_(variable); } }, getNumVariables: function(oldName) { diff --git a/accessible/variable-remove-modal.component.js b/accessible/variable-remove-modal.component.js index 480485342..c6d70c9ca 100644 --- a/accessible/variable-remove-modal.component.js +++ b/accessible/variable-remove-modal.component.js @@ -108,7 +108,8 @@ blocklyApp.VariableRemoveModalComponent = ng.core.Component({ }, // Submits the name change for the variable. submit: function() { - blocklyApp.workspace.deleteVariableInternal_(this.currentVariableName); + var variable = blocklyApp.workspace.getVariable(this.currentVariableName); + blocklyApp.workspace.deleteVariableInternal_(variable); this.hideModal_(); }, // Dismisses and closes the modal. diff --git a/core/workspace.js b/core/workspace.js index ecdccfce2..cd6e56e2c 100644 --- a/core/workspace.js +++ b/core/workspace.js @@ -326,7 +326,7 @@ Blockly.Workspace.prototype.getVariableUses = function(name) { for (var j = 0; j < blockVariables.length; j++) { var varName = blockVariables[j]; // Variable name may be null if the block is only half-built. - if (varName && Blockly.Names.equals(varName, name)) { + if (varName && name && Blockly.Names.equals(varName, name)) { uses.push(blocks[i]); } }