From aefae79186b6f5be6da73cc35688896cf61a8710 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 10 Apr 2017 11:29:52 +0100 Subject: [PATCH] Display config nodes in Info sidebar table --- editor/js/ui/tab-info.js | 31 ++++++++++++++++++++++++++----- editor/sass/palette.scss | 6 ++++-- editor/sass/tab-config.scss | 32 ++++++++++++++++---------------- editor/sass/tab-info.scss | 6 ++++++ 4 files changed, 52 insertions(+), 23 deletions(-) diff --git a/editor/js/ui/tab-info.js b/editor/js/ui/tab-info.js index 3a110ef2e..423777b02 100644 --- a/editor/js/ui/tab-info.js +++ b/editor/js/ui/tab-info.js @@ -134,7 +134,7 @@ RED.sidebar.info = (function() { $(propRow.children()[1]).html(' '+(node.label||"")) propRow = $(''+RED._("sidebar.info.id")+"").appendTo(tableBody); RED.utils.createObjectElement(node.id).appendTo(propRow.children()[1]); - propRow = $('State').appendTo(tableBody); + propRow = $('Status').appendTo(tableBody); $(propRow.children()[1]).html((!!!node.disabled)?"Enabled":"Disabled") } else { nodeSection.title.html("Node"); @@ -150,13 +150,34 @@ RED.sidebar.info = (function() { if (!m && node.type != "subflow" && node.type != "comment") { if (node._def) { var count = 0; - for (var n in node._def.defaults) { - if (n != "name" && node._def.defaults.hasOwnProperty(n)) { + var defaults = node._def.defaults; + for (var n in defaults) { + if (n != "name" && defaults.hasOwnProperty(n)) { var val = node[n]; var type = typeof val; count++; propRow = $(''+n+"").appendTo(tableBody); - RED.utils.createObjectElement(val).appendTo(propRow.children()[1]); + if (defaults[n].type) { + var configNode = RED.nodes.node(val); + if (!configNode) { + RED.utils.createObjectElement(undefined).appendTo(propRow.children()[1]); + } else { + var configLabel = RED.utils.getNodeLabel(configNode,val); + var nodeContainer = $('').appendTo(propRow.children()[1]); + var entry = $('') + .css({marginLeft:"5px",width:"calc(100% - 20px)"}).appendTo(nodeContainer); + $('
').text(configLabel).appendTo(entry); + var icon_url = RED.utils.getNodeIcon(node._def); + var iconContainer = $('
',{class:"palette_icon_container"}).appendTo(entry); + $('
',{class:"palette_icon",style:"background-image: url("+icon_url+")"}).appendTo(iconContainer); + + entry.dblclick(function(e) { + RED.editor.editConfig("", configNode.type, configNode.id); + }) + } + } else { + RED.utils.createObjectElement(val).appendTo(propRow.children()[1]); + } } } if (count > 0) { @@ -172,7 +193,7 @@ RED.sidebar.info = (function() { subflowNode = node; } - $(''+RED._("sidebar.info.subflow")+'').appendTo(tableBody); + $(''+RED._("sidebar.info.subflow")+'').appendTo(tableBody); var userCount = 0; var subflowType = "subflow:"+subflowNode.id; diff --git a/editor/sass/palette.scss b/editor/sass/palette.scss index 7441fbeb0..3bc457094 100644 --- a/editor/sass/palette.scss +++ b/editor/sass/palette.scss @@ -114,16 +114,18 @@ } .palette_label { font-size: 13px; - margin: 4px 0 4px 28px; + margin: 4px 0 4px 32px; line-height: 20px; overflow: hidden; text-align: center; + @include disable-selection; } .palette_label_right { - margin: 4px 28px 4px 0; + margin: 4px 32px 4px 0; } .palette_node { + display: block; cursor:move; background: #ddd; margin: 10px auto; diff --git a/editor/sass/tab-config.scss b/editor/sass/tab-config.scss index 7f4497063..8175cfdf3 100644 --- a/editor/sass/tab-config.scss +++ b/editor/sass/tab-config.scss @@ -25,6 +25,22 @@ .config-node-list { margin: 0; list-style-type: none; + + .palette_label { + margin-left: 8px; + line-height: 24px; + text-align: left; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + .palette_icon_container { + font-size: 12px; + line-height: 30px; + background-color: #e8e8e8; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + } } .config_node { width: 160px; @@ -32,22 +48,6 @@ background: #f3f3f3; color: #666; cursor: pointer; - - .palette_label { - margin-left: 8px; - line-height: 24px; - text-align: left; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } - .palette_icon_container { - font-size: 12px; - line-height: 30px; - background-color: #e8e8e8; - border-top-right-radius: 4px; - border-bottom-right-radius: 4px; - } } .config_node_type { color: #999; diff --git a/editor/sass/tab-info.scss b/editor/sass/tab-info.scss index 892ce9a87..8b8e0377c 100644 --- a/editor/sass/tab-info.scss +++ b/editor/sass/tab-info.scss @@ -258,3 +258,9 @@ div.node-info { margin-left: 4px; } } + +.node-info-property-config-node { + border: 1px solid #eee; + border-radius: 4px; + padding: 2px 4px 2px; +}