-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added field_label_serializable #2399
Added field_label_serializable #2399
Conversation
1c74966
to
c2f032e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good. I'd prefer this be a separate block in the factory for two reasons:
- Modifying the existing block means you need to test migration paths (loading old block definitions).
- It's something else developers need to think about even if they aren't using serializable labels.
core/field_label_serializable.js
Outdated
* @license | ||
* Visual Blocks Editor | ||
* | ||
* Copyright 2012 Google Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2019
core/field_label_serializable.js
Outdated
|
||
|
||
/** | ||
* Class for a variable getter field. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: update comment
39f7b66
to
4bfb6c6
Compare
Changed & retested code generation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last comment then lgtm.
demos/blockfactory/index.html
Outdated
@@ -4,7 +4,7 @@ | |||
<meta charset="utf-8"> | |||
<meta name="viewport" content="target-densitydpi=device-dpi, height=660, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | |||
<title>Blockly Demo: Blockly Developer Tools</title> | |||
<script src="../../blockly_compressed.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, missed this. Please upload a rebuilt compressed file instead of swapping it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gah I meant to do that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the new field_label_serializable isn't required by any other scripts at the moment, which I think is making it so closure doesn't include it in the compressed file. Should I try to export it? or is there a different solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add a goog.require for the new field type to blockly.js.
Side note: You can see a require for FieldDate commented out in that file which is what keeps it from being included in Blockly by default since the date picker is a relatively large dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebuilt and retested!
97e5b39
to
28b6e37
Compare
28b6e37
to
e42df08
Compare
The basics
The details
Resolves
Work on #1623
Extension of PR #2389
Proposed Changes
Adds a field_label_serializable field. Which is a label field that can be modified programmatically and saved to XMl.
Also adds an option to the block factory to turn a field_label into a field_label_serializable.
I can also change it to be a separate block if you think that makes more sense.
Reason for Changes
Makes it so developers don't have to create a serializable label field themselves, they can just use the prebuilt one.
Test Coverage
Added an XML test to the mocha to make sure it serializes properly.
I also added a test block to the playground with a button to help test the serialization:
I also tested that blockfactory generates correct json and javascript.
JSON, not serializable:
JSON, serializable:
JavaScript, not serializable:
JavaScript, serializable:
Tested on:
Additional Information