mirror of
https://github.com/The-Low-Code-Foundation/OpenNoodl.git
synced 2026-01-10 14:22:53 +01:00
feat(runtime): Add "Switched" signal output on the Switch node (#58)
This commit is contained in:
committed by
Richard Osborne
parent
365e96a1ac
commit
226a460cf9
@@ -4,7 +4,7 @@ const Switch = {
|
||||
name: 'Switch',
|
||||
docs: 'https://docs.noodl.net/nodes/logic/switch',
|
||||
category: 'Logic',
|
||||
initialize: function () {
|
||||
initialize() {
|
||||
this._internal.state = false;
|
||||
this._internal.initialized = false;
|
||||
},
|
||||
@@ -15,7 +15,7 @@ const Switch = {
|
||||
on: {
|
||||
displayName: 'On',
|
||||
group: 'Change State',
|
||||
valueChangedToTrue: function () {
|
||||
valueChangedToTrue() {
|
||||
if (this._internal.state === true) {
|
||||
return;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ const Switch = {
|
||||
off: {
|
||||
displayName: 'Off',
|
||||
group: 'Change State',
|
||||
valueChangedToTrue: function () {
|
||||
valueChangedToTrue() {
|
||||
if (this._internal.state === false) {
|
||||
return;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ const Switch = {
|
||||
flip: {
|
||||
displayName: 'Flip',
|
||||
group: 'Change State',
|
||||
valueChangedToTrue: function () {
|
||||
valueChangedToTrue() {
|
||||
this._internal.state = !this._internal.state;
|
||||
this.flagOutputDirty('state');
|
||||
this.emitSignals();
|
||||
@@ -50,7 +50,7 @@ const Switch = {
|
||||
displayName: 'State',
|
||||
group: 'General',
|
||||
default: false,
|
||||
set: function (value) {
|
||||
set(value) {
|
||||
this._internal.state = !!value;
|
||||
this.flagOutputDirty('state');
|
||||
this.emitSignals();
|
||||
@@ -61,10 +61,15 @@ const Switch = {
|
||||
state: {
|
||||
type: 'boolean',
|
||||
displayName: 'Current State',
|
||||
getter: function () {
|
||||
getter() {
|
||||
return this._internal.state;
|
||||
}
|
||||
},
|
||||
switched: {
|
||||
displayName: 'Switched',
|
||||
type: 'signal',
|
||||
group: 'Signals'
|
||||
},
|
||||
switchedToOn: {
|
||||
displayName: 'Switched To On',
|
||||
type: 'signal',
|
||||
@@ -77,12 +82,13 @@ const Switch = {
|
||||
}
|
||||
},
|
||||
prototypeExtensions: {
|
||||
emitSignals: function () {
|
||||
emitSignals() {
|
||||
if (this._internal.state === true) {
|
||||
this.sendSignalOnOutput('switchedToOn');
|
||||
} else {
|
||||
this.sendSignalOnOutput('switchedToOff');
|
||||
}
|
||||
this.sendSignalOnOutput('switched');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user