mirror of
https://github.com/google/blockly.git
synced 2026-01-17 13:57:13 +01:00
Fixing the accessible variable stuff so it interacts correctly with (#1170)
variableMap.
This commit is contained in:
@@ -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());
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user