mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add node/editor lifecycle events
This commit is contained in:
parent
3cac48e86f
commit
bea8eb799f
@ -195,6 +195,7 @@ RED.nodes = (function() {
|
|||||||
}
|
}
|
||||||
nodes.push(n);
|
nodes.push(n);
|
||||||
}
|
}
|
||||||
|
RED.events.emit('nodes:add',n);
|
||||||
}
|
}
|
||||||
function addLink(l) {
|
function addLink(l) {
|
||||||
links.push(l);
|
links.push(l);
|
||||||
@ -220,6 +221,7 @@ RED.nodes = (function() {
|
|||||||
if (id in configNodes) {
|
if (id in configNodes) {
|
||||||
node = configNodes[id];
|
node = configNodes[id];
|
||||||
delete configNodes[id];
|
delete configNodes[id];
|
||||||
|
RED.events.emit('nodes:remove',node);
|
||||||
RED.workspaces.refresh();
|
RED.workspaces.refresh();
|
||||||
} else {
|
} else {
|
||||||
node = getNode(id);
|
node = getNode(id);
|
||||||
@ -252,6 +254,7 @@ RED.nodes = (function() {
|
|||||||
if (updatedConfigNode) {
|
if (updatedConfigNode) {
|
||||||
RED.workspaces.refresh();
|
RED.workspaces.refresh();
|
||||||
}
|
}
|
||||||
|
RED.events.emit('nodes:remove',node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (node && node._def.onremove) {
|
if (node && node._def.onremove) {
|
||||||
|
@ -545,6 +545,9 @@ RED.editor = (function() {
|
|||||||
|
|
||||||
function showEditDialog(node) {
|
function showEditDialog(node) {
|
||||||
var editing_node = node;
|
var editing_node = node;
|
||||||
|
if (editStack.length === 0) {
|
||||||
|
RED.events.emit("editor:open");
|
||||||
|
}
|
||||||
editStack.push(node);
|
editStack.push(node);
|
||||||
RED.view.state(RED.state.EDITING);
|
RED.view.state(RED.state.EDITING);
|
||||||
var type = node.type;
|
var type = node.type;
|
||||||
@ -713,6 +716,7 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
editing_node.dirty = true;
|
editing_node.dirty = true;
|
||||||
validateNode(editing_node);
|
validateNode(editing_node);
|
||||||
|
RED.events.emit("editor:save",editing_node);
|
||||||
RED.tray.close();
|
RED.tray.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -770,6 +774,7 @@ RED.editor = (function() {
|
|||||||
editStack.pop();
|
editStack.pop();
|
||||||
if (editStack.length === 0) {
|
if (editStack.length === 0) {
|
||||||
RED.view.focus();
|
RED.view.focus();
|
||||||
|
RED.events.emit("editor:close");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
show: function() {
|
show: function() {
|
||||||
@ -832,6 +837,9 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
editing_config_node["_"] = node_def._;
|
editing_config_node["_"] = node_def._;
|
||||||
}
|
}
|
||||||
|
if (editStack.length === 0) {
|
||||||
|
RED.events.emit("editor:open");
|
||||||
|
}
|
||||||
editStack.push(editing_config_node);
|
editStack.push(editing_config_node);
|
||||||
|
|
||||||
RED.view.state(RED.state.EDITING);
|
RED.view.state(RED.state.EDITING);
|
||||||
@ -924,6 +932,7 @@ RED.editor = (function() {
|
|||||||
editStack.pop();
|
editStack.pop();
|
||||||
if (editStack.length === 0) {
|
if (editStack.length === 0) {
|
||||||
RED.view.focus();
|
RED.view.focus();
|
||||||
|
RED.events.emit("editor:close");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
show: function() {
|
show: function() {
|
||||||
@ -1054,6 +1063,9 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
RED.nodes.dirty(true);
|
RED.nodes.dirty(true);
|
||||||
RED.view.redraw(true);
|
RED.view.redraw(true);
|
||||||
|
if (!configAdding) {
|
||||||
|
RED.events.emit("editor:save",editing_config_node);
|
||||||
|
}
|
||||||
RED.tray.close(function() {
|
RED.tray.close(function() {
|
||||||
updateConfigNodeSelect(configProperty,configType,editing_config_node.id,prefix);
|
updateConfigNodeSelect(configProperty,configType,editing_config_node.id,prefix);
|
||||||
});
|
});
|
||||||
@ -1083,7 +1095,6 @@ RED.editor = (function() {
|
|||||||
changes: {},
|
changes: {},
|
||||||
dirty: RED.nodes.dirty()
|
dirty: RED.nodes.dirty()
|
||||||
}
|
}
|
||||||
RED.nodes.remove(configId);
|
|
||||||
for (var i=0;i<editing_config_node.users.length;i++) {
|
for (var i=0;i<editing_config_node.users.length;i++) {
|
||||||
var user = editing_config_node.users[i];
|
var user = editing_config_node.users[i];
|
||||||
historyEvent.changes[user.id] = {
|
historyEvent.changes[user.id] = {
|
||||||
@ -1100,6 +1111,7 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
validateNode(user);
|
validateNode(user);
|
||||||
}
|
}
|
||||||
|
RED.nodes.remove(configId);
|
||||||
RED.nodes.dirty(true);
|
RED.nodes.dirty(true);
|
||||||
RED.view.redraw(true);
|
RED.view.redraw(true);
|
||||||
RED.history.push(historyEvent);
|
RED.history.push(historyEvent);
|
||||||
@ -1115,6 +1127,9 @@ RED.editor = (function() {
|
|||||||
|
|
||||||
function showEditSubflowDialog(subflow) {
|
function showEditSubflowDialog(subflow) {
|
||||||
var editing_node = subflow;
|
var editing_node = subflow;
|
||||||
|
if (editStack.length === 0) {
|
||||||
|
RED.events.emit("editor:open");
|
||||||
|
}
|
||||||
editStack.push(subflow);
|
editStack.push(subflow);
|
||||||
RED.view.state(RED.state.EDITING);
|
RED.view.state(RED.state.EDITING);
|
||||||
var subflowEditor;
|
var subflowEditor;
|
||||||
@ -1260,6 +1275,7 @@ RED.editor = (function() {
|
|||||||
editing_node = null;
|
editing_node = null;
|
||||||
if (editStack.length === 0) {
|
if (editStack.length === 0) {
|
||||||
RED.view.focus();
|
RED.view.focus();
|
||||||
|
RED.events.emit("editor:close");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
show: function() {
|
show: function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user