1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add description to flow same as subflow

This commit is contained in:
Kazuki-Nakanishi 2017-03-17 01:29:19 +09:00
parent fb24dca019
commit 38a950a6dc
5 changed files with 39 additions and 7 deletions

View File

@ -277,7 +277,8 @@ RED.nodes = (function() {
ws._def = {
defaults: {
label: {value:""},
disabled: {value: false}
disabled: {value: false},
info: {value: ""}
}
};

View File

@ -109,7 +109,7 @@ RED.sidebar.info = (function() {
$("<tr><td>"+RED._("sidebar.info.instances")+"</td><td>"+userCount+"</td></tr>").appendTo(tableBody);
}
if (!m && node.type != "subflow" && node.type != "comment") {
if (!m && node.type != "subflow" && node.type != "comment" && node.type != "tab") {
$('<tr class="blank"><td colspan="2"><a href="#" class="node-info-property-header"><i style="width: 10px; text-align: center;" class="fa fa-caret-'+(propertiesExpanded?"down":"right")+'"></i> '+RED._("sidebar.info.properties")+'</a></td></tr>').appendTo(tableBody);
if (node._def) {
for (var n in node._def.defaults) {
@ -124,12 +124,14 @@ RED.sidebar.info = (function() {
}
$(table).appendTo(content);
$("<hr/>").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($('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(helpText)+'">'+helpText+'</span></div>').appendTo(content));
}
if (subflowNode) {
addTargetToExternalLinks($('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(subflowNode.info||"")+'">'+marked(subflowNode.info||"")+'</span></div>').appendTo(content));
} else if (node.type == "tab") {
addTargetToExternalLinks($('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(node.info||"")+'">'+marked(node.info||"")+'</span></div>').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();
}
}
}
});

View File

@ -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 = $('<form id="dialog-form" class="form-horizontal"></form>').appendTo(trayBody);
@ -131,6 +141,16 @@ RED.workspaces = (function() {
'<input type="checkbox" id="node-input-disabled" style="display: none;"/>'+
'</div>').appendTo(dialogForm);
$('<div class="form-row node-text-editor-row">'+
'<label for="node-input-info" data-i18n="editor:workspace.info"></label>'+
'<div style="height: 250px;" class="node-text-editor" id="node-input-info"></div>'+
'</div>').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() {
$('<input type="text" style="display: none;" />').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);

View File

@ -21,7 +21,8 @@
"dropFlowHere": "Drop the flow here",
"status": "Status",
"enabled": "Enabled",
"disabled":"Disabled"
"disabled":"Disabled",
"info": "Description"
},
"menu": {
"label": {

View File

@ -18,7 +18,8 @@
"editFlow": "フローを編集: __name__",
"confirmDelete": "削除の確認",
"delete": "本当に '__label__' を削除しますか?",
"dropFlowHere": "ここにフローをドロップしてください"
"dropFlowHere": "ここにフローをドロップしてください",
"info": "詳細"
},
"menu": {
"label": {