mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Reduce churn in setting Switch rule typedInput type
This commit is contained in:
parent
0cc061196d
commit
8158487c3e
@ -117,30 +117,35 @@
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createValueField(row){
|
function createValueField(row, defaultType){
|
||||||
return $('<input/>',{class:"node-input-rule-value",type:"text",style:"width: 100%;"}).appendTo(row).typedInput({default:'str',types:['msg','flow','global','str','num','jsonata','env',previousValueType]});
|
return $('<input/>',{class:"node-input-rule-value",type:"text",style:"width: 100%;"}).appendTo(row)
|
||||||
|
.typedInput({default:defaultType||'str',types:['msg','flow','global','str','num','jsonata','env',previousValueType]});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNumValueField(row){
|
function createNumValueField(row, defaultType){
|
||||||
return $('<input/>',{class:"node-input-rule-num-value",type:"text",style:"width: 100%;"}).appendTo(row).typedInput({default:'num',types:['flow','global','num','jsonata','env']});
|
return $('<input/>',{class:"node-input-rule-num-value",type:"text",style:"width: 100%;"}).appendTo(row)
|
||||||
|
.typedInput({default:defaultType||'num',types:['flow','global','num','jsonata','env']});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createExpValueField(row){
|
function createExpValueField(row){
|
||||||
return $('<input/>',{class:"node-input-rule-exp-value",type:"text",style:"width: 100%;"}).appendTo(row).typedInput({default:'jsonata',types:['jsonata']});
|
return $('<input/>',{class:"node-input-rule-exp-value",type:"text",style:"width: 100%;"}).appendTo(row)
|
||||||
|
.typedInput({default:'jsonata',types:['jsonata']});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createBtwnValueField(row){
|
function createBtwnValueField(row, defaultType){
|
||||||
return $('<input/>',{class:"node-input-rule-btwn-value",type:"text",style:"width: 100%;"}).appendTo(row).typedInput({default:'num',types:['msg','flow','global','str','num','jsonata','env',previousValueType]});
|
return $('<input/>',{class:"node-input-rule-btwn-value",type:"text",style:"width: 100%;"}).appendTo(row)
|
||||||
|
.typedInput({default:defaultType||'num',types:['msg','flow','global','str','num','jsonata','env',previousValueType]});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createBtwnValue2Field(row3, andLabel){
|
function createBtwnValue2Field(row3, andLabel, defaultType){
|
||||||
$('<div/>',{class:"node-input-rule-btwn-label", style:"width: 120px; text-align: right;"}).text(" "+andLabel+" ").appendTo(row3);
|
$('<div/>',{class:"node-input-rule-btwn-label", style:"width: 120px; text-align: right;"}).text(" "+andLabel+" ").appendTo(row3);
|
||||||
var row3InputCell = $('<div/>',{style:"flex-grow:1; margin-left: 5px;"}).appendTo(row3);
|
var row3InputCell = $('<div/>',{style:"flex-grow:1; margin-left: 5px;"}).appendTo(row3);
|
||||||
return $('<input/>',{class:"node-input-rule-btwn-value2",type:"text",style:"width: 100%"}).appendTo(row3InputCell).typedInput({default:'num',types:['msg','flow','global','str','num','jsonata','env',previousValueType]});
|
return $('<input/>',{class:"node-input-rule-btwn-value2",type:"text",style:"width: 100%"}).appendTo(row3InputCell)
|
||||||
|
.typedInput({default:defaultType||'num',types:['msg','flow','global','str','num','jsonata','env',previousValueType]});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTypeValueField(){
|
function createTypeValueField(row, defaultType){
|
||||||
return $('<input/>',{class:"node-input-rule-type-value",type:"text",style:"width: 100%;"}).appendTo(row).typedInput({default:'string',types:[
|
return $('<input/>',{class:"node-input-rule-type-value",type:"text",style:"width: 100%;"}).appendTo(row).typedInput({default:defaultType || 'string',types:[
|
||||||
{value:"string",label:RED._("common.type.string"),hasValue:false,icon:"red/images/typedInput/az.png"},
|
{value:"string",label:RED._("common.type.string"),hasValue:false,icon:"red/images/typedInput/az.png"},
|
||||||
{value:"number",label:RED._("common.type.number"),hasValue:false,icon:"red/images/typedInput/09.png"},
|
{value:"number",label:RED._("common.type.number"),hasValue:false,icon:"red/images/typedInput/09.png"},
|
||||||
{value:"boolean",label:RED._("common.type.boolean"),hasValue:false,icon:"red/images/typedInput/bool.png"},
|
{value:"boolean",label:RED._("common.type.boolean"),hasValue:false,icon:"red/images/typedInput/bool.png"},
|
||||||
@ -279,24 +284,12 @@
|
|||||||
selectField.on("change", function() {
|
selectField.on("change", function() {
|
||||||
var fieldToFocus;
|
var fieldToFocus;
|
||||||
var type = selectField.val();
|
var type = selectField.val();
|
||||||
if (valueField){
|
if (valueField) { valueField.typedInput('hide'); }
|
||||||
valueField.typedInput('hide');
|
if (expValueField) { expValueField.typedInput('hide'); }
|
||||||
}
|
if (numValueField) { numValueField.typedInput('hide'); }
|
||||||
if (expValueField){
|
if (typeValueField) { typeValueField.typedInput('hide'); }
|
||||||
expValueField.typedInput('hide');
|
if (btwnValueField) { btwnValueField.typedInput('hide'); }
|
||||||
}
|
if (btwnValue2Field) { btwnValue2Field.typedInput('hide'); }
|
||||||
if (numValueField){
|
|
||||||
numValueField.typedInput('hide');
|
|
||||||
}
|
|
||||||
if (typeValueField){
|
|
||||||
typeValueField.typedInput('hide');
|
|
||||||
}
|
|
||||||
if (btwnValueField){
|
|
||||||
btwnValueField.typedInput('hide');
|
|
||||||
}
|
|
||||||
if (btwnValue2Field){
|
|
||||||
btwnValue2Field.typedInput('hide');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((type === "btwn") || (type === "index")) {
|
if ((type === "btwn") || (type === "index")) {
|
||||||
if (!btwnValueField){
|
if (!btwnValueField){
|
||||||
@ -319,7 +312,7 @@
|
|||||||
|
|
||||||
} else if (type === "istype") {
|
} else if (type === "istype") {
|
||||||
if (!typeValueField){
|
if (!typeValueField){
|
||||||
typeValueField = createTypeValueField();
|
typeValueField = createTypeValueField(rowInputCell);
|
||||||
}
|
}
|
||||||
typeValueField.typedInput('show');
|
typeValueField.typedInput('show');
|
||||||
fieldToFocus = typeValueField;
|
fieldToFocus = typeValueField;
|
||||||
@ -362,48 +355,26 @@
|
|||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
selectField.val(rule.t);
|
selectField.val(rule.t);
|
||||||
if ((rule.t == "btwn") || (rule.t == "index")) {
|
|
||||||
if (!btwnValueField){
|
|
||||||
btwnValueField = createBtwnValueField(rowInputCell);
|
|
||||||
}
|
|
||||||
btwnValueField.typedInput('value',rule.v);
|
|
||||||
btwnValueField.typedInput('type',rule.vt||'num');
|
|
||||||
|
|
||||||
if (!btwnValue2Field){
|
if ((rule.t == "btwn") || (rule.t == "index")) {
|
||||||
btwnValue2Field = createBtwnValue2Field(row3, andLabel);
|
btwnValueField = createBtwnValueField(rowInputCell,rule.vt||'num');
|
||||||
}
|
btwnValueField.typedInput('value',rule.v);
|
||||||
|
btwnValue2Field = createBtwnValue2Field(row3, andLabel,rule.v2t||'num');
|
||||||
btwnValue2Field.typedInput('value',rule.v2);
|
btwnValue2Field.typedInput('value',rule.v2);
|
||||||
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(rowInputCell,rule.vt||'num');
|
||||||
numValueField = createNumValueField(row);
|
|
||||||
}
|
|
||||||
numValueField.typedInput('value',rule.v);
|
numValueField.typedInput('value',rule.v);
|
||||||
numValueField.typedInput('type',rule.vt||'num');
|
|
||||||
} else if (rule.t === "istype") {
|
} else if (rule.t === "istype") {
|
||||||
if (!typeValueField){
|
typeValueField = createTypeValueField(rowInputCell,rule.vt);
|
||||||
typeValueField =createTypeValueField();
|
|
||||||
}
|
|
||||||
typeValueField.typedInput('value',rule.vt);
|
typeValueField.typedInput('value',rule.vt);
|
||||||
typeValueField.typedInput('type',rule.vt);
|
|
||||||
} else if (rule.t === "jsonata_exp") {
|
} else if (rule.t === "jsonata_exp") {
|
||||||
if (!expValueField){
|
expValueField = createExpValueField(rowInputCell,rule.vt||'jsonata');
|
||||||
expValueField = createExpValueField(row);
|
|
||||||
}
|
|
||||||
expValueField.typedInput('value',rule.v);
|
expValueField.typedInput('value',rule.v);
|
||||||
expValueField.typedInput('type',rule.vt||'jsonata');
|
|
||||||
} else if (typeof rule.v != "undefined") {
|
} else if (typeof rule.v != "undefined") {
|
||||||
if (!valueField){
|
valueField = createValueField(rowInputCell,rule.vt||'str');
|
||||||
valueField = createValueField(rowInputCell);
|
|
||||||
}
|
|
||||||
valueField.typedInput('value',rule.v);
|
valueField.typedInput('value',rule.v);
|
||||||
valueField.typedInput('type',rule.vt||'str');
|
|
||||||
}
|
|
||||||
if (rule.case) {
|
|
||||||
caseSensitive.prop('checked',true);
|
|
||||||
} else {
|
|
||||||
caseSensitive.prop('checked',false);
|
|
||||||
}
|
}
|
||||||
|
caseSensitive.prop('checked',!!rule.case);
|
||||||
selectField.change();
|
selectField.change();
|
||||||
|
|
||||||
var currentOutputs = JSON.parse(outputCount.val()||"{}");
|
var currentOutputs = JSON.parse(outputCount.val()||"{}");
|
||||||
|
Loading…
Reference in New Issue
Block a user