|
| 1 | +"use strict"; |
| 2 | + |
| 3 | +/// --- Write Cell -------------------------------------------------- |
| 4 | + |
| 5 | +Blockly.Words["google-spreadsheet_writeCell_write-to"] = { en: "write to", de: "Schreibe in " } |
| 6 | +Blockly.Words["google-spreadsheet_writeCell_sheetName"] = { en: "on sheet", de: "auf Tabellenblatt" } |
| 7 | +Blockly.Words["google-spreadsheet_writeCell_cell"] = { en: "in cell", de: "in Zelle" } |
| 8 | +Blockly.Words["google-spreadsheet_writeCell_data"] = { en: "the data", de: "die Daten" } |
| 9 | + |
| 10 | +Blockly.Sendto.blocks["google-spreadsheet.writeCell"] = |
| 11 | + '<block type="google-spreadsheet.writeCell">' + |
| 12 | + |
| 13 | + ' <value name="NAME">' + |
| 14 | + ' </value>' + |
| 15 | + ' <value name="INSTANCE">' + |
| 16 | + ' </value>' + |
| 17 | + ' <value name="SHEET_NAME">' + |
| 18 | + ' <shadow type="text">' + |
| 19 | + ' <field name="TEXT">text</field>' + |
| 20 | + ' </shadow>' + |
| 21 | + ' </value>' + |
| 22 | + ' <value name="CELL">' + |
| 23 | + ' <shadow type="text">' + |
| 24 | + ' <field name="TEXT">A1</field>' + |
| 25 | + ' </shadow>' + |
| 26 | + ' </value>' + |
| 27 | + ' <value name="DATA">' + |
| 28 | + ' </value>' + |
| 29 | + '</block>'; |
| 30 | + |
| 31 | +Blockly.Blocks["google-spreadsheet.writeCell"] = { |
| 32 | + init: function () { |
| 33 | + const instances = getInstances(); |
| 34 | + |
| 35 | + this.appendDummyInput("NAME") |
| 36 | + .appendField(Blockly.Translate("google-spreadsheet_writeCell_write-to")) |
| 37 | + .appendField(new Blockly.FieldDropdown(instances), "INSTANCE"); |
| 38 | + |
| 39 | + this.appendValueInput("SHEET_NAME") |
| 40 | + .appendField(Blockly.Translate("google-spreadsheet_writeCell_sheetName")); |
| 41 | + |
| 42 | + this.appendValueInput("CELL") |
| 43 | + .appendField(Blockly.Translate("google-spreadsheet_writeCell_cell")); |
| 44 | + |
| 45 | + this.appendValueInput("DATA") |
| 46 | + .appendField(Blockly.Translate("google-spreadsheet_writeCell_data")); |
| 47 | + |
| 48 | + this.setInputsInline(false); |
| 49 | + this.setPreviousStatement(true, null); |
| 50 | + this.setNextStatement(true, null); |
| 51 | + |
| 52 | + this.setColour(Blockly.Sendto.HUE); |
| 53 | + } |
| 54 | +}; |
| 55 | + |
| 56 | +Blockly.JavaScript["google-spreadsheet.writeCell"] = function (block) { |
| 57 | + var dropdown_instance = block.getFieldValue("INSTANCE"); |
| 58 | + var sheetName = Blockly.JavaScript.valueToCode(block, "SHEET_NAME", Blockly.JavaScript.ORDER_ATOMIC); |
| 59 | + var cell = Blockly.JavaScript.valueToCode(block, "CELL", Blockly.JavaScript.ORDER_ATOMIC); |
| 60 | + var data = Blockly.JavaScript.valueToCode(block, "DATA", Blockly.JavaScript.ORDER_ATOMIC); |
| 61 | + |
| 62 | + return 'sendTo("google-spreadsheet' + dropdown_instance + '", "writeCell", {"sheetName": '+sheetName+', "cell": '+cell+', "data":'+data+'}' + ");\n"; |
| 63 | +}; |
| 64 | + |
0 commit comments