Skip to content

Conversation

@BeksOmega
Copy link
Contributor

@BeksOmega BeksOmega commented Jul 14, 2021

The basics

  • I branched from project-cereal
  • My pull request is against project-cereal
  • My code follows the style guide

Link for Diff: BeksOmega/blockly@cereal/basic-hooks...BeksOmega:cereal/block-serialization

The details

Resolves

Work on project cereal
Dependent on #5052

Proposed Changes

Adds serialization of basic block attributes: type, id, x, y, collapsed, deletable, etc.

Does not serialize children, fields, mutators, or icons. Does not handle deserialization.

Reason for Changes

Serializing state is good.

Test Coverage

Added unit tests to make sure the serializer is returning an object with the structure we expect.

@BeksOmega BeksOmega mentioned this pull request Jul 14, 2021
3 tasks
@BeksOmega BeksOmega force-pushed the cereal/block-serialization branch from 51442e1 to dfce263 Compare July 14, 2021 21:46
* @param {!Blockly.serialization.blocks.State} state The state object to append
* to.
*/
const addAttributes = function(block, state) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update private functions w/ whatever the preferred syntax is before merging.

Comment on lines 80 to 82
if (!block.isEnabled()) {
state['disabled'] = true;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to change this to be state['enabled'] to match the new API?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I think 'enabled' flags are easier to understand than 'disabled' ones (and therefore preferable), but given that undefined is falsey there might be an argument to using disabled if 'enabled' is the default state allowing the flat to be omitted in most cases.

@BeksOmega BeksOmega force-pushed the cereal/block-serialization branch from dfce263 to 38bb6d8 Compare July 20, 2021 20:34
@BeksOmega BeksOmega marked this pull request as ready for review July 20, 2021 20:54
@BeksOmega BeksOmega requested a review from a team as a code owner July 20, 2021 20:54
@BeksOmega BeksOmega removed the request for review from a team July 20, 2021 20:54
@BeksOmega BeksOmega merged commit d03f525 into RaspberryPiFoundation:project-cereal Jul 23, 2021
BeksOmega added a commit to BeksOmega/blockly that referenced this pull request Sep 13, 2021
…ation#5053)

* Add basic attribute tests

* Add basic block serialization

* Add more attribute tests

* Change save to use options dictionary

* Add obeying save options

* Add test for data attribute

* Add saving data tag

* Move to ES6 syntax

* Fixup move to es6 syntax

* Declare module

* Format and lint

* Add docs

* Add returning null on insertion markers

* Fixup for move to module

* Switch to other function declarations

* Cleanup for finalized style

* Fix lint and types

* Export State def

* Switch disabled=true to enabled=false
@BeksOmega BeksOmega deleted the cereal/block-serialization branch September 16, 2021 15:32
BeksOmega added a commit that referenced this pull request Sep 17, 2021
* Add basic attribute tests

* Add basic block serialization

* Add more attribute tests

* Change save to use options dictionary

* Add obeying save options

* Add test for data attribute

* Add saving data tag

* Move to ES6 syntax

* Fixup move to es6 syntax

* Declare module

* Format and lint

* Add docs

* Add returning null on insertion markers

* Fixup for move to module

* Switch to other function declarations

* Cleanup for finalized style

* Fix lint and types

* Export State def

* Switch disabled=true to enabled=false
alschmiedt pushed a commit to alschmiedt/blockly that referenced this pull request Sep 20, 2021
…ation#5053)

* Add basic attribute tests

* Add basic block serialization

* Add more attribute tests

* Change save to use options dictionary

* Add obeying save options

* Add test for data attribute

* Add saving data tag

* Move to ES6 syntax

* Fixup move to es6 syntax

* Declare module

* Format and lint

* Add docs

* Add returning null on insertion markers

* Fixup for move to module

* Switch to other function declarations

* Cleanup for finalized style

* Fix lint and types

* Export State def

* Switch disabled=true to enabled=false
alschmiedt pushed a commit that referenced this pull request Sep 20, 2021
* Add basic attribute tests

* Add basic block serialization

* Add more attribute tests

* Change save to use options dictionary

* Add obeying save options

* Add test for data attribute

* Add saving data tag

* Move to ES6 syntax

* Fixup move to es6 syntax

* Declare module

* Format and lint

* Add docs

* Add returning null on insertion markers

* Fixup for move to module

* Switch to other function declarations

* Cleanup for finalized style

* Fix lint and types

* Export State def

* Switch disabled=true to enabled=false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants