My first question is, using 'if-else' block mutator as basis, the updateShape()_ function must recreate this connections one-by-one, or there's a easier way to do that? If not, how can I do this? I was trying to resolve this using connectionDB, a attribute inside the input connector, but without success yet. On the docs, it's specified that this attribute is a vertcal database of connected blocks, but I didn't make success using it.
My approach is correct here?
--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/178e6f40-1df9-4672-980c-51b627c6e0ff%40googlegroups.com.

To unsubscribe from this group and stop receiving emails from it, send an email to blo...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/405720b8-b447-4de5-896c-af209482b80e%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/405720b8-b447-4de5-896c-af209482b80e%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/a62b8e04-ff4e-4830-94a5-d01f8f1a490b%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/35d51eba-f5e2-486e-bfe9-47ab2e2267b2%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/35d51eba-f5e2-486e-bfe9-47ab2e2267b2%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/a62b8e04-ff4e-4830-94a5-d01f8f1a490b%40googlegroups.com.
mutationToDom(): Element{ if (this.getFieldValue('variable_model') && this.getFieldValue('variable_model') !== this.oldVariableModelFieldValue) { this.getField('variable_model').validator_(this.getFieldValue('variable_model')); this.oldVariableModelFieldValue = this.getFieldValue('variable_model'); this.rebuildShape_(); }
if (!this.horizontalConnectedBlocks.length) { return null; }
let mutationXmlElement = Blockly.utils.xml.createElement('mutation'); this.modelFieldsToFilterArray && mutationXmlElement.setAttribute('modelFieldsToFilterArray', this.modelFieldsToFilterArray); this.horizontalConnectedBlocks && mutationXmlElement.setAttribute('horizontalConnectedBlocks', this.horizontalConnectedBlocks); this.modelType && mutationXmlElement.setAttribute('modelType', this.modelType);
return mutationXmlElement;},
domToMutation(a): void{ this.modelFieldsToFilterArray = a.getAttribute('modelFieldsToFilterArray').split(','); this.horizontalConnectedBlocks = a.getAttribute('horizontalConnectedBlocks').split(','); this.modelType = a.getAttribute('modelType'); this.rebuildShape_();},
rebuildShape_(): void{ // tslint:disable-next-line: one-variable-per-declaration let a = [null], b = [null], c = null; for (let d = 1; this.getInput('FILTER');) { // tslint:disable-next-line: one-variable-per-declaration let e = this.getInput('FILTER'); a.push(e.connection.targetConnection); d++; } this.updateShape_(); this.reconnectChildBlocks_(a);},
compose(topBlock): void{ topBlock = topBlock.nextConnection.targetBlock(); this.modelFieldsToFilterArray = ['']; let b = []; let c = []; let d;
this.horizontalConnectedBlocks = []; if (topBlock) { switch (topBlock.type) { case ModelSingleBlockType.FILTER_MODEL_FIELD: b.push(topBlock.getInput('filter_condition').connection && topBlock.getInput('filter_condition').connection.targetConnection);
this.mountHorizontalConnections(topBlock.getInputTargetBlock('filter_condition'), 0);
c.push(topBlock.statementConnection_); break; default: throw TypeError('Unknown block type: ' + topBlock.type); } }
this.updateShape_(); this.reconnectChildBlocks_(b);},decompose(workspace: Blockly.WorkspaceSvg): Blockly.BlockSvg{ let topBlock = workspace.newBlock(ModelSingleBlockType.APPEND_MODEL_FILTERS) as Blockly.BlockSvg; topBlock.initSvg(); let c: Blockly.Connection = topBlock.nextConnection; let d: number = 1;
if (this.horizontalConnectedBlocks.length) { let filterBlockFixed = workspace.newBlock(ModelSingleBlockType.FILTER_MODEL_FIELD) as Blockly.BlockSvg; filterBlockFixed.initSvg(); c.connect(filterBlockFixed.previousConnection); c = filterBlockFixed.nextConnection;
let inputIn: Blockly.Connection = filterBlockFixed.getInput('filter_condition').connection; this.reconnectHorizontalInputs(workspace, inputIn, this.horizontalConnectedBlocks[0], 0); } return topBlock;},
updateShape_(): void{ (this as Blockly.BlockSvg).removeInput('FILTER', true);
let idx = 0; while (SELF.workspace.getBlockById('FILTER' + idx)) { SELF.workspace.getBlockById('FILTER' + idx).dispose(false); idx++; }
if (this.horizontalConnectedBlocks.length) { this.appendValueInput('FILTER').appendField('Where');
let inputIn: Blockly.RenderedConnection = this.getInput('FILTER').connection; let childBlock = SELF.workspace.newBlock('LOGIC_COMPARE', 'FILTER0') as Blockly.BlockSvg;
childBlock.initSvg(); childBlock.render();
let childConnection = childBlock.outputConnection; inputIn.connect(childConnection); // this.reconnectHorizontalInputs(SELF.workspace, inputIn, this.horizontalConnectedBlocks[0], 0); }},To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/a62b8e04-ff4e-4830-94a5-d01f8f1a490b%40googlegroups.com.