UNPKG

red-contrib-processcube-testing

Version:
101 lines (81 loc) 3.61 kB
<script type="text/javascript"> RED.nodes.registerType('externaltask-input-inject', { category: 'ProcessCube Testing', color: '#02AFD6', defaults: { name: { value: '' }, externaltask: { value: '' } }, inputs: 1, outputs: 1, icon: 'externaltask_input.svg', label: function () { const nodes = RED.nodes.filterNodes({ type: 'externaltask-input' }); if (nodes && nodes.length > 0) { let foundNode = null; nodes.forEach((node) => { if (node.id === this.externaltask) { foundNode = node; } }); return foundNode ? `inject '${foundNode.name}'` : this.name || 'externaltask-input-inject'; } else { return this.name || 'externaltask-input-inject'; } }, oneditprepare: function () { try { var dropdown = $('#node-input-externaltask'); dropdown.empty(); const selectedValue = this.externaltask || ""; const localCallNodes = RED.nodes.filterNodes({ type: 'externaltask-input' }); if (!Array.isArray(localCallNodes)) { console.error("Expected an array from RED.nodes.filterNodes but got:", localCallNodes); return; } if (localCallNodes.length === 0) { console.warn("No externaltask-input nodes found."); dropdown.append($("<option></option>").attr("value", "").text("No available tasks")); } else { localCallNodes.forEach((node) => { let option = $("<option></option>") .attr("value", node.id) .text(`${node.name || "Unnamed"} (${node.id})`); if (node.id === selectedValue) { option.attr("selected", "selected"); } dropdown.append(option); }); } } catch (error) { console.error(error); } }, oneditsave: function () { this.externaltask = $('#node-input-externaltask').val(); } }); </script> <script type="text/html" data-template-name="externaltask-input-inject"> <div class="form-row"> <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name" /> </div> <div class="form-row"> <label for="node-input-externaltask"><i class="fa fa-tag"></i> External Task</label> <select id="node-input-externaltask"></select> </div> </script> <script type="text/markdown" data-help-name="externaltask-input-inject"> Send the incoming message to the external task. ## Configs : name (string) : The name of the node : externaltask (external-input) : The External task to inject the message ## Input : payload (string | {}) : The payload to send to the external task. ## Outputs : payload (string | {}) : The payload the result from the external task. ### References - [The ProcessCube&copy; Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; platform - [ProcessCube&copy; LowCode Integration](https://processcube.io/docs/node-red) - LowCode integration in ProcessCube&copy; </script>