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

Merge branch 'master' of github.com:namgk/node-red

This commit is contained in:
Nam Giang 2019-08-14 15:02:51 -07:00
commit b30d519523

View File

@ -208,14 +208,33 @@
selectField.append($("<option></option>").val(operators[d].v).text(/^switch/.test(operators[d].t)?node._(operators[d].t):operators[d].t)); selectField.append($("<option></option>").val(operators[d].v).text(/^switch/.test(operators[d].t)?node._(operators[d].t):operators[d].t));
} }
} }
var valueField = $('<input/>',{class:"node-input-rule-value",type:"text",style:"margin-left: 5px;"}).appendTo(row).typedInput({default:'str',types:['msg','flow','global','str','num','jsonata','env',previousValueType]});
var numValueField = $('<input/>',{class:"node-input-rule-num-value",type:"text",style:"margin-left: 5px;"}).appendTo(row).typedInput({default:'num',types:['flow','global','num','jsonata','env']}); function createValueField(){
var expValueField = $('<input/>',{class:"node-input-rule-exp-value",type:"text",style:"margin-left: 5px;"}).appendTo(row).typedInput({default:'jsonata',types:['jsonata']}); return $('<input/>',{class:"node-input-rule-value",type:"text",style:"margin-left: 5px;"}).appendTo(row).typedInput({default:'str',types:['msg','flow','global','str','num','jsonata','env',previousValueType]});
var btwnValueField = $('<input/>',{class:"node-input-rule-btwn-value",type:"text",style:"margin-left: 5px;"}).appendTo(row).typedInput({default:'num',types:['msg','flow','global','str','num','jsonata','env',previousValueType]}); }
var btwnAndLabel = $('<span/>',{class:"node-input-rule-btwn-label"}).text(" "+andLabel+" ").appendTo(row3);
var btwnValue2Field = $('<input/>',{class:"node-input-rule-btwn-value2",type:"text",style:"margin-left:2px;"}).appendTo(row3).typedInput({default:'num',types:['msg','flow','global','str','num','jsonata','env',previousValueType]}); function createNumValueField(){
var typeValueField = $('<input/>',{class:"node-input-rule-type-value",type:"text",style:"margin-left: 5px;"}).appendTo(row) return $('<input/>',{class:"node-input-rule-num-value",type:"text",style:"margin-left: 5px;"}).appendTo(row).typedInput({default:'num',types:['flow','global','num','jsonata','env']});
.typedInput({default:'string',types:[ }
function createExpValueField(){
return $('<input/>',{class:"node-input-rule-exp-value",type:"text",style:"margin-left: 5px;"}).appendTo(row).typedInput({default:'jsonata',types:['jsonata']});
}
function createBtwnValueField(){
return $('<input/>',{class:"node-input-rule-btwn-value",type:"text",style:"margin-left: 5px;"}).appendTo(row).typedInput({default:'num',types:['msg','flow','global','str','num','jsonata','env',previousValueType]});
}
function createBtwnAndLabel(){
return $('<span/>',{class:"node-input-rule-btwn-label"}).text(" "+andLabel+" ").appendTo(row3);
}
function createBtwnValue2Field(){
return $('<input/>',{class:"node-input-rule-btwn-value2",type:"text",style:"margin-left:2px;"}).appendTo(row3).typedInput({default:'num',types:['msg','flow','global','str','num','jsonata','env',previousValueType]});
}
function createTypeValueField(){
return $('<input/>',{class:"node-input-rule-type-value",type:"text",style:"margin-left: 5px;"}).appendTo(row).typedInput({default:'string',types:[
{value:"string",label:"string",hasValue:false}, {value:"string",label:"string",hasValue:false},
{value:"number",label:"number",hasValue:false}, {value:"number",label:"number",hasValue:false},
{value:"boolean",label:"boolean",hasValue:false}, {value:"boolean",label:"boolean",hasValue:false},
@ -226,6 +245,15 @@
{value:"undefined",label:"undefined",hasValue:false}, {value:"undefined",label:"undefined",hasValue:false},
{value:"null",label:"null",hasValue:false} {value:"null",label:"null",hasValue:false}
]}); ]});
}
var valueField = null;
var numValueField = null;
var expValueField = null;
var btwnAndLabel = null;
var btwnValue2Field = 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);
@ -233,43 +261,49 @@
selectField.change(function() { selectField.change(function() {
resizeRule(container); resizeRule(container);
var type = selectField.val(); var type = selectField.val();
if ((type === "btwn") || (type === "index")) {
try {
valueField.typedInput('hide'); valueField.typedInput('hide');
} catch(e){}
try {
expValueField.typedInput('hide'); expValueField.typedInput('hide');
} catch(e){}
try {
numValueField.typedInput('hide'); numValueField.typedInput('hide');
} catch(e){}
try {
typeValueField.typedInput('hide'); typeValueField.typedInput('hide');
} catch(e){}
try {
btwnValue2Field.typedInput('hide');
} catch(e){}
if ((type === "btwn") || (type === "index")) {
if (!btwnValueField){
btwnValueField = createBtwnValueField();
}
btwnValueField.typedInput('show'); btwnValueField.typedInput('show');
} else if ((type === "head") || (type === "tail")) { } else if ((type === "head") || (type === "tail")) {
btwnValueField.typedInput('hide'); if (!numValueField){
btwnValue2Field.typedInput('hide'); numValueField = createNumValueField();
expValueField.typedInput('hide');
numValueField.typedInput('show');
typeValueField.typedInput('hide');
valueField.typedInput('hide');
} else if (type === "jsonata_exp") {
btwnValueField.typedInput('hide');
btwnValue2Field.typedInput('hide');
expValueField.typedInput('show');
numValueField.typedInput('hide');
typeValueField.typedInput('hide');
valueField.typedInput('hide');
} else {
btwnValueField.typedInput('hide');
expValueField.typedInput('hide');
numValueField.typedInput('hide');
typeValueField.typedInput('hide');
valueField.typedInput('hide');
if (type === "true" || type === "false" || type === "null" || type === "nnull" || type === "empty" || type === "nempty" || type === "else") {
valueField.typedInput('hide');
typeValueField.typedInput('hide');
} }
else numValueField.typedInput('show');
} else if (type === "jsonata_exp") {
if (!expValueField){
expValueField = createExpValueField();
}
expValueField.typedInput('show');
} else {
if (type === "istype") { if (type === "istype") {
valueField.typedInput('hide'); if (!typeValueField){
typeValueField = createTypeValueField();
}
typeValueField.typedInput('show'); typeValueField.typedInput('show');
} }
else { else {
typeValueField.typedInput('hide'); if (!valueField){
valueField = createValueField();
}
valueField.typedInput('show'); valueField.typedInput('show');
} }
} }
@ -279,6 +313,9 @@
} else if ((type === "btwn") || (type === "index")) { } else if ((type === "btwn") || (type === "index")) {
row2.hide(); row2.hide();
row3.show(); row3.show();
if (!btwnValue2Field){
btwnValue2Field = createBtwnValue2Field();
}
btwnValue2Field.typedInput('show'); btwnValue2Field.typedInput('show');
} else { } else {
row2.hide(); row2.hide();
@ -287,20 +324,39 @@
}); });
selectField.val(rule.t); selectField.val(rule.t);
if ((rule.t == "btwn") || (rule.t == "index")) { if ((rule.t == "btwn") || (rule.t == "index")) {
if (!btwnValueField){
btwnValueField = createBtwnValueField();
}
btwnValueField.typedInput('value',rule.v); btwnValueField.typedInput('value',rule.v);
btwnValueField.typedInput('type',rule.vt||'num'); btwnValueField.typedInput('type',rule.vt||'num');
if (!btwnValue2Field){
btwnValue2Field = createBtwnValue2Field();
}
btwnValue2Field.typedInput('value',rule.v2); btwnValue2Field.typedInput('value',rule.v2);
btwnValue2Field.typedInput('type',rule.v2t||'num'); btwnValue2Field.typedInput('type',rule.v2t||'num');
} else if ((rule.t === "head") || (rule.t === "tail")) { } else if ((rule.t === "head") || (rule.t === "tail")) {
if (!numValueField){
numValueField = createNumValueField();
}
numValueField.typedInput('value',rule.v); numValueField.typedInput('value',rule.v);
numValueField.typedInput('type',rule.vt||'num'); numValueField.typedInput('type',rule.vt||'num');
} else if (rule.t === "istype") { } else if (rule.t === "istype") {
if (!typeValueField){
typeValueField =createTypeValueField();
}
typeValueField.typedInput('value',rule.vt); typeValueField.typedInput('value',rule.vt);
typeValueField.typedInput('type',rule.vt); typeValueField.typedInput('type',rule.vt);
} else if (rule.t === "jsonata_exp") { } else if (rule.t === "jsonata_exp") {
if (!expValueField){
expValueField = createExpValueField();
}
expValueField.typedInput('value',rule.v); expValueField.typedInput('value',rule.v);
expValueField.typedInput('type',rule.vt||'jsonata'); expValueField.typedInput('type',rule.vt||'jsonata');
} else if (typeof rule.v != "undefined") { } else if (typeof rule.v != "undefined") {
if (!valueField){
valueField = createValueField();
}
valueField.typedInput('value',rule.v); valueField.typedInput('value',rule.v);
valueField.typedInput('type',rule.vt||'str'); valueField.typedInput('type',rule.vt||'str');
} }