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

Fix up dynamic generation of switch ui

This commit is contained in:
Nick O'Leary 2019-08-21 12:39:51 +01:00
parent 0d680a58f3
commit 8307f26099
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -251,17 +251,16 @@
var numValueField = null; var numValueField = null;
var expValueField = null; var expValueField = null;
var btwnAndLabel = null; var btwnAndLabel = null;
var btwnValueField = null;
var btwnValue2Field = null; var btwnValue2Field = null;
var typeValueField = null; var typeValueField = null;
var finalspan = $('<span/>',{style:"float: right;margin-top: 6px;"}).appendTo(row); var finalspan = $('<span/>',{style:"float: right;margin-top: 6px;"}).appendTo(row);
finalspan.append(' &#8594; <span class="node-input-rule-index">'+(i+1)+'</span> '); finalspan.append(' &#8594; <span class="node-input-rule-index">'+(i+1)+'</span> ');
var caseSensitive = $('<input/>',{id:"node-input-rule-case-"+i,class:"node-input-rule-case",type:"checkbox",style:"width:auto;vertical-align:top"}).appendTo(row2); var caseSensitive = $('<input/>',{id:"node-input-rule-case-"+i,class:"node-input-rule-case",type:"checkbox",style:"width:auto;vertical-align:top"}).appendTo(row2);
$('<label/>',{for:"node-input-rule-case-"+i,style:"margin-left: 3px;"}).text(caseLabel).appendTo(row2); $('<label/>',{for:"node-input-rule-case-"+i,style:"margin-left: 3px;"}).text(caseLabel).appendTo(row2);
selectField.change(function() { selectField.change(function() {
resizeRule(container);
var type = selectField.val(); var type = selectField.val();
if (valueField){ if (valueField){
valueField.typedInput('hide'); valueField.typedInput('hide');
} }
@ -274,10 +273,13 @@
if (typeValueField){ if (typeValueField){
typeValueField.typedInput('hide'); typeValueField.typedInput('hide');
} }
if (btwnValueField){
btwnValueField.typedInput('hide');
}
if (btwnValue2Field){ if (btwnValue2Field){
btwnValue2Field.typedInput('hide'); btwnValue2Field.typedInput('hide');
} }
if ((type === "btwn") || (type === "index")) { if ((type === "btwn") || (type === "index")) {
if (!btwnValueField){ if (!btwnValueField){
btwnValueField = createBtwnValueField(); btwnValueField = createBtwnValueField();
@ -293,19 +295,16 @@
expValueField = createExpValueField(); expValueField = createExpValueField();
} }
expValueField.typedInput('show'); expValueField.typedInput('show');
} else { } else if (type === "istype") {
if (type === "istype") { if (!typeValueField){
if (!typeValueField){ typeValueField = createTypeValueField();
typeValueField = createTypeValueField();
}
typeValueField.typedInput('show');
} }
else { typeValueField.typedInput('show');
} else if (! (type === "true" || type === "false" || type === "null" || type === "nnull" || type === "empty" || type === "nempty" || type === "else" )) {
if (!valueField){ if (!valueField){
valueField = createValueField(); valueField = createValueField();
} }
valueField.typedInput('show'); valueField.typedInput('show');
}
} }
if (type === "regex") { if (type === "regex") {
row2.show(); row2.show();
@ -321,6 +320,8 @@
row2.hide(); row2.hide();
row3.hide(); row3.hide();
} }
resizeRule(container);
}); });
selectField.val(rule.t); selectField.val(rule.t);
if ((rule.t == "btwn") || (rule.t == "index")) { if ((rule.t == "btwn") || (rule.t == "index")) {