Assign variable UUID to field_variable dropdown.#1096
Assign variable UUID to field_variable dropdown.#1096marisaleung merged 1 commit intoRaspberryPiFoundation:developfrom
Conversation
core/field_variable.js
Outdated
| goog.require('goog.asserts'); | ||
| goog.require('goog.string'); | ||
|
|
||
| var RENAME_VARIABLE_ID = 'RENAME_VARIABLE'; |
There was a problem hiding this comment.
There was a problem hiding this comment.
More seriously, these should probably be constants in Blockly.Constants, and they should definitely have 'ID' in the text.
There was a problem hiding this comment.
For reference, this is my fault and you should listen to Rachel.
There was a problem hiding this comment.
Hahahaha I love this X).
Done (listened to Rachel.)
core/field_variable.js
Outdated
| @@ -177,10 +164,14 @@ Blockly.FieldVariable.dropdownCreate = function() { | |||
| */ | |||
| Blockly.FieldVariable.prototype.onItemSelected = function(menu, menuItem) { | |||
| var itemText = menuItem.getValue(); | |||
There was a problem hiding this comment.
itemText feels overloaded now. On line 166 (on the right) it's the ID, not the text. But on line 172 it's the text.
There was a problem hiding this comment.
Agreed. I'm setting it to id for now.
In the next CL I will change field_variable's setValue() to take in an id since all items are now ids. Then we can get rid of itemText.
d984d6b to
b438c69
Compare
rachel-fenichel
left a comment
There was a problem hiding this comment.
A few small changes but generally looks good.
core/constants.js
Outdated
| * variable...' and if selected, should trigger the prompt to rename a variable. | ||
| * @const {string} | ||
| */ | ||
| Blockly.RENAME_VARIABLE_ID = 'RENAME_VARIABLE'; |
There was a problem hiding this comment.
Make this 'RENAME_VARIABLE_ID', and 'DELETE_VARIABLE_ID'
core/variable_model.js
Outdated
| * @param {Blockly.VariableModel} var1 First variable to compare. | ||
| * @param {Blockly.VariableModel} var2 Second variable to compare. | ||
| */ | ||
| Blockly.VariableModel.prototype.compareByName = function(var1, var2) { |
There was a problem hiding this comment.
You can put this on Blockly.VariableModel instead of Blockly.VariableModel.prototype.
| } | ||
|
|
||
| // Call any validation function, and allow it to override. | ||
| itemText = this.callValidator(itemText); |
There was a problem hiding this comment.
Did you decide that validators don't make sense in the context of a variable dropdown?
There was a problem hiding this comment.
Yes, the call does nothing. And the text comes directly from the variable itself so I can't imagine an instance in which a validator would be needed/useful.
4d4109e to
b7932f9
Compare
|
Review status: 0 of 4 files reviewed at latest revision, 3 unresolved discussions. core/variable_model.js, line 84 at r2 (raw file):
This lost the case insensitive part. Check with Rachel if you're safe to use goog.string.caseInsensitiveCompare(var1.name, var2.name) and if not first convert both names to lowercase before comparing. Comments from Reviewable |
|
Review status: 0 of 4 files reviewed at latest revision, 3 unresolved discussions. core/variable_model.js, line 84 at r2 (raw file): Previously, RoboErikG wrote…
Done. Comments from Reviewable |
|
Review status: 0 of 4 files reviewed at latest revision, 3 unresolved discussions. Comments from Reviewable |
|
Review status: 0 of 4 files reviewed at latest revision, 4 unresolved discussions. core/field_variable.js, line 135 at r3 (raw file):
This comparison should be case-insensitive. Comments from Reviewable |
|
Review status: 0 of 4 files reviewed at latest revision, 4 unresolved discussions. core/field_variable.js, line 135 at r3 (raw file): Previously, rachel-fenichel (Rachel Fenichel) wrote…
Done. Comments from Reviewable |

This change is