Auto help

This commit is contained in:
2020-02-22 12:23:08 +01:00
parent 73ef52b939
commit 4e1f900326
2 changed files with 133 additions and 9 deletions
+26 -1
View File
@@ -136,6 +136,8 @@
whiteSpace: 'nowrap'
});
var row = $('<div/>').appendTo(container);
var row2 = $('<div/>').appendTo(container);
var row3 = $('<div/>').appendTo(container);
var selectField = $('<select/>', { style: "width:120px; margin-left: 5px; text-align: center;" }).appendTo(row);
var group0 = $('<optgroup/>', { label: "value rules" }).appendTo(selectField);
for (var d in operators) {
@@ -166,9 +168,23 @@
var typeValueField = null;
var finalspan = $('<span/>', { style: "float: right;margin-top: 6px;" }).appendTo(row);
var desc_label = $('<span/>', {style:"width:100px;display:inline-block;"}).text("Help:").appendTo(row2);
var desc = $('<input/>', { class: "node-input-rule-help", type: "text", style: "margin-left: 5px; width:250px", placeholder:"Help description" }).appendTo(row2);
desc.val(rule.help || "");
var desc_label = $('<span/>', {style:"width:100px;display:inline-block;"}).text("Variable:").appendTo(row3);
var match_name = $('<input/>', { class: "node-input-rule-match_name", type: "text", style: "margin-left: 5px; width: 250px;", placeholder:"Matched variable name" }).appendTo(row3);
match_name.val(rule.match_name || "");
if (rule.type !== "regex") {
row3.hide();
}
finalspan.append(' &#8594; <span class="node-input-rule-index">' + (i + 1) + '</span> ');
selectField.on("change", function () {
var type = selectField.val();
if (type == "regex") {
row3.show();
} else {
row3.hide();
}
valueField.typedInput('hide');
if (!valueField) {
valueField = createValueField();
@@ -234,6 +250,10 @@
var r = { t: type };
r.v = rule.find(".node-input-rule-value").typedInput('value');
r.vt = rule.find(".node-input-rule-value").typedInput('type');
r.help = rule.find(".node-input-rule-help").val();
if(r.t == 'regex') {
r.match_name = rule.find(".node-input-rule-match_name").val();
}
node.rules.push(r);
});
this.propertyType = $("#node-input-property").typedInput('type');
@@ -264,6 +284,10 @@
<label for="node-input-property"><i class="fa fa-ellipsis-h"></i> Property:</label>
<input type="text" id="node-input-property" style="width: 70%"/>
</div>
<div class="form-row">
<label for="node-input-help_keyword"><i class="fa fa-ellipsis-h"></i> Help keyword:</label>
<input type="text" id="node-input-help_keyword" style="width: 70%"/>
</div>
<div class="form-row node-text-editor-row">
<input type="hidden" id="node-input-help_text" autofocus="autofocus">
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-help_text-editor"></div>
@@ -279,7 +303,8 @@
defaults: {
property: { value: "payload", required: true, validate: RED.validators.typedInput("propertyType") },
name: { value: "" },
help_text: {value: ""}
help_text: {value: ""},
help_keyword: {value: "help"},
},
inputs: 1,
outputs: 2,