-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from ThomasPohl/feature/writeCell
Feature/write cell
- Loading branch information
Showing
16 changed files
with
389 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
"use strict"; | ||
|
||
/// --- Read Cell -------------------------------------------------- | ||
|
||
Blockly.Words["google-spreadsheet_read_read-from"] = { en: "read from", de: "Lies von" } | ||
Blockly.Words["google-spreadsheet_read_on-sheetName"] = { en: "sheet", de: "Tabellenblatt" } | ||
Blockly.Words["google-spreadsheet_read_in-cell"] = { en: "cell", de: "Zelle" } | ||
Blockly.Sendto.blocks["google-spreadsheet.read"] = | ||
'<block type="google-spreadsheet.read">' + | ||
' <value name="NAME">' + | ||
' </value>' + | ||
' <value name="INSTANCE">' + | ||
' </value>' + | ||
' <value name="SHEET_NAME">' + | ||
' <shadow type="text">' + | ||
' <field name="TEXT">text</field>' + | ||
' </shadow>' + | ||
' </value>' + | ||
' <value name="RANGE">' + | ||
' <shadow type="text">' + | ||
' <field name="TEXT">text</field>' + | ||
' </shadow>' + | ||
' </value>' + | ||
'</block>'; | ||
|
||
Blockly.Blocks["google-spreadsheet.read"] = { | ||
init: function () { | ||
const instances = getInstances(false); | ||
|
||
this.appendDummyInput("NAME") | ||
.appendField(Blockly.Translate("google-spreadsheet_read_read-from")) | ||
.appendField(new Blockly.FieldDropdown(instances), "INSTANCE"); | ||
|
||
this.appendValueInput("SHEET_NAME") | ||
.appendField(Blockly.Translate("google-spreadsheet_read_on-sheetName")); | ||
|
||
this.appendValueInput("CELL") | ||
.appendField(Blockly.Translate("google-spreadsheet_read_in-cell")); | ||
|
||
|
||
|
||
this.setInputsInline(true); | ||
this.setPreviousStatement(false, null); | ||
this.setNextStatement(false, null); | ||
this.setOutput(true, 'String'); | ||
|
||
this.setColour(Blockly.Sendto.HUE); | ||
|
||
}, | ||
}; | ||
|
||
Blockly.JavaScript["google-spreadsheet.read"] = function (block) { | ||
var dropdown_instance = block.getFieldValue("INSTANCE"); | ||
var data = Blockly.JavaScript.valueToCode(block, "DATA", Blockly.JavaScript.ORDER_ATOMIC); | ||
if (!data){ | ||
data = "{}"; | ||
} | ||
var sheetName = Blockly.JavaScript.valueToCode(block, "SHEET_NAME", Blockly.JavaScript.ORDER_ATOMIC); | ||
var cell = Blockly.JavaScript.valueToCode(block, "CELL", Blockly.JavaScript.ORDER_ATOMIC); | ||
|
||
return ['await new Promise((resolve)=>{sendTo("google-spreadsheet' + dropdown_instance + '", "readCell", {"sheetName":"'+sheetName+'", "cell":"'+cell+'"}, (response)=>{resolve(response)}); })', 0]; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"use strict"; | ||
|
||
/// --- Write Cell -------------------------------------------------- | ||
|
||
Blockly.Words["google-spreadsheet_writeCell_write-to"] = { en: "write to", de: "Schreibe in " } | ||
Blockly.Words["google-spreadsheet_writeCell_sheetName"] = { en: "on sheet", de: "auf Tabellenblatt" } | ||
Blockly.Words["google-spreadsheet_writeCell_cell"] = { en: "in cell", de: "in Zelle" } | ||
Blockly.Words["google-spreadsheet_writeCell_data"] = { en: "the data", de: "die Daten" } | ||
|
||
Blockly.Sendto.blocks["google-spreadsheet.writeCell"] = | ||
'<block type="google-spreadsheet.writeCell">' + | ||
|
||
' <value name="NAME">' + | ||
' </value>' + | ||
' <value name="INSTANCE">' + | ||
' </value>' + | ||
' <value name="SHEET_NAME">' + | ||
' <shadow type="text">' + | ||
' <field name="TEXT">text</field>' + | ||
' </shadow>' + | ||
' </value>' + | ||
' <value name="CELL">' + | ||
' <shadow type="text">' + | ||
' <field name="TEXT">A1</field>' + | ||
' </shadow>' + | ||
' </value>' + | ||
' <value name="DATA">' + | ||
' </value>' + | ||
'</block>'; | ||
|
||
Blockly.Blocks["google-spreadsheet.writeCell"] = { | ||
init: function () { | ||
const instances = getInstances(); | ||
|
||
this.appendDummyInput("NAME") | ||
.appendField(Blockly.Translate("google-spreadsheet_writeCell_write-to")) | ||
.appendField(new Blockly.FieldDropdown(instances), "INSTANCE"); | ||
|
||
this.appendValueInput("SHEET_NAME") | ||
.appendField(Blockly.Translate("google-spreadsheet_writeCell_sheetName")); | ||
|
||
this.appendValueInput("CELL") | ||
.appendField(Blockly.Translate("google-spreadsheet_writeCell_cell")); | ||
|
||
this.appendValueInput("DATA") | ||
.appendField(Blockly.Translate("google-spreadsheet_writeCell_data")); | ||
|
||
this.setInputsInline(false); | ||
this.setPreviousStatement(true, null); | ||
this.setNextStatement(true, null); | ||
|
||
this.setColour(Blockly.Sendto.HUE); | ||
} | ||
}; | ||
|
||
Blockly.JavaScript["google-spreadsheet.writeCell"] = function (block) { | ||
var dropdown_instance = block.getFieldValue("INSTANCE"); | ||
var sheetName = Blockly.JavaScript.valueToCode(block, "SHEET_NAME", Blockly.JavaScript.ORDER_ATOMIC); | ||
var cell = Blockly.JavaScript.valueToCode(block, "CELL", Blockly.JavaScript.ORDER_ATOMIC); | ||
var data = Blockly.JavaScript.valueToCode(block, "DATA", Blockly.JavaScript.ORDER_ATOMIC); | ||
|
||
return 'sendTo("google-spreadsheet' + dropdown_instance + '", "writeCell", {"sheetName": '+sheetName+', "cell": '+cell+', "data":'+data+'}' + ");\n"; | ||
}; | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.