Rework Subflow Instance property UI (#2236)

* Add support of Subflow UI definition

* new UI definition for env var

* fix label

* fixed value obtaining

* fixed label width

* fix checkbox

* fix subflow info

* remove old subflow ui tests

* add tests

* merge ui new changes

* fix initial open button

* fix environment variable edit tab

* WIP: cp-1

* Rework subflow ui property

* Restrict SF value type according to input selection

* Move subflow property UI code to subflow.js

* Update subflow ui type select appearance

* Present subflow instance properties as table rather than generated UI

* Move subflow instance properties to separate tab

* Fix subflow property ui element layout issues
This commit is contained in:
Nick O'Leary
2019-08-12 15:01:54 +01:00
committed by GitHub
parent c8acc6a12e
commit 880757fb5d
19 changed files with 2125 additions and 381 deletions

View File

@@ -447,4 +447,117 @@ describe('subflow', function() {
});
});
it('should access env var type of subflow instance', function(done) {
var flow = [
{id:"t0", type:"tab", label:"", disabled:false, info:""},
{id:"n1", x:10, y:10, z:"t0", type:"subflow:s1",
env: [
{name: "K", type: "str", value: "V"}
],
wires:[["n2"]]},
{id:"n2", x:10, y:10, z:"t0", type:"helper", wires:[]},
// Subflow
{id:"s1", type:"subflow", name:"Subflow", info:"",
in:[{
x:10, y:10,
wires:[ {id:"s1-n1"} ]
}],
out:[{
x:10, y:10,
wires:[ {id:"s1-n1", port:0} ]
}]
},
{id:"s1-n1", x:10, y:10, z:"s1", type:"function",
func:"msg.V = env.get('K_type'); return msg;",
wires:[]}
];
helper.load(functionNode, flow, function() {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
n2.on("input", function(msg) {
try {
msg.should.have.property("V", "str");
done();
}
catch (e) {
console.log(e);
done(e);
}
});
n1.receive({payload:"foo"});
});
});
it('should access env var info of subflow instance', function(done) {
var flow = [
{id:"t0", type:"tab", label:"", disabled:false, info:""},
{id:"n1", x:10, y:10, z:"t0", type:"subflow:s1",
env: [
{name: "K", type: "str", value: "V"}
],
wires:[["n2"]]},
{id:"n2", x:10, y:10, z:"t0", type:"helper", wires:[]},
// Subflow
{id:"s1", type:"subflow", name:"Subflow", info:"",
in:[{
x:10, y:10,
wires:[ {id:"s1-n1"} ]
}],
out:[{
x:10, y:10,
wires:[ {id:"s1-n1", port:0} ]
}],
env:[
{
name: "K", type: "str", value: "",
ui: {
hasUI: true,
icon: "icon",
labels: {
"en-US": "label"
},
type: "input",
inputTypes: {
str: true
}
}
}
]
},
{id:"s1-n1", x:10, y:10, z:"s1", type:"function",
func:"msg.V = env.get('K_info'); return msg;",
wires:[]}
];
helper.load(functionNode, flow, function() {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
n2.on("input", function(msg) {
try {
msg.should.have.property("V");
var v = msg.V;
v.should.have.property("name", "K");
v.should.have.property("value", "V");
v.should.have.property("type", "str");
v.should.have.property("ui");
var ui = v.ui;
ui.should.have.property("hasUI", true);
ui.should.have.property("icon", "icon");
ui.should.have.property("type", "input");
ui.should.have.property("labels");
var labels = ui.labels;
labels.should.have.property("en-US", "label");
ui.should.have.property("inputTypes");
var types = ui.inputTypes;
types.should.have.property("str", true);
done();
}
catch (e) {
console.log(e);
done(e);
}
});
n1.receive({payload:"foo"});
});
});
});