Skip to content

Commit

Permalink
chore: release v7.7.0
Browse files Browse the repository at this point in the history
* (klein0r) Added block for multiple and conditions
  • Loading branch information
klein0r committed Jan 14, 2024
1 parent de0c4f9 commit 8a38c44
Show file tree
Hide file tree
Showing 13 changed files with 246 additions and 57 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG_OLD.md
@@ -1,4 +1,10 @@
The newest change log is in README.md
## 7.5.0 (2023-12-15)

* (klein0r) Blockly: Day of week as number always returns 1 (monday) to 7 (sunday)
* (klein0r) Fixed layout of script type selection
* (klein0r) Fixed sendto with multiple instances (for callback / timeout handling)

## 7.4.0 (2023-12-08)

* (klein0r) Download script as xml file (export)
Expand Down
8 changes: 1 addition & 7 deletions README.md
Expand Up @@ -46,7 +46,7 @@ Since v5.5.0 of the JavaScript adapter the following locations (relative to the
<!--
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
### 7.7.0 (2024-01-14)

* (klein0r) Added block for multiple and conditions

Expand All @@ -70,12 +70,6 @@ Since v5.5.0 of the JavaScript adapter the following locations (relative to the
* (klein0r) Added option for calendar week to Blockly
* (klein0r) Fixed inpaired round brackets of getMinutes (Blockly)

### 7.5.0 (2023-12-15)

* (klein0r) Blockly: Day of week as number always returns 1 (monday) to 7 (sunday)
* (klein0r) Fixed layout of script type selection
* (klein0r) Fixed sendto with multiple instances (for callback / timeout handling)

## License
The MIT License (MIT)

Expand Down
10 changes: 5 additions & 5 deletions admin/asset-manifest.json
@@ -1,8 +1,8 @@
{
"files": {
"main.js": "/static/js/main.10262ca6.js",
"main.js": "/static/js/main.8c1c081e.js",
"static/css/864.42bfc5f3.chunk.css": "/static/css/864.42bfc5f3.chunk.css",
"static/js/864.74e29d53.chunk.js": "/static/js/864.74e29d53.chunk.js",
"static/js/864.8c5abf54.chunk.js": "/static/js/864.8c5abf54.chunk.js",
"static/js/805.7c367e53.chunk.js": "/static/js/805.7c367e53.chunk.js",
"static/js/723.a75610c2.chunk.js": "/static/js/723.a75610c2.chunk.js",
"static/js/66.ebb5d6fe.chunk.js": "/static/js/66.ebb5d6fe.chunk.js",
Expand Down Expand Up @@ -161,9 +161,9 @@
"static/media/Garage Doors.svg": "/static/media/Garage Doors.0c2a1cfca7ad1ea59625.svg",
"static/media/Outdoor Blinds.svg": "/static/media/Outdoor Blinds.37b85a9c060a4af48da9.svg",
"static/media/Upstairs.svg": "/static/media/Upstairs.441813e54e0daca0882d.svg",
"main.10262ca6.js.map": "/static/js/main.10262ca6.js.map",
"main.8c1c081e.js.map": "/static/js/main.8c1c081e.js.map",
"864.42bfc5f3.chunk.css.map": "/static/css/864.42bfc5f3.chunk.css.map",
"864.74e29d53.chunk.js.map": "/static/js/864.74e29d53.chunk.js.map",
"864.8c5abf54.chunk.js.map": "/static/js/864.8c5abf54.chunk.js.map",
"805.7c367e53.chunk.js.map": "/static/js/805.7c367e53.chunk.js.map",
"723.a75610c2.chunk.js.map": "/static/js/723.a75610c2.chunk.js.map",
"66.ebb5d6fe.chunk.js.map": "/static/js/66.ebb5d6fe.chunk.js.map",
Expand Down Expand Up @@ -197,6 +197,6 @@
"917.05d2dfa0.chunk.js.map": "/static/js/917.05d2dfa0.chunk.js.map"
},
"entrypoints": [
"static/js/main.10262ca6.js"
"static/js/main.8c1c081e.js"
]
}
224 changes: 204 additions & 20 deletions admin/google-blockly/own/blocks_logic.js
Expand Up @@ -4,6 +4,190 @@ if (typeof goog !== 'undefined') {
goog.require('Blockly.JavaScript');
}

// --- logic multi and --------------------------------------------------

Blockly.Blocks['logic_multi_and_container'] = {
/**
* Mutator block for container.
* @this Blockly.Block
*/
init: function() {
this.setColour("%{BKY_LOGIC_HUE}");

this.appendDummyInput()
.appendField(Blockly.Translate('logic_multi_and'));

this.appendStatementInput('STACK');
this.setTooltip(Blockly.Translate('logic_multi_and_tooltip'));

this.contextMenu = false;
}
};

Blockly.Blocks['logic_multi_and_mutator'] = {
/**
* Mutator block for add items.
* @this Blockly.Block
*/
init: function() {
this.setColour("%{BKY_LOGIC_HUE}");

this.appendDummyInput('AND')
.appendField(Blockly.Translate('logic_multi_and_and'));

this.setPreviousStatement(true);
this.setNextStatement(true);

this.setTooltip(Blockly.Translate('logic_multi_and_tooltip'));

this.contextMenu = false;
}
};

Blockly.Blocks['logic_multi_and'] = {
init: function() {
this.itemCount_ = 2;
this.setMutator(new Blockly.Mutator(['logic_multi_and_mutator']));

this.setInputsInline(false);
this.setOutput(true, 'Boolean');

this.setColour("%{BKY_LOGIC_HUE}");
this.setTooltip(Blockly.Translate('logic_multi_and_tooltip'));
// this.setHelpUrl(getHelp('logic_multi_and_help'));
},
/**
* Create XML to represent number of text inputs.
* @return {!Element} XML storage element.
* @this Blockly.Block
*/
mutationToDom: function () {
const container = document.createElement('mutation');
container.setAttribute('items', this.itemCount_);

return container;
},
/**
* Parse XML to restore the text inputs.
* @param {!Element} xmlElement XML storage element.
* @this Blockly.Block
*/
domToMutation: function (xmlElement) {
this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10);
this.updateShape_();
},
/**
* Populate the mutator's dialog with this block's components.
* @param {!Blockly.Workspace} workspace Mutator's workspace.
* @return {!Blockly.Block} Root block in mutator.
* @this Blockly.Block
*/
decompose: function (workspace) {
const containerBlock = workspace.newBlock('logic_multi_and_container');
containerBlock.initSvg();

let connection = containerBlock.getInput('STACK').connection;
for (let i = 0; i < this.itemCount_; i++) {
const itemBlock = workspace.newBlock('logic_multi_and_mutator');
itemBlock.initSvg();
connection.connect(itemBlock.previousConnection);
connection = itemBlock.nextConnection;
}

return containerBlock;
},
/**
* Reconfigure this block based on the mutator dialog's components.
* @param {!Blockly.Block} containerBlock Root block in mutator.
* @this Blockly.Block
*/
compose: function (containerBlock) {
let itemBlock = containerBlock.getInputTargetBlock('STACK');
// Count number of inputs.
const connections = [];
while (itemBlock) {
connections.push(itemBlock.valueConnection_);
itemBlock = itemBlock.nextConnection &&
itemBlock.nextConnection.targetBlock();
}

// Disconnect any children that don't belong.
for (let k = 0; k < this.itemCount_; k++) {
const connection = this.getInput('AND' + k).connection.targetConnection;
if (connection && connections.indexOf(connection) === -1) {
connection.disconnect();
}
}

this.itemCount_ = connections.length;
if (this.itemCount_ < 2) {
this.itemCount_ = 2;
}
this.updateShape_();

// Reconnect any child blocks.
for (let i = 0; i < this.itemCount_; i++) {
Blockly.Mutator.reconnect(connections[i], this, 'AND' + i);
}
},
/**
* Store pointers to any connected child blocks.
* @param {!Blockly.Block} containerBlock Root block in mutator.
* @this Blockly.Block
*/
saveConnections: function(containerBlock) {
let itemBlock = containerBlock.getInputTargetBlock('STACK');
let i = 0;

while (itemBlock) {
const input = this.getInput('AND' + i);
itemBlock.valueConnection_ = input && input.connection.targetConnection;
i++;
itemBlock = itemBlock.nextConnection &&
itemBlock.nextConnection.targetBlock();
}
},
/**
* Modify this block to have the correct number of inputs.
* @private
* @this Blockly.Block
*/
updateShape_: function() {
if (this.itemCount_ && this.getInput('EMPTY')) {
this.removeInput('EMPTY');
} else if (!this.itemCount_ && !this.getInput('EMPTY')) {
this.appendDummyInput('EMPTY')
.appendField(this.newQuote_(true))
.appendField(this.newQuote_(false));
}
// Add new inputs.
for (let i = 0; i < this.itemCount_; i++) {
if (!this.getInput('AND' + i)) {
const input = this.appendValueInput('AND' + i).setAlign(Blockly.ALIGN_RIGHT);
if (i > 0) {
input.appendField(Blockly.Translate('logic_multi_and_and'));
}
}
}
// Remove deleted inputs.
for (let i = this.itemCount_; this.getInput('AND' + i); i++) {
this.removeInput('AND' + i);
}
}
};

Blockly.JavaScript['logic_multi_and'] = function(block) {
const ands = [];
for (let n = 0; n < block.itemCount_; n++) {
const condition = Blockly.JavaScript.valueToCode(block, 'AND' + n, Blockly.JavaScript.ORDER_COMMA);
if (condition) {
ands.push(condition);
}
}

return [`(${ands.length > 0 ? ands.join(' && ') : 'false'})`, Blockly.JavaScript.ORDER_ATOMIC];
};

// --- logic between --------------------------------------------------

Blockly.Blocks['logic_between'] = {
Expand All @@ -21,9 +205,9 @@ Blockly.Blocks['logic_between'] = {
this.setOutput(true, 'Boolean');
this.setColour("%{BKY_LOGIC_HUE}");
this.setTooltip(Blockly.Translate('logic_between_tooltip'));
// this.setHelpUrl(Blockly.Translate('logic_between_helpurl'));
// this.setHelpUrl(getHelp('logic_between_help'));
}
}
};

