/** * Copyright 2013, 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. **/ RED.history = (function() { var undo_history = []; return { //TODO: this function is a placeholder until there is a 'save' event that can be listened to markAllDirty: function() { for (var i=0;i 0) { subflow = RED.nodes.subflow(ev.subflowInputs[0].z); subflow.in.push(ev.subflowInputs[0]); subflow.in[0].dirty = true; } if (ev.subflowOutputs && ev.subflowOutputs.length > 0) { subflow = RED.nodes.subflow(ev.subflowOutputs[0].z); ev.subflowOutputs.sort(function(a,b) { return a.i-b.i}); for (i=0;i= output.i) { l.sourcePort++; } } }); } } if (ev.subflow && ev.subflow.hasOwnProperty('instances')) { ev.subflow.instances.forEach(function(n) { var node = RED.nodes.node(n.id); if (node) { node.changed = n.changed; node.dirty = true; } }); } if (subflow) { RED.nodes.filterNodes({type:"subflow:"+subflow.id}).forEach(function(n) { n.inputs = subflow.in.length; n.outputs = subflow.out.length; while (n.outputs > n.ports.length) { n.ports.push(n.ports.length); } n.resize = true; n.dirty = true; }); } if (ev.nodes) { for (i=0;i ev.subflow.inputCount) { ev.node.in.splice(ev.subflow.inputCount); } else if (ev.subflow.inputs.length > 0) { ev.node.in = ev.node.in.concat(ev.subflow.inputs); } } if (ev.subflow.hasOwnProperty('outputCount')) { if (ev.node.out.length > ev.subflow.outputCount) { ev.node.out.splice(ev.subflow.outputCount); } else if (ev.subflow.outputs.length > 0) { ev.node.out = ev.node.out.concat(ev.subflow.outputs); } } if (ev.subflow.hasOwnProperty('instances')) { ev.subflow.instances.forEach(function(n) { var node = RED.nodes.node(n.id); if (node) { node.changed = n.changed; node.dirty = true; } }); } RED.nodes.filterNodes({type:"subflow:"+ev.node.id}).forEach(function(n) { n.inputs = ev.node.in.length; n.outputs = ev.node.out.length; RED.editor.updateNodeProperties(n); }); } else { var outputMap; if (ev.outputMap) { outputMap = {}; for (var port in ev.outputMap) { if (ev.outputMap.hasOwnProperty(port) && ev.outputMap[port] !== -1) { outputMap[ev.outputMap[port]] = port; } } } RED.editor.updateNodeProperties(ev.node,outputMap); RED.editor.validateNode(ev.node); } if (ev.links) { for (i=0;i