Skip to content

formSubmission event handler implementation #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion circuit/circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports = RED => {
['renewAccessTokenFailed', 'renewSessionTokenFailed'].forEach(elem => node.client.addEventListener(elem, evt => node.error(util.inspect(evt, { showHidden: true, depth: null }))));
// event listeners for all events that need to be "broadcasted" to all nodes.
['callStatus', 'callIncoming', 'callEnded', 'conversationUpdated', 'conversationCreated', 'itemUpdated', 'itemAdded',
'userSettingsChanged', 'userUpdated', 'userPresenceChanged', 'basicSearchResults']
'userSettingsChanged', 'userUpdated', 'userPresenceChanged', 'basicSearchResults', 'formSubmission']
.forEach(elem => node.client.addEventListener(elem, evt => node.broadcast(elem, evt)));

// subscribe and unsubscribe handling
Expand Down
7 changes: 7 additions & 0 deletions circuit/events.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
<input type="checkbox" id="node-input-userEvent" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-userEvent" style="width: 70%;"> User events</label>
</div>
<div class="form-row">
<label>Subscribe?</label>
<input type="checkbox" id="node-input-formEvent" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-formEvent" style="width: 70%;"> Form events</label>
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-bookmark"></i> Node name</label>
<input type="text" id="node-input-name" style="width: 70%;">
Expand All @@ -37,6 +42,7 @@
<li><code>Conversation Events</code> conversationUpdated, conversationCreated</li>
<li><code>Item Events</code> itemUpdated, itemAdded</li>
<li><code>User Events</code> userSettingsChanged, userUpdated</li>
<li><code>Form Events</code> formSubmission</li>
</ul>
You can check details about events on <a href="https://circuitsandbox.net/sdk/classes/Client.html#events" target="_blank">https://circuitsandbox.net/sdk</a>
</p>
Expand All @@ -52,6 +58,7 @@
convEvent: {value: true},
itemEvent: {value: true},
userEvent: {value: true},
formEvent: {value: true},
name: {value: '', required: false},
},
color: '#88C540',
Expand Down
4 changes: 4 additions & 0 deletions circuit/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = RED => {
node.convEvent = n.convEvent;
node.itemEvent = n.itemEvent;
node.userEvent = n.userEvent;
node.formEvent = n.formEvent;
node.server.subscribe(node.id, 'state', state => node.status(state));

if (node.callEvent) {
Expand All @@ -26,6 +27,9 @@ module.exports = RED => {
node.server.subscribe(node.id, 'userSettingsChanged', evt => node.send({ payload: evt.text }));
node.server.subscribe(node.id, 'userUpdated', evt => node.send({ payload: evt.text }));
}
if (node.formEvent) {
node.server.subscribe(node.id, 'formSubmission', evt => node.send({payload: evt.text}));
}
}
RED.nodes.registerType('Events', Events);
}