mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add new style tray editor
This commit is contained in:
parent
4ad540412a
commit
41b10fd5e4
@ -120,6 +120,7 @@ module.exports = function(grunt) {
|
|||||||
"editor/js/ui/tab-info.js",
|
"editor/js/ui/tab-info.js",
|
||||||
"editor/js/ui/tab-config.js",
|
"editor/js/ui/tab-config.js",
|
||||||
"editor/js/ui/editor.js",
|
"editor/js/ui/editor.js",
|
||||||
|
"editor/js/ui/tray.js",
|
||||||
"editor/js/ui/clipboard.js",
|
"editor/js/ui/clipboard.js",
|
||||||
"editor/js/ui/library.js",
|
"editor/js/ui/library.js",
|
||||||
"editor/js/ui/notifications.js",
|
"editor/js/ui/notifications.js",
|
||||||
|
@ -14,6 +14,11 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
RED.editor = (function() {
|
RED.editor = (function() {
|
||||||
|
|
||||||
|
|
||||||
|
var editStack = [];
|
||||||
|
|
||||||
|
|
||||||
var editing_node = null;
|
var editing_node = null;
|
||||||
var editing_config_node = null;
|
var editing_config_node = null;
|
||||||
var subflowEditor;
|
var subflowEditor;
|
||||||
@ -173,239 +178,8 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createDialog(){
|
function createDialog(){
|
||||||
$( "#dialog" ).dialog({
|
return;
|
||||||
modal: true,
|
|
||||||
autoOpen: false,
|
|
||||||
dialogClass: "ui-dialog-no-close",
|
|
||||||
closeOnEscape: false,
|
|
||||||
minWidth: 500,
|
|
||||||
width: 'auto',
|
|
||||||
buttons: [
|
|
||||||
{
|
|
||||||
id: "node-dialog-ok",
|
|
||||||
text: RED._("common.label.ok"),
|
|
||||||
click: function() {
|
|
||||||
if (editing_node) {
|
|
||||||
var changes = {};
|
|
||||||
var changed = false;
|
|
||||||
var wasDirty = RED.nodes.dirty();
|
|
||||||
var d;
|
|
||||||
|
|
||||||
if (editing_node._def.oneditsave) {
|
|
||||||
var oldValues = {};
|
|
||||||
for (d in editing_node._def.defaults) {
|
|
||||||
if (editing_node._def.defaults.hasOwnProperty(d)) {
|
|
||||||
if (typeof editing_node[d] === "string" || typeof editing_node[d] === "number") {
|
|
||||||
oldValues[d] = editing_node[d];
|
|
||||||
} else {
|
|
||||||
oldValues[d] = $.extend(true,{},{v:editing_node[d]}).v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var rc = editing_node._def.oneditsave.call(editing_node);
|
|
||||||
if (rc === true) {
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (d in editing_node._def.defaults) {
|
|
||||||
if (editing_node._def.defaults.hasOwnProperty(d)) {
|
|
||||||
if (oldValues[d] === null || typeof oldValues[d] === "string" || typeof oldValues[d] === "number") {
|
|
||||||
if (oldValues[d] !== editing_node[d]) {
|
|
||||||
changes[d] = oldValues[d];
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (JSON.stringify(oldValues[d]) !== JSON.stringify(editing_node[d])) {
|
|
||||||
changes[d] = oldValues[d];
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (editing_node._def.defaults) {
|
|
||||||
for (d in editing_node._def.defaults) {
|
|
||||||
if (editing_node._def.defaults.hasOwnProperty(d)) {
|
|
||||||
var input = $("#node-input-"+d);
|
|
||||||
var newValue;
|
|
||||||
if (input.attr('type') === "checkbox") {
|
|
||||||
newValue = input.prop('checked');
|
|
||||||
} else {
|
|
||||||
newValue = input.val();
|
|
||||||
}
|
|
||||||
if (newValue != null) {
|
|
||||||
if (d === "outputs" && (newValue.trim() === "" || isNaN(newValue))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (editing_node[d] != newValue) {
|
|
||||||
if (editing_node._def.defaults[d].type) {
|
|
||||||
if (newValue == "_ADD_") {
|
|
||||||
newValue = "";
|
|
||||||
}
|
|
||||||
// Change to a related config node
|
|
||||||
var configNode = RED.nodes.node(editing_node[d]);
|
|
||||||
if (configNode) {
|
|
||||||
var users = configNode.users;
|
|
||||||
users.splice(users.indexOf(editing_node),1);
|
|
||||||
}
|
|
||||||
configNode = RED.nodes.node(newValue);
|
|
||||||
if (configNode) {
|
|
||||||
configNode.users.push(editing_node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
changes[d] = editing_node[d];
|
|
||||||
editing_node[d] = newValue;
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (editing_node._def.credentials) {
|
|
||||||
var prefix = 'node-input';
|
|
||||||
var credDefinition = editing_node._def.credentials;
|
|
||||||
var credsChanged = updateNodeCredentials(editing_node,credDefinition,prefix);
|
|
||||||
changed = changed || credsChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
var removedLinks = updateNodeProperties(editing_node);
|
|
||||||
if (changed) {
|
|
||||||
var wasChanged = editing_node.changed;
|
|
||||||
editing_node.changed = true;
|
|
||||||
RED.nodes.dirty(true);
|
|
||||||
|
|
||||||
var activeSubflow = RED.nodes.subflow(RED.workspaces.active());
|
|
||||||
var subflowInstances = null;
|
|
||||||
if (activeSubflow) {
|
|
||||||
subflowInstances = [];
|
|
||||||
RED.nodes.eachNode(function(n) {
|
|
||||||
if (n.type == "subflow:"+RED.workspaces.active()) {
|
|
||||||
subflowInstances.push({
|
|
||||||
id:n.id,
|
|
||||||
changed:n.changed
|
|
||||||
});
|
|
||||||
n.changed = true;
|
|
||||||
n.dirty = true;
|
|
||||||
updateNodeProperties(n);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
var historyEvent = {
|
|
||||||
t:'edit',
|
|
||||||
node:editing_node,
|
|
||||||
changes:changes,
|
|
||||||
links:removedLinks,
|
|
||||||
dirty:wasDirty,
|
|
||||||
changed:wasChanged
|
|
||||||
};
|
};
|
||||||
if (subflowInstances) {
|
|
||||||
historyEvent.subflow = {
|
|
||||||
instances:subflowInstances
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RED.history.push(historyEvent);
|
|
||||||
}
|
|
||||||
editing_node.dirty = true;
|
|
||||||
validateNode(editing_node);
|
|
||||||
RED.view.redraw(true);
|
|
||||||
}
|
|
||||||
$( this ).dialog( "close" );
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "node-dialog-cancel",
|
|
||||||
text: RED._("common.label.cancel"),
|
|
||||||
click: function() {
|
|
||||||
if (editing_node && editing_node._def) {
|
|
||||||
if (editing_node._def.oneditcancel) {
|
|
||||||
editing_node._def.oneditcancel.call(editing_node);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var d in editing_node._def.defaults) {
|
|
||||||
if (editing_node._def.defaults.hasOwnProperty(d)) {
|
|
||||||
var def = editing_node._def.defaults[d];
|
|
||||||
if (def.type) {
|
|
||||||
var configTypeDef = RED.nodes.getType(def.type);
|
|
||||||
if (configTypeDef && configTypeDef.exclusive) {
|
|
||||||
var input = $("#node-input-"+d).val()||"";
|
|
||||||
if (input !== "" && !editing_node[d]) {
|
|
||||||
// This node has an exclusive config node that
|
|
||||||
// has just been added. As the user is cancelling
|
|
||||||
// the edit, need to delete the just-added config
|
|
||||||
// node so that it doesn't get orphaned.
|
|
||||||
RED.nodes.remove(input);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
$( this ).dialog( "close" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
resize: function(e,ui) {
|
|
||||||
if (editing_node) {
|
|
||||||
$(this).dialog('option',"sizeCache-"+editing_node.type,ui.size);
|
|
||||||
if (editing_node._def.oneditresize) {
|
|
||||||
var form = $("#dialog-form");
|
|
||||||
editing_node._def.oneditresize.call(editing_node,{width:form.width(),height:form.height()});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
open: function(e) {
|
|
||||||
var minWidth = $(this).dialog('option','minWidth');
|
|
||||||
if ($(this).outerWidth() < minWidth) {
|
|
||||||
$(this).dialog('option','width',minWidth);
|
|
||||||
} else {
|
|
||||||
$(this).dialog('option','width',$(this).outerWidth());
|
|
||||||
}
|
|
||||||
RED.keyboard.disable();
|
|
||||||
if (editing_node) {
|
|
||||||
var size = $(this).dialog('option','sizeCache-'+editing_node.type);
|
|
||||||
if (size) {
|
|
||||||
$(this).dialog('option','width',size.width);
|
|
||||||
$(this).dialog('option','height',size.height);
|
|
||||||
}
|
|
||||||
if (editing_node._def.oneditresize) {
|
|
||||||
setTimeout(function() {
|
|
||||||
var form = $("#dialog-form");
|
|
||||||
editing_node._def.oneditresize.call(editing_node,{width:form.width(),height:form.height()});
|
|
||||||
},0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
close: function(e) {
|
|
||||||
RED.keyboard.enable();
|
|
||||||
|
|
||||||
if (RED.view.state() != RED.state.IMPORT_DRAGGING) {
|
|
||||||
RED.view.state(RED.state.DEFAULT);
|
|
||||||
}
|
|
||||||
$( this ).dialog('option','height','auto');
|
|
||||||
$( this ).dialog('option','width','auto');
|
|
||||||
if (editing_node) {
|
|
||||||
RED.sidebar.info.refresh(editing_node);
|
|
||||||
}
|
|
||||||
RED.workspaces.refresh();
|
|
||||||
|
|
||||||
var buttons = $( this ).dialog("option","buttons");
|
|
||||||
if (buttons.length == 3) {
|
|
||||||
$( this ).dialog("option","buttons",buttons.splice(1));
|
|
||||||
}
|
|
||||||
editing_node = null;
|
|
||||||
}
|
|
||||||
}).parent().on('keydown', function(evt) {
|
|
||||||
if (evt.keyCode === $.ui.keyCode.ESCAPE && (evt.metaKey || evt.ctrlKey)) {
|
|
||||||
$("#node-dialog-cancel").click();
|
|
||||||
} else if (evt.keyCode === $.ui.keyCode.ENTER && (evt.metaKey || evt.ctrlKey)) {
|
|
||||||
$("#node-dialog-ok").click();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a config-node select box for this property
|
* Create a config-node select box for this property
|
||||||
@ -622,7 +396,8 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function showEditDialog(node) {
|
function showEditDialog(node) {
|
||||||
editing_node = node;
|
editStack.push({node:node});
|
||||||
|
var editing_node = node;
|
||||||
RED.view.state(RED.state.EDITING);
|
RED.view.state(RED.state.EDITING);
|
||||||
var type = node.type;
|
var type = node.type;
|
||||||
if (node.type.substring(0,8) == "subflow:") {
|
if (node.type.substring(0,8) == "subflow:") {
|
||||||
@ -639,14 +414,199 @@ RED.editor = (function() {
|
|||||||
});
|
});
|
||||||
$( "#dialog" ).dialog("option","buttons",buttons);
|
$( "#dialog" ).dialog("option","buttons",buttons);
|
||||||
}
|
}
|
||||||
$("#dialog-form").html($("script[data-template-name='"+type+"']").html());
|
var trayOptions = {
|
||||||
|
title: "Edit "+type+" node",
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
id: "node-dialog-ok",
|
||||||
|
text: RED._("common.label.ok"),
|
||||||
|
click: function() {
|
||||||
|
var editElement = editStack.pop();
|
||||||
|
if (editElement) {
|
||||||
|
var editing_node = editElement.node;
|
||||||
|
|
||||||
|
var changes = {};
|
||||||
|
var changed = false;
|
||||||
|
var wasDirty = RED.nodes.dirty();
|
||||||
|
var d;
|
||||||
|
|
||||||
|
if (editing_node._def.oneditsave) {
|
||||||
|
var oldValues = {};
|
||||||
|
for (d in editing_node._def.defaults) {
|
||||||
|
if (editing_node._def.defaults.hasOwnProperty(d)) {
|
||||||
|
if (typeof editing_node[d] === "string" || typeof editing_node[d] === "number") {
|
||||||
|
oldValues[d] = editing_node[d];
|
||||||
|
} else {
|
||||||
|
oldValues[d] = $.extend(true,{},{v:editing_node[d]}).v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var rc = editing_node._def.oneditsave.call(editing_node);
|
||||||
|
if (rc === true) {
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (d in editing_node._def.defaults) {
|
||||||
|
if (editing_node._def.defaults.hasOwnProperty(d)) {
|
||||||
|
if (oldValues[d] === null || typeof oldValues[d] === "string" || typeof oldValues[d] === "number") {
|
||||||
|
if (oldValues[d] !== editing_node[d]) {
|
||||||
|
changes[d] = oldValues[d];
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (JSON.stringify(oldValues[d]) !== JSON.stringify(editing_node[d])) {
|
||||||
|
changes[d] = oldValues[d];
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (editing_node._def.defaults) {
|
||||||
|
for (d in editing_node._def.defaults) {
|
||||||
|
if (editing_node._def.defaults.hasOwnProperty(d)) {
|
||||||
|
var input = $("#node-input-"+d);
|
||||||
|
var newValue;
|
||||||
|
if (input.attr('type') === "checkbox") {
|
||||||
|
newValue = input.prop('checked');
|
||||||
|
} else {
|
||||||
|
newValue = input.val();
|
||||||
|
}
|
||||||
|
if (newValue != null) {
|
||||||
|
if (d === "outputs" && (newValue.trim() === "" || isNaN(newValue))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (editing_node[d] != newValue) {
|
||||||
|
if (editing_node._def.defaults[d].type) {
|
||||||
|
if (newValue == "_ADD_") {
|
||||||
|
newValue = "";
|
||||||
|
}
|
||||||
|
// Change to a related config node
|
||||||
|
var configNode = RED.nodes.node(editing_node[d]);
|
||||||
|
if (configNode) {
|
||||||
|
var users = configNode.users;
|
||||||
|
users.splice(users.indexOf(editing_node),1);
|
||||||
|
}
|
||||||
|
configNode = RED.nodes.node(newValue);
|
||||||
|
if (configNode) {
|
||||||
|
configNode.users.push(editing_node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
changes[d] = editing_node[d];
|
||||||
|
editing_node[d] = newValue;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (editing_node._def.credentials) {
|
||||||
|
var prefix = 'node-input';
|
||||||
|
var credDefinition = editing_node._def.credentials;
|
||||||
|
var credsChanged = updateNodeCredentials(editing_node,credDefinition,prefix);
|
||||||
|
changed = changed || credsChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
var removedLinks = updateNodeProperties(editing_node);
|
||||||
|
if (changed) {
|
||||||
|
var wasChanged = editing_node.changed;
|
||||||
|
editing_node.changed = true;
|
||||||
|
RED.nodes.dirty(true);
|
||||||
|
|
||||||
|
var activeSubflow = RED.nodes.subflow(RED.workspaces.active());
|
||||||
|
var subflowInstances = null;
|
||||||
|
if (activeSubflow) {
|
||||||
|
subflowInstances = [];
|
||||||
|
RED.nodes.eachNode(function(n) {
|
||||||
|
if (n.type == "subflow:"+RED.workspaces.active()) {
|
||||||
|
subflowInstances.push({
|
||||||
|
id:n.id,
|
||||||
|
changed:n.changed
|
||||||
|
});
|
||||||
|
n.changed = true;
|
||||||
|
n.dirty = true;
|
||||||
|
updateNodeProperties(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var historyEvent = {
|
||||||
|
t:'edit',
|
||||||
|
node:editing_node,
|
||||||
|
changes:changes,
|
||||||
|
links:removedLinks,
|
||||||
|
dirty:wasDirty,
|
||||||
|
changed:wasChanged
|
||||||
|
};
|
||||||
|
if (subflowInstances) {
|
||||||
|
historyEvent.subflow = {
|
||||||
|
instances:subflowInstances
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RED.history.push(historyEvent);
|
||||||
|
}
|
||||||
|
editing_node.dirty = true;
|
||||||
|
validateNode(editing_node);
|
||||||
|
RED.view.redraw(true);
|
||||||
|
}
|
||||||
|
RED.tray.close();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "node-dialog-cancel",
|
||||||
|
text: RED._("common.label.cancel"),
|
||||||
|
click: function() {
|
||||||
|
var editElement = editStack.pop();
|
||||||
|
if (editElement && editElement.node._def) {
|
||||||
|
var editing_node = editElement.node;
|
||||||
|
if (editing_node._def.oneditcancel) {
|
||||||
|
editing_node._def.oneditcancel.call(editing_node);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var d in editing_node._def.defaults) {
|
||||||
|
if (editing_node._def.defaults.hasOwnProperty(d)) {
|
||||||
|
var def = editing_node._def.defaults[d];
|
||||||
|
if (def.type) {
|
||||||
|
var configTypeDef = RED.nodes.getType(def.type);
|
||||||
|
if (configTypeDef && configTypeDef.exclusive) {
|
||||||
|
var input = $("#node-input-"+d).val()||"";
|
||||||
|
if (input !== "" && !editing_node[d]) {
|
||||||
|
// This node has an exclusive config node that
|
||||||
|
// has just been added. As the user is cancelling
|
||||||
|
// the edit, need to delete the just-added config
|
||||||
|
// node so that it doesn't get orphaned.
|
||||||
|
RED.nodes.remove(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RED.tray.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
resize: function() {
|
||||||
|
var editing_node = editStack[editStack.length-1];
|
||||||
|
if (editing_node && editing_node.node._def.oneditresize) {
|
||||||
|
setTimeout(function() {
|
||||||
|
var form = $("#dialog-form");
|
||||||
|
editing_node.node._def.oneditresize.call(editing_node.node,{width:form.width(),height:form.height()});
|
||||||
|
},0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
open: function(trayBody) {
|
||||||
|
RED.keyboard.disable();
|
||||||
|
var dialogForm = $('<form id="dialog-form" class="form-horizontal"></form>').appendTo(trayBody);
|
||||||
|
dialogForm.html($("script[data-template-name='"+type+"']").html());
|
||||||
var ns;
|
var ns;
|
||||||
if (node._def.set.module === "node-red") {
|
if (node._def.set.module === "node-red") {
|
||||||
ns = "node-red";
|
ns = "node-red";
|
||||||
} else {
|
} else {
|
||||||
ns = node._def.set.id;
|
ns = node._def.set.id;
|
||||||
}
|
}
|
||||||
$("#dialog-form").find('[data-i18n]').each(function() {
|
dialogForm.find('[data-i18n]').each(function() {
|
||||||
var current = $(this).attr("data-i18n");
|
var current = $(this).attr("data-i18n");
|
||||||
var keys = current.split(";");
|
var keys = current.split(";");
|
||||||
for (var i=0;i<keys.length;i++) {
|
for (var i=0;i<keys.length;i++) {
|
||||||
@ -663,10 +623,51 @@ RED.editor = (function() {
|
|||||||
}
|
}
|
||||||
$(this).attr("data-i18n",keys.join(";"));
|
$(this).attr("data-i18n",keys.join(";"));
|
||||||
});
|
});
|
||||||
$('<input type="text" style="display: none;" />').appendTo("#dialog-form");
|
$('<input type="text" style="display: none;" />').prependTo(dialogForm);
|
||||||
prepareEditDialog(node,node._def,"node-input");
|
prepareEditDialog(node,node._def,"node-input");
|
||||||
$("#dialog").i18n();
|
dialogForm.i18n();
|
||||||
$( "#dialog" ).dialog("option","title","Edit "+type+" node").dialog( "open" );
|
|
||||||
|
// var minWidth = $(this).dialog('option','minWidth');
|
||||||
|
// if ($(this).outerWidth() < minWidth) {
|
||||||
|
// $(this).dialog('option','width',minWidth);
|
||||||
|
// } else {
|
||||||
|
// $(this).dialog('option','width',$(this).outerWidth());
|
||||||
|
// }
|
||||||
|
// if (editing_node) {
|
||||||
|
// var size = $(this).dialog('option','sizeCache-'+editing_node.type);
|
||||||
|
// if (size) {
|
||||||
|
// $(this).dialog('option','width',size.width);
|
||||||
|
// $(this).dialog('option','height',size.height);
|
||||||
|
// }
|
||||||
|
// if (editing_node._def.oneditresize) {
|
||||||
|
// setTimeout(function() {
|
||||||
|
// var form = $("#dialog-form");
|
||||||
|
// editing_node._def.oneditresize.call(editing_node,{width:form.width(),height:form.height()});
|
||||||
|
// },0);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
close: function() {
|
||||||
|
RED.keyboard.enable();
|
||||||
|
if (RED.view.state() != RED.state.IMPORT_DRAGGING) {
|
||||||
|
RED.view.state(RED.state.DEFAULT);
|
||||||
|
}
|
||||||
|
if (editing_node) {
|
||||||
|
RED.sidebar.info.refresh(editing_node);
|
||||||
|
}
|
||||||
|
RED.workspaces.refresh();
|
||||||
|
RED.tray.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*).parent().on('keydown', function(evt) {
|
||||||
|
if (evt.keyCode === $.ui.keyCode.ESCAPE && (evt.metaKey || evt.ctrlKey)) {
|
||||||
|
$("#node-dialog-cancel").click();
|
||||||
|
} else if (evt.keyCode === $.ui.keyCode.ENTER && (evt.metaKey || evt.ctrlKey)) {
|
||||||
|
$("#node-dialog-ok").click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
RED.tray.show(trayOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showEditConfigNodeDialog(name,type,id) {
|
function showEditConfigNodeDialog(name,type,id) {
|
||||||
@ -1163,7 +1164,6 @@ RED.editor = (function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function showEditSubflowDialog(subflow) {
|
function showEditSubflowDialog(subflow) {
|
||||||
editing_node = subflow;
|
editing_node = subflow;
|
||||||
RED.view.state(RED.state.EDITING);
|
RED.view.state(RED.state.EDITING);
|
||||||
@ -1186,8 +1186,9 @@ RED.editor = (function() {
|
|||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
init: function(){
|
init: function() {
|
||||||
createDialog();
|
RED.tray.init();
|
||||||
|
//createDialog();
|
||||||
createNodeConfigDialog();
|
createNodeConfigDialog();
|
||||||
createSubflowDialog();
|
createSubflowDialog();
|
||||||
},
|
},
|
||||||
|
@ -103,12 +103,12 @@ RED.sidebar = (function() {
|
|||||||
sidebarSeparator.chartWidth = $("#workspace").width();
|
sidebarSeparator.chartWidth = $("#workspace").width();
|
||||||
sidebarSeparator.chartRight = winWidth-$("#workspace").width()-$("#workspace").offset().left-2;
|
sidebarSeparator.chartRight = winWidth-$("#workspace").width()-$("#workspace").offset().left-2;
|
||||||
|
|
||||||
|
|
||||||
if (!RED.menu.isSelected("menu-item-sidebar")) {
|
if (!RED.menu.isSelected("menu-item-sidebar")) {
|
||||||
sidebarSeparator.opening = true;
|
sidebarSeparator.opening = true;
|
||||||
var newChartRight = 7;
|
var newChartRight = 7;
|
||||||
$("#sidebar").addClass("closing");
|
$("#sidebar").addClass("closing");
|
||||||
$("#workspace").css("right",newChartRight);
|
$("#workspace").css("right",newChartRight);
|
||||||
|
$("#editor-stack").css("right",newChartRight+1);
|
||||||
$("#sidebar").width(0);
|
$("#sidebar").width(0);
|
||||||
RED.menu.setSelected("menu-item-sidebar",true);
|
RED.menu.setSelected("menu-item-sidebar",true);
|
||||||
RED.events.emit("sidebar:resize");
|
RED.events.emit("sidebar:resize");
|
||||||
@ -147,6 +147,7 @@ RED.sidebar = (function() {
|
|||||||
|
|
||||||
var newChartRight = sidebarSeparator.chartRight-d;
|
var newChartRight = sidebarSeparator.chartRight-d;
|
||||||
$("#workspace").css("right",newChartRight);
|
$("#workspace").css("right",newChartRight);
|
||||||
|
$("#editor-stack").css("right",newChartRight+1);
|
||||||
$("#sidebar").width(newSidebarWidth);
|
$("#sidebar").width(newSidebarWidth);
|
||||||
|
|
||||||
sidebar_tabs.resize();
|
sidebar_tabs.resize();
|
||||||
@ -159,6 +160,7 @@ RED.sidebar = (function() {
|
|||||||
if ($("#sidebar").width() < 180) {
|
if ($("#sidebar").width() < 180) {
|
||||||
$("#sidebar").width(180);
|
$("#sidebar").width(180);
|
||||||
$("#workspace").css("right",187);
|
$("#workspace").css("right",187);
|
||||||
|
$("#editor-stack").css("right",188);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$("#sidebar-separator").css("left","auto");
|
$("#sidebar-separator").css("left","auto");
|
||||||
|
127
editor/js/ui/tray.js
Normal file
127
editor/js/ui/tray.js
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 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.tray = (function() {
|
||||||
|
|
||||||
|
var stack = [];
|
||||||
|
|
||||||
|
function resize() {
|
||||||
|
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
init: function() {
|
||||||
|
$( window ).resize(function() {
|
||||||
|
if (stack.length > 0) {
|
||||||
|
var tray = stack[stack.length-1];
|
||||||
|
var trayHeight = tray.tray.height()-tray.header.outerHeight()-tray.footer.outerHeight();
|
||||||
|
tray.body.height(trayHeight-40);
|
||||||
|
|
||||||
|
if (tray.options.resize) {
|
||||||
|
tray.options.resize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
show: function show(options) {
|
||||||
|
if (stack.length > 0) {
|
||||||
|
var oldTray = stack[stack.length-1];
|
||||||
|
oldTray.tray.css({
|
||||||
|
right: -(oldTray.tray.width()+10)+"px"
|
||||||
|
});
|
||||||
|
setTimeout(function() {
|
||||||
|
oldTray.tray.detach();
|
||||||
|
},400)
|
||||||
|
}
|
||||||
|
var el = $('<div class="editor-tray"></div>');
|
||||||
|
var header = $('<div class="editor-tray-header">'+(options.title||"")+'</div>').appendTo(el);
|
||||||
|
var body = $('<div class="editor-tray-body"></div>').appendTo(el);
|
||||||
|
var footer = $('<div class="editor-tray-footer"></div>').appendTo(el);
|
||||||
|
//'<form id="dialog-form" class="form-horizontal"></form>'+
|
||||||
|
// '<button type="button" id="node-dialog-ok">Ok</button>'+
|
||||||
|
// '<button type="button" id="node-dialog-cancel">Cancel</button>'+
|
||||||
|
if (options.buttons) {
|
||||||
|
for (var i=0;i<options.buttons.length;i++) {
|
||||||
|
var button = options.buttons[i];
|
||||||
|
|
||||||
|
var b = $('<button>').appendTo(footer);
|
||||||
|
if (button.id) {
|
||||||
|
b.attr('id',button.id);
|
||||||
|
}
|
||||||
|
if (button.text) {
|
||||||
|
b.text(button.text);
|
||||||
|
}
|
||||||
|
if (button.click) {
|
||||||
|
b.click(button.click);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
el.appendTo("#editor-stack");
|
||||||
|
var tray = {
|
||||||
|
tray: el,
|
||||||
|
header: header,
|
||||||
|
body: body,
|
||||||
|
footer: footer,
|
||||||
|
options: options
|
||||||
|
};
|
||||||
|
if (options.open) {
|
||||||
|
options.open(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#editor-shade").show();
|
||||||
|
el.css({
|
||||||
|
right: -(el.width()+10)+"px",
|
||||||
|
transition: "right 0.3s ease"
|
||||||
|
});
|
||||||
|
$("#workspace").scrollLeft(0);
|
||||||
|
|
||||||
|
stack.push(tray);
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
var trayHeight = el.height()-header.outerHeight()-footer.outerHeight();
|
||||||
|
body.height(trayHeight-40);
|
||||||
|
|
||||||
|
if (options.resize) {
|
||||||
|
options.resize();
|
||||||
|
}
|
||||||
|
el.css({right:0});
|
||||||
|
},0);
|
||||||
|
},
|
||||||
|
close: function close() {
|
||||||
|
if (stack.length > 0) {
|
||||||
|
var tray = stack.pop();
|
||||||
|
tray.tray.css({
|
||||||
|
right: -(tray.tray.width()+10)+"px"
|
||||||
|
});
|
||||||
|
setTimeout(function() {
|
||||||
|
if (tray.options.close) {
|
||||||
|
tray.options.close();
|
||||||
|
}
|
||||||
|
tray.tray.remove();
|
||||||
|
if (stack.length > 0) {
|
||||||
|
var oldTray = stack[stack.length-1];
|
||||||
|
oldTray.tray.appendTo("#editor-stack");
|
||||||
|
setTimeout(function() {
|
||||||
|
oldTray.tray.css({right:0});
|
||||||
|
},0);
|
||||||
|
}
|
||||||
|
},400)
|
||||||
|
if (stack.length === 0) {
|
||||||
|
$("#editor-shade").hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
@ -14,6 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
$background-color: #f3f3f3;
|
||||||
|
|
||||||
$form-placeholder-color: #bbbbbb;
|
$form-placeholder-color: #bbbbbb;
|
||||||
$form-text-color: #444;
|
$form-text-color: #444;
|
||||||
$form-input-focus-color: rgba(85,150,230,0.8);
|
$form-input-focus-color: rgba(85,150,230,0.8);
|
||||||
@ -45,6 +47,8 @@ $workspace-button-color-hover: #666;
|
|||||||
$workspace-button-color-active: #666;
|
$workspace-button-color-active: #666;
|
||||||
$workspace-button-color-selected: #AAA;
|
$workspace-button-color-selected: #AAA;
|
||||||
|
|
||||||
|
$workspace-button-color-focus-outline: rgba(85,150,230,0.2);
|
||||||
|
|
||||||
$typedInput-button-background: #efefef;
|
$typedInput-button-background: #efefef;
|
||||||
$typedInput-button-background-hover: #ddd;
|
$typedInput-button-background-hover: #ddd;
|
||||||
$typedInput-button-background-active: #e3e3e3;
|
$typedInput-button-background-active: #e3e3e3;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
.dialog-form, #dialog-form, #dialog-config-form {
|
.dialog-form,#dialog-form, #dialog-config-form {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
@ -62,10 +62,13 @@
|
|||||||
background: $workspace-button-background-active;
|
background: $workspace-button-background-active;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button-group &:not(:first-child) {
|
.button-group &:not(:first-child) {
|
||||||
border-left: none;
|
border-left: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: 1px solid $workspace-button-color-focus-outline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@mixin workspace-button-toggle {
|
@mixin workspace-button-toggle {
|
||||||
@include workspace-button;
|
@include workspace-button;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
width: 315px;
|
width: 315px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
z-index: 100;
|
||||||
@include component-border;
|
@include component-border;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,13 +47,15 @@
|
|||||||
right: 315px;
|
right: 315px;
|
||||||
bottom:10px;
|
bottom:10px;
|
||||||
width: 7px;
|
width: 7px;
|
||||||
background: url(images/grip.png) no-repeat 50% 50%;
|
z-index: 101;
|
||||||
|
background: $background-color url(images/grip.png) no-repeat 50% 50%;
|
||||||
cursor: col-resize;
|
cursor: col-resize;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-closed > #sidebar { display: none; }
|
.sidebar-closed > #sidebar { display: none; }
|
||||||
.sidebar-closed > #sidebar-separator { right: 0px !important; }
|
.sidebar-closed > #sidebar-separator { right: 0px !important; }
|
||||||
.sidebar-closed > #workspace { right: 7px !important; }
|
.sidebar-closed > #workspace { right: 7px !important; }
|
||||||
|
.sidebar-closed > #editor-stack { right: 8px !important; }
|
||||||
|
|
||||||
#sidebar .button {
|
#sidebar .button {
|
||||||
@include workspace-button;
|
@include workspace-button;
|
||||||
|
@ -52,7 +52,7 @@ body {
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
|
font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
|
||||||
padding-top: 100px;
|
padding-top: 100px;
|
||||||
background: #f3f3f3;
|
background: $background-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main-container {
|
#main-container {
|
||||||
|
@ -50,6 +50,64 @@
|
|||||||
margin-right: 35px;
|
margin-right: 35px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#editor-stack {
|
||||||
|
position: absolute;
|
||||||
|
margin: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0px;
|
||||||
|
right: 323px;
|
||||||
|
width: 0;
|
||||||
|
}
|
||||||
|
.editor-tray {
|
||||||
|
position:absolute;
|
||||||
|
margin: 0;
|
||||||
|
top: 0;
|
||||||
|
min-width: 500px;
|
||||||
|
width: auto;
|
||||||
|
right: -1000px;
|
||||||
|
bottom: 0;
|
||||||
|
background: #fff;
|
||||||
|
border-left: 1px solid $primary-border-color;
|
||||||
|
border-bottom: 1px solid $primary-border-color;
|
||||||
|
box-sizing: content-box;
|
||||||
|
box-shadow: -1px 0 10px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
.editor-tray.open {
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
.editor-tray-body {
|
||||||
|
width: auto;
|
||||||
|
padding: 20px;
|
||||||
|
min-width: 500px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
.editor-tray-header {
|
||||||
|
padding: 10px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-weight: bold;
|
||||||
|
height: 40px;
|
||||||
|
border-bottom: 1px solid $primary-border-color;
|
||||||
|
background: $palette-header-background;
|
||||||
|
}
|
||||||
|
.editor-tray-footer {
|
||||||
|
@include component-footer;
|
||||||
|
height: auto;
|
||||||
|
padding: 8px;
|
||||||
|
button {
|
||||||
|
@include workspace-button;
|
||||||
|
padding: 0.4em 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#editor-shade {
|
||||||
|
position: absolute;
|
||||||
|
top:0;
|
||||||
|
bottom:0;
|
||||||
|
left:0;
|
||||||
|
right:0;
|
||||||
|
background: rgba(220,220,220,0.5);
|
||||||
|
}
|
||||||
#workspace-add-tab {
|
#workspace-add-tab {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
@ -65,6 +65,19 @@
|
|||||||
<a class="workspace-footer-button" id="btn-zoom-in" href="#"><i class="fa fa-plus"></i></a>
|
<a class="workspace-footer-button" id="btn-zoom-in" href="#"><i class="fa fa-plus"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="editor-shade" class="hide"></div>
|
||||||
|
<div id="editor-stack">
|
||||||
|
<!--
|
||||||
|
<div class="workspace-tray-header"></div>
|
||||||
|
<div class="workspace-tray-body">
|
||||||
|
<form id="dialog-form" class="form-horizontal"></form>
|
||||||
|
</div>
|
||||||
|
<div class="workspace-tray-footer">
|
||||||
|
<button type="button" id="node-dialog-ok">Ok</button>
|
||||||
|
<button type="button" id="node-dialog-cancel">Cancel</button>
|
||||||
|
</div>
|
||||||
|
-->
|
||||||
|
</div>
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
<ul id="sidebar-tabs"></ul>
|
<ul id="sidebar-tabs"></ul>
|
||||||
<div id="sidebar-content"></div>
|
<div id="sidebar-content"></div>
|
||||||
@ -78,7 +91,7 @@
|
|||||||
<div id="notifications"></div>
|
<div id="notifications"></div>
|
||||||
<div id="dropTarget"><div data-i18n="[append]workspace.dropFlowHere"><br/><i class="fa fa-download"></i></div></div>
|
<div id="dropTarget"><div data-i18n="[append]workspace.dropFlowHere"><br/><i class="fa fa-download"></i></div></div>
|
||||||
|
|
||||||
<div id="dialog" class="hide"><form id="dialog-form" class="form-horizontal"></form></div>
|
<div id="dialog2" class="hide"><form id="dialog-form2" class="form-horizontal"></form></div>
|
||||||
<div id="node-config-dialog" class="hide"><form id="dialog-config-form" class="form-horizontal"><div id="node-config-dialog-edit-form"></div><!--<div id="node-config-dialog-toolbar" class="form-row"><label><span>Node scope</span></label><select id="node-config-dialog-scope"></select></div>--></form></div>
|
<div id="node-config-dialog" class="hide"><form id="dialog-config-form" class="form-horizontal"><div id="node-config-dialog-edit-form"></div><!--<div id="node-config-dialog-toolbar" class="form-row"><label><span>Node scope</span></label><select id="node-config-dialog-scope"></select></div>--></form></div>
|
||||||
<div id="subflow-dialog" class="hide">
|
<div id="subflow-dialog" class="hide">
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
|
Loading…
Reference in New Issue
Block a user