Blockly.JavaScript['logic_between'] = function(block) {
const min = Blockly.JavaScript.valueToCode(block, 'MIN', Blockly.JavaScript.ORDER_RELATIONAL) || 0;
Expand All @@ -33,28 +217,28 @@ Blockly.JavaScript['logic_between'] = function(block) {
const maxOperator = block.getFieldValue('MAX_OPERATOR') === 'LT' ? '<' : '<=';

return [`${min} ${minOperator} ${value} && ${value} ${maxOperator} ${max}`, Blockly.JavaScript.ORDER_LOGICAL_AND];
}
};

// --- logic ifempty --------------------------------------------------

Blockly.Blocks['logic_ifempty'] = {
init: function() {
this.appendValueInput('VALUE')
.setCheck(null)
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Translate('logic_ifempty'));
this.appendValueInput('DEFLT')
.setCheck(null)
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Translate('logic_ifempty_then'));

this.setOutput(true, null);
this.setInputsInline(true);
this.setColour("%{BKY_LOGIC_HUE}");
this.setTooltip(Blockly.Translate('logic_ifempty_tooltip'));
// this.setHelpUrl(Blockly.Translate('logic_ifempty_helpurl'));
}
}
init: function() {
this.appendValueInput('VALUE')
.setCheck(null)
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Translate('logic_ifempty'));
this.appendValueInput('DEFLT')
.setCheck(null)
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(Blockly.Translate('logic_ifempty_then'));

this.setOutput(true, null);
this.setInputsInline(true);
this.setColour("%{BKY_LOGIC_HUE}");
this.setTooltip(Blockly.Translate('logic_ifempty_tooltip'));
// this.setHelpUrl(getHelp('logic_ifempty_help'));
}
};

Blockly.JavaScript['logic_ifempty'] = function(block) {
const value = Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_LOGICAL_OR) || null;
Expand Down

0 comments on commit 8a38c44

Please sign in to comment.