From 38a950a6dc9e02329446dc748e87b4e2183c1437 Mon Sep 17 00:00:00 2001 From: Kazuki-Nakanishi Date: Fri, 17 Mar 2017 01:29:19 +0900 Subject: [PATCH] Add description to flow same as subflow --- editor/js/nodes.js | 3 ++- editor/js/ui/tab-info.js | 13 ++++++++++--- editor/js/ui/workspaces.js | 24 +++++++++++++++++++++++- red/api/locales/en-US/editor.json | 3 ++- red/api/locales/ja/editor.json | 3 ++- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/editor/js/nodes.js b/editor/js/nodes.js index 5d8f59d2a..957bd6dd9 100644 --- a/editor/js/nodes.js +++ b/editor/js/nodes.js @@ -277,7 +277,8 @@ RED.nodes = (function() { ws._def = { defaults: { label: {value:""}, - disabled: {value: false} + disabled: {value: false}, + info: {value: ""} } }; diff --git a/editor/js/ui/tab-info.js b/editor/js/ui/tab-info.js index f96fbdbf3..78129f6ea 100644 --- a/editor/js/ui/tab-info.js +++ b/editor/js/ui/tab-info.js @@ -109,7 +109,7 @@ RED.sidebar.info = (function() { $(""+RED._("sidebar.info.instances")+""+userCount+"").appendTo(tableBody); } - if (!m && node.type != "subflow" && node.type != "comment") { + if (!m && node.type != "subflow" && node.type != "comment" && node.type != "tab") { $(' '+RED._("sidebar.info.properties")+'').appendTo(tableBody); if (node._def) { for (var n in node._def.defaults) { @@ -124,12 +124,14 @@ RED.sidebar.info = (function() { } $(table).appendTo(content); $("
").appendTo(content); - if (!subflowNode && node.type != "comment") { + if (!subflowNode && node.type != "comment" && node.type != "tab") { var helpText = $("script[data-help-name$='"+node.type+"']").html()||""; addTargetToExternalLinks($('
'+helpText+'
').appendTo(content)); } if (subflowNode) { addTargetToExternalLinks($('
'+marked(subflowNode.info||"")+'
').appendTo(content)); + } else if (node.type == "tab") { + addTargetToExternalLinks($('
'+marked(node.info||"")+'
').appendTo(content)); } else if (node._def && node._def.info) { var info = node._def.info; var textInfo = (typeof info === "function" ? info.call(node) : info); @@ -262,7 +264,12 @@ RED.sidebar.info = (function() { if (subflow) { refresh(subflow); } else { - clear(); + var workspace = RED.nodes.workspace(RED.workspaces.active()); + if (workspace.info) { + refresh(workspace); + } else { + clear(); + } } } }); diff --git a/editor/js/ui/workspaces.js b/editor/js/ui/workspaces.js index f058cce8d..558a24e0c 100644 --- a/editor/js/ui/workspaces.js +++ b/editor/js/ui/workspaces.js @@ -59,6 +59,7 @@ RED.workspaces = (function() { function showRenameWorkspaceDialog(id) { var workspace = RED.nodes.workspace(id); RED.view.state(RED.state.EDITING); + var tabflowEditor; var trayOptions = { title: RED._("workspace.editFlow",{name:workspace.label}), buttons: [ @@ -98,6 +99,12 @@ RED.workspaces = (function() { changed = true; workspace.disabled = disabled; } + var info = tabflowEditor.getValue(); + if (workspace.info !== info) { + changes.info = workspace.info; + changed = true; + workspace.info = info; + } $("#red-ui-tab-"+(workspace.id.replace(".","-"))).toggleClass('workspace-disabled',workspace.disabled); // $("#workspace").toggleClass("workspace-disabled",workspace.disabled); @@ -117,6 +124,9 @@ RED.workspaces = (function() { } } ], + resize: function(dimensions) { + tabflowEditor.resize(); + }, open: function(tray) { var trayBody = tray.find('.editor-tray-body'); var dialogForm = $('
').appendTo(trayBody); @@ -131,6 +141,16 @@ RED.workspaces = (function() { ''+ '').appendTo(dialogForm); + $('
'+ + ''+ + '
'+ + '
').appendTo(dialogForm); + tabflowEditor = RED.editor.createEditor({ + id: 'node-input-info', + mode: 'ace/mode/markdown', + value: "" + }); + dialogForm.find('#node-input-disabled-btn').on("click",function(e) { var i = $(this).find("i"); if (i.hasClass('fa-toggle-off')) { @@ -162,13 +182,15 @@ RED.workspaces = (function() { $('').prependTo(dialogForm); dialogForm.submit(function(e) { e.preventDefault();}); $("#node-input-name").val(workspace.label); - RED.text.bidi.prepareInput($("#node-input-name")) + RED.text.bidi.prepareInput($("#node-input-name")); + tabflowEditor.getSession().setValue(workspace.info || "", -1); dialogForm.i18n(); }, close: function() { if (RED.view.state() != RED.state.IMPORT_DRAGGING) { RED.view.state(RED.state.DEFAULT); } + RED.sidebar.info.refresh(workspace); } } RED.tray.show(trayOptions); diff --git a/red/api/locales/en-US/editor.json b/red/api/locales/en-US/editor.json index 369589eb4..28ccf5c55 100644 --- a/red/api/locales/en-US/editor.json +++ b/red/api/locales/en-US/editor.json @@ -21,7 +21,8 @@ "dropFlowHere": "Drop the flow here", "status": "Status", "enabled": "Enabled", - "disabled":"Disabled" + "disabled":"Disabled", + "info": "Description" }, "menu": { "label": { diff --git a/red/api/locales/ja/editor.json b/red/api/locales/ja/editor.json index e52fef916..8846f7c15 100644 --- a/red/api/locales/ja/editor.json +++ b/red/api/locales/ja/editor.json @@ -18,7 +18,8 @@ "editFlow": "フローを編集: __name__", "confirmDelete": "削除の確認", "delete": "本当に '__label__' を削除しますか?", - "dropFlowHere": "ここにフローをドロップしてください" + "dropFlowHere": "ここにフローをドロップしてください", + "info": "詳細" }, "menu": { "label": {