@gregoriusrippenstein/erlang-red-unittest 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +14 -0
- package/nodes/locales/en-US/ut-assert-debug.html +4 -0
- package/nodes/locales/en-US/ut-assert-debug.json +16 -0
- package/nodes/locales/en-US/ut-assert-failure.html +6 -0
- package/nodes/locales/en-US/ut-assert-failure.json +14 -0
- package/nodes/locales/en-US/ut-assert-status.html +4 -0
- package/nodes/locales/en-US/ut-assert-status.json +17 -0
- package/nodes/locales/en-US/ut-assert-success.html +6 -0
- package/nodes/locales/en-US/ut-assert-success.json +15 -0
- package/nodes/locales/en-US/ut-assert-values.html +9 -0
- package/nodes/locales/en-US/ut-assert-values.json +57 -0
- package/nodes/ut-assert-debug.html +164 -0
- package/nodes/ut-assert-debug.js +38 -0
- package/nodes/ut-assert-failure.html +64 -0
- package/nodes/ut-assert-failure.js +38 -0
- package/nodes/ut-assert-status.html +199 -0
- package/nodes/ut-assert-status.js +38 -0
- package/nodes/ut-assert-success.html +64 -0
- package/nodes/ut-assert-success.js +38 -0
- package/nodes/ut-assert-values.html +288 -0
- package/nodes/ut-assert-values.js +120 -0
- package/package.json +34 -0
- package/plugins/sidebar.html +608 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
(function(){
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function frontendSupportFunction() {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
var functTwo = (arg) => {
|
|
9
|
+
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
RED.nodes.registerType('ut-assert-status',{
|
|
13
|
+
color: '#C0DEED',
|
|
14
|
+
icon: "font-awesome/fa-window-minimize",
|
|
15
|
+
category: 'testing',
|
|
16
|
+
paletteLabel: 'Assert Status',
|
|
17
|
+
defaults: {
|
|
18
|
+
name: {
|
|
19
|
+
value:"",
|
|
20
|
+
},
|
|
21
|
+
nodeid: {
|
|
22
|
+
value: "",
|
|
23
|
+
required: true
|
|
24
|
+
},
|
|
25
|
+
content: {
|
|
26
|
+
value: "",
|
|
27
|
+
},
|
|
28
|
+
colour: {
|
|
29
|
+
value: "grey",
|
|
30
|
+
required: true
|
|
31
|
+
},
|
|
32
|
+
shape: {
|
|
33
|
+
value: "dot",
|
|
34
|
+
required: true
|
|
35
|
+
},
|
|
36
|
+
inverse: {
|
|
37
|
+
value: false,
|
|
38
|
+
required: true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
inputs: 0,
|
|
43
|
+
|
|
44
|
+
outputs: 0,
|
|
45
|
+
|
|
46
|
+
label: function() {
|
|
47
|
+
if ( this.nodeid && !this.name) {
|
|
48
|
+
let nodeLabel = `[${this.nodeid}]`;
|
|
49
|
+
let node = RED.nodes.node(this.nodeid)
|
|
50
|
+
if (node) {
|
|
51
|
+
nodeLabel = RED.utils.getNodeLabel(node)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if ( this.inverse ) {
|
|
55
|
+
return `Assert No Status for ${nodeLabel}`
|
|
56
|
+
} else {
|
|
57
|
+
return `Assert Status for ${nodeLabel}: ${this.colour} ${this.shape}`
|
|
58
|
+
}
|
|
59
|
+
} else { return (this.name || this._def.paletteLabel) }
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
labelStyle: function() {
|
|
63
|
+
return (this.name || this.nodeid) ? "node_label_italic" : "";
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
onpaletteadd: function() {
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
onpaletteremove: function() {
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
oneditprepare: function() {
|
|
73
|
+
$('#node-input-inverse').on('change', () => {
|
|
74
|
+
if ($('#node-input-inverse').is(":checked")) {
|
|
75
|
+
$('#ut-assert-status-opts-to-hide-on-inverse').fadeOut(300);
|
|
76
|
+
} else {
|
|
77
|
+
$('#ut-assert-status-opts-to-hide-on-inverse').fadeIn(300);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
var dirList = $("#node-input-assert-status-target-container-div").css({
|
|
82
|
+
width: "100%",
|
|
83
|
+
height: "calc(100%)"
|
|
84
|
+
}).treeList(
|
|
85
|
+
{
|
|
86
|
+
multi: false
|
|
87
|
+
}
|
|
88
|
+
).on('treelistselect', function (event, item) {
|
|
89
|
+
if (item && item.nodeid) {
|
|
90
|
+
RED.view.reveal(item.nodeid);
|
|
91
|
+
RED.view.select(item.nodeid);
|
|
92
|
+
}
|
|
93
|
+
}).on('treelistconfirm', function (event, item) {
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
var search = $("#node-input-assert-status-target-filter").searchBox({
|
|
97
|
+
style: "compact",
|
|
98
|
+
delay: 300,
|
|
99
|
+
change: function () {
|
|
100
|
+
var val = $(this).val().trim().toLowerCase();
|
|
101
|
+
if (val === "") {
|
|
102
|
+
dirList.treeList("filter", null);
|
|
103
|
+
search.searchBox("count", "");
|
|
104
|
+
} else {
|
|
105
|
+
var count = dirList.treeList("filter", function (item) {
|
|
106
|
+
return item.label.toLowerCase().indexOf(val) > -1 || item.sublabel.toLowerCase().indexOf(val) > -1
|
|
107
|
+
});
|
|
108
|
+
search.searchBox("count", count + " / " + dirList.treeList("data").length);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
let data = RED.nodes.filterNodes({ z: RED.workspaces.active() }).filter(n => n.id != this.id).map(nde => {
|
|
114
|
+
return {
|
|
115
|
+
label: RED.utils.getNodeLabel(nde),
|
|
116
|
+
icon: "",
|
|
117
|
+
nodeid: nde.id,
|
|
118
|
+
sublabel: nde.type,
|
|
119
|
+
selected: nde.id == this.nodeid,
|
|
120
|
+
checkbox: false,
|
|
121
|
+
radio: true,
|
|
122
|
+
children: undefined
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
dirList.treeList('data', data)
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
oneditcancel: function() {
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
oneditsave: function() {
|
|
133
|
+
this.nodeid = $("#node-input-assert-status-target-container-div").treeList('selected').nodeid;
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
oneditresize: function(size) {
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
});
|
|
141
|
+
})();
|
|
142
|
+
|
|
143
|
+
</script>
|
|
144
|
+
|
|
145
|
+
<script type="text/html" data-template-name="ut-assert-status">
|
|
146
|
+
<div class="form-row">
|
|
147
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
|
|
148
|
+
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
<div class="form-row">
|
|
152
|
+
<input type="checkbox" id="node-input-inverse"
|
|
153
|
+
style="display:inline-block; width:15px; vertical-align:baseline;">
|
|
154
|
+
<label for="node-input-inverse"><span data-i18n="ut-assert-status.label.inverse"></span></label>
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
<div id="ut-assert-status-opts-to-hide-on-inverse">
|
|
158
|
+
<div class="form-row">
|
|
159
|
+
<label for="node-input-content"><i class="fa fa-tag"></i> <span data-i18n="ut-assert-status.label.content"></span></label>
|
|
160
|
+
<input type="text" id="node-input-content" data-i18n="[placeholder]ut-assert-status.label.content">
|
|
161
|
+
</div>
|
|
162
|
+
|
|
163
|
+
<div class="form-row">
|
|
164
|
+
<label for="node-input-colour">
|
|
165
|
+
<i class="fa fa-tag"></i>
|
|
166
|
+
<span>Colour</span>
|
|
167
|
+
</label>
|
|
168
|
+
|
|
169
|
+
<select id="node-input-colour">
|
|
170
|
+
<option value="red" selected=selected>Red</option>
|
|
171
|
+
<option value="grey">Grey</option>
|
|
172
|
+
<option value="blue">Blue</option>
|
|
173
|
+
<option value="yellow">Yellow</option>
|
|
174
|
+
<option value="green">Green</option>
|
|
175
|
+
</select>
|
|
176
|
+
</div>
|
|
177
|
+
|
|
178
|
+
<div class="form-row">
|
|
179
|
+
<label for="node-input-shape">
|
|
180
|
+
<i class="fa fa-tag"></i>
|
|
181
|
+
<span>Shape</span>
|
|
182
|
+
</label>
|
|
183
|
+
|
|
184
|
+
<select id="node-input-shape">
|
|
185
|
+
<option value="dot" selected=selected>Dot</option>
|
|
186
|
+
<option value="ring">Ring</option>
|
|
187
|
+
</select>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
<div class="form-row" style="margin-left: 10px; position: relative; height: 40vh; margin-right: 15px; min-height: 5vh;"">
|
|
193
|
+
<div style=" margin-bottom: 5px; width: 35%; padding-left: 60%;">
|
|
194
|
+
<input type="text" id="node-input-assert-status-target-filter">
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
<div id="node-input-assert-status-target-container-div"></div>
|
|
198
|
+
</div>
|
|
199
|
+
</script>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module.exports = function(RED) {
|
|
2
|
+
function Coreut_assert_statusFunctionality(config) {
|
|
3
|
+
RED.nodes.createNode(this,config);
|
|
4
|
+
|
|
5
|
+
var node = this;
|
|
6
|
+
var cfg = config;
|
|
7
|
+
|
|
8
|
+
node.on('close', function() {
|
|
9
|
+
node.status({});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
/* msg handler, in this case pass the message on unchanged */
|
|
13
|
+
node.on("input", function(msg, send, done) {
|
|
14
|
+
// How to send a status update
|
|
15
|
+
node.status({ fill: "green", shape: "ring", text: RED._("ut-assert-status.label.statusset") });
|
|
16
|
+
|
|
17
|
+
// Send a message and how to handle errors.
|
|
18
|
+
try {
|
|
19
|
+
try {
|
|
20
|
+
send(msg);
|
|
21
|
+
done();
|
|
22
|
+
} catch ( err ) {
|
|
23
|
+
// use node.error if the node might send subsequent messages
|
|
24
|
+
node.error("error occurred", { ...msg, error: err })
|
|
25
|
+
done();
|
|
26
|
+
}
|
|
27
|
+
} catch (err) {
|
|
28
|
+
// use done if the node won't send anymore messages for the
|
|
29
|
+
// message it received.
|
|
30
|
+
msg.error = err
|
|
31
|
+
done(err.message, msg)
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
RED.nodes.registerType("ut-assert-status", Coreut_assert_statusFunctionality);
|
|
37
|
+
|
|
38
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
(function(){
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function frontendSupportFunction() {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
var functTwo = (arg) => {
|
|
9
|
+
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
RED.nodes.registerType('ut-assert-success',{
|
|
13
|
+
color: '#addb7b',
|
|
14
|
+
icon: "font-awesome/fa-smile-o",
|
|
15
|
+
category: 'testing',
|
|
16
|
+
defaults: {
|
|
17
|
+
name: {
|
|
18
|
+
value:"",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
paletteLabel: "Assert True",
|
|
23
|
+
inputs: 1,
|
|
24
|
+
|
|
25
|
+
outputs: 0,
|
|
26
|
+
|
|
27
|
+
label: function() {
|
|
28
|
+
return (this.name || this._def.paletteLabel);
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
labelStyle: function() {
|
|
32
|
+
return this.name?"node_label_italic":"";
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
onpaletteadd: function() {
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
onpaletteremove: function() {
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
oneditprepare: function() {
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
oneditcancel: function() {
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
oneditsave: function() {
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
oneditresize: function(size) {
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
});
|
|
55
|
+
})();
|
|
56
|
+
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<script type="text/html" data-template-name="ut-assert-success">
|
|
60
|
+
<div class="form-row">
|
|
61
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
|
|
62
|
+
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
|
|
63
|
+
</div>
|
|
64
|
+
</script>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module.exports = function(RED) {
|
|
2
|
+
function CoreutassertsuccessFunctionality(config) {
|
|
3
|
+
RED.nodes.createNode(this,config);
|
|
4
|
+
|
|
5
|
+
var node = this;
|
|
6
|
+
var cfg = config;
|
|
7
|
+
|
|
8
|
+
node.on('close', function() {
|
|
9
|
+
node.status({});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
/* msg handler, in this case pass the message on unchanged */
|
|
13
|
+
node.on("input", function(msg, send, done) {
|
|
14
|
+
// How to send a status update
|
|
15
|
+
node.status({ fill: "green", shape: "ring", text: RED._("ut-assert-success.label.succeed") });
|
|
16
|
+
|
|
17
|
+
// Send a message and how to handle errors.
|
|
18
|
+
try {
|
|
19
|
+
try {
|
|
20
|
+
send(msg);
|
|
21
|
+
done();
|
|
22
|
+
} catch ( err ) {
|
|
23
|
+
// use node.error if the node might send subsequent messages
|
|
24
|
+
node.error("error occurred", { ...msg, error: err })
|
|
25
|
+
done();
|
|
26
|
+
}
|
|
27
|
+
} catch (err) {
|
|
28
|
+
// use done if the node won't send anymore messages for the
|
|
29
|
+
// message it received.
|
|
30
|
+
msg.error = err
|
|
31
|
+
done(err.message, msg)
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
RED.nodes.registerType("ut-assert-success", CoreutassertsuccessFunctionality);
|
|
37
|
+
|
|
38
|
+
}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
(function(){
|
|
3
|
+
|
|
4
|
+
RED.nodes.registerType('ut-assert-values',{
|
|
5
|
+
color: '#FDF0C2',
|
|
6
|
+
icon: "font-awesome/fa-exclamation",
|
|
7
|
+
category: 'testing',
|
|
8
|
+
defaults: {
|
|
9
|
+
name: {
|
|
10
|
+
value:"",
|
|
11
|
+
},
|
|
12
|
+
rules: {
|
|
13
|
+
value: [{ t: "eql", p: "payload", pt: "msg", to: "", tot: "str" }],
|
|
14
|
+
validate: function (rules, opt) {
|
|
15
|
+
let msg;
|
|
16
|
+
const errors = []
|
|
17
|
+
if (!rules || rules.length === 0) { return true }
|
|
18
|
+
for (var i = 0; i < rules.length; i++) {
|
|
19
|
+
const opt = { label: RED._('ut-assert-values.label.rule') + ' ' + (i + 1) }
|
|
20
|
+
const r = rules[i];
|
|
21
|
+
if (r.t === 'eql' || r.t === 'noteql' || r.t === 'mth' || r.t === 'notmth' || r.t === 'debug' || r.t === 'notset' || r.t === 'set') {
|
|
22
|
+
if ((msg = RED.utils.validateTypedProperty(r.p, r.pt, opt)) !== true) {
|
|
23
|
+
errors.push(msg)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (r.t === 'eql' || r.t === 'noteql' || r.t === 'mth' || r.t === 'notmth') {
|
|
27
|
+
if ((msg = RED.utils.validateTypedProperty(r.to, r.tot, opt)) !== true) {
|
|
28
|
+
errors.push(msg)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (errors.length) {
|
|
33
|
+
return errors
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
paletteLabel: 'Assert Values',
|
|
42
|
+
inputs: 1,
|
|
43
|
+
|
|
44
|
+
outputs: 1,
|
|
45
|
+
|
|
46
|
+
label: function () {
|
|
47
|
+
function prop2name(type, key) {
|
|
48
|
+
var result = RED.utils.parseContextKey(key);
|
|
49
|
+
return type + "." + result.key;
|
|
50
|
+
}
|
|
51
|
+
if (this.name) {
|
|
52
|
+
return this.name;
|
|
53
|
+
}
|
|
54
|
+
if ( this.rules) {
|
|
55
|
+
if (this.rules.length == 1) {
|
|
56
|
+
return this._("ut-assert-values.label." + this.rules[0].t, { property: prop2name((this.rules[0].pt || "msg"), this.rules[0].p) });
|
|
57
|
+
} else {
|
|
58
|
+
return this._("ut-assert-values.label.changeCount", { count: this.rules.length });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
labelStyle: function() {
|
|
64
|
+
return this.name?"node_label_italic":"";
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
onpaletteadd: function() {
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
onpaletteremove: function() {
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
oneditprepare: function() {
|
|
74
|
+
var to = this._("ut-assert-values.action.to");
|
|
75
|
+
var toValueLabel = this._("ut-assert-values.action.toValue", to);
|
|
76
|
+
var search = this._("ut-assert-values.action.search");
|
|
77
|
+
var replace = this._("ut-assert-values.action.replace");
|
|
78
|
+
var regex = this._("ut-assert-values.label.regex");
|
|
79
|
+
|
|
80
|
+
var node = this;
|
|
81
|
+
|
|
82
|
+
function createPropertyValue(row2_1, row2_2, defaultType) {
|
|
83
|
+
var propValInput = $('<input/>', { class: "node-input-rule-property-value", type: "text" })
|
|
84
|
+
.appendTo(row2_1)
|
|
85
|
+
.typedInput({ default: defaultType || 'str', types: ['msg', 'flow', 'global', 'str', 'num', 'bool', 'json', 'bin', 'date', 'jsonata', 'env'] });
|
|
86
|
+
|
|
87
|
+
propValInput.on("change", function (evt, type, val) {
|
|
88
|
+
row2_2.toggle(type === "msg" || type === "flow" || type === "global" || type === "env");
|
|
89
|
+
})
|
|
90
|
+
return [propValInput, undefined];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
function createFromValue(row3_1, defaultType) {
|
|
95
|
+
return $('<input/>', { class: "node-input-rule-property-search-value", type: "text" })
|
|
96
|
+
.appendTo(row3_1)
|
|
97
|
+
.typedInput({ default: defaultType || 'str', types: ['msg', 'flow', 'global', 'str', 're', 'num', 'bool', 'env'] });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
function createToValue(row3_2, defaultType) {
|
|
102
|
+
return $('<input/>', { class: "node-input-rule-property-replace-value", type: "text" })
|
|
103
|
+
.appendTo(row3_2)
|
|
104
|
+
.typedInput({ default: defaultType || 'str', types: ['msg', 'flow', 'global', 'str', 'num', 'bool', 'json', 'bin', 'env'] });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
function createMoveValue(row4, defaultType) {
|
|
109
|
+
return $('<input/>', { class: "node-input-rule-property-move-value", type: "text" })
|
|
110
|
+
.appendTo(row4)
|
|
111
|
+
.typedInput({ default: defaultType || 'msg', types: ['msg', 'flow', 'global'] });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
$('#node-input-assert-values-rule-container').css('min-height', '150px').css('min-width', '450px').editableList({
|
|
115
|
+
addItem: function (container, i, opt) {
|
|
116
|
+
var rule = opt;
|
|
117
|
+
if (!rule.hasOwnProperty('t')) {
|
|
118
|
+
rule = { t: "eql", p: "payload", to: "", tot: "str" };
|
|
119
|
+
}
|
|
120
|
+
container.css({
|
|
121
|
+
overflow: 'hidden',
|
|
122
|
+
whiteSpace: 'nowrap'
|
|
123
|
+
});
|
|
124
|
+
let fragment = document.createDocumentFragment();
|
|
125
|
+
var row1 = $('<div/>', { style: "display:flex; align-items: baseline" }).appendTo(fragment);
|
|
126
|
+
var row2 = $('<div/>', { style: "margin-top:8px;" }).appendTo(fragment);
|
|
127
|
+
var row3 = $('<div/>', { style: "margin-top:8px;" }).appendTo(fragment);
|
|
128
|
+
var row4 = $('<div/>', { style: "display:flex;margin-top:8px;align-items: baseline" }).appendTo(fragment);
|
|
129
|
+
|
|
130
|
+
var selectField = $('<select/>', { class: "node-input-rule-type", style: "width:110px; margin-right:10px;" }).appendTo(row1);
|
|
131
|
+
var selectOptions = [
|
|
132
|
+
{ v: "eql" },
|
|
133
|
+
{ v: "noteql" },
|
|
134
|
+
{ v: "mth" },
|
|
135
|
+
{ v: "notmth" },
|
|
136
|
+
{ v: "set" },
|
|
137
|
+
{ v: "notset" },
|
|
138
|
+
{ v: "debug" },
|
|
139
|
+
];
|
|
140
|
+
for (var i = 0; i < selectOptions.length; i++) {
|
|
141
|
+
let label = node._("ut-assert-values.action." + (selectOptions[i].l || selectOptions[i].v))
|
|
142
|
+
selectField.append($("<option></option>").val(selectOptions[i].v).text(label));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
var propertyName = $('<input/>', { class: "node-input-rule-property-name", type: "text" })
|
|
146
|
+
.appendTo(row1)
|
|
147
|
+
.typedInput({ types: ['msg', 'flow', 'global'] });
|
|
148
|
+
|
|
149
|
+
var row2_1 = $('<div/>', { style: "display:flex;align-items: baseline" }).appendTo(row2);
|
|
150
|
+
$('<div/>', { style: "display:inline-block;text-align:right; width:120px; padding-right:10px; box-sizing:border-box;" })
|
|
151
|
+
.text(toValueLabel)
|
|
152
|
+
.appendTo(row2_1);
|
|
153
|
+
|
|
154
|
+
var row2_2 = $('<div/>', { style: "margin-top: 4px;" }).appendTo(row2);
|
|
155
|
+
|
|
156
|
+
var row3_1 = $('<div/>', { style: "display:flex;align-items: baseline" }).appendTo(row3);
|
|
157
|
+
$('<div/>', { style: "display:inline-block;text-align:right; width:120px; padding-right:10px; box-sizing:border-box;" })
|
|
158
|
+
.text(search)
|
|
159
|
+
.appendTo(row3_1);
|
|
160
|
+
|
|
161
|
+
var row3_2 = $('<div/>', { style: "display:flex;margin-top:8px;align-items: baseline" }).appendTo(row3);
|
|
162
|
+
$('<div/>', { style: "display:inline-block;text-align:right; width:120px; padding-right:10px; box-sizing:border-box;" })
|
|
163
|
+
.text(replace)
|
|
164
|
+
.appendTo(row3_2);
|
|
165
|
+
|
|
166
|
+
$('<div/>', { style: "display:inline-block;text-align:right; width:120px; padding-right:10px; box-sizing:border-box;" })
|
|
167
|
+
.text(to)
|
|
168
|
+
.appendTo(row4);
|
|
169
|
+
|
|
170
|
+
let propertyValue = null;
|
|
171
|
+
let fromValue = null;
|
|
172
|
+
let toValue = null;
|
|
173
|
+
let moveValue = null;
|
|
174
|
+
|
|
175
|
+
selectField.on("change", function () {
|
|
176
|
+
var type = $(this).val();
|
|
177
|
+
if (propertyValue) {
|
|
178
|
+
propertyValue.typedInput('hide');
|
|
179
|
+
}
|
|
180
|
+
if (fromValue) {
|
|
181
|
+
fromValue.typedInput('hide');
|
|
182
|
+
}
|
|
183
|
+
if (toValue) {
|
|
184
|
+
toValue.typedInput('hide');
|
|
185
|
+
}
|
|
186
|
+
if (moveValue) {
|
|
187
|
+
moveValue.typedInput('hide');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (type != "notset" && type != "debug" && type != "set") {
|
|
191
|
+
if (!propertyValue) {
|
|
192
|
+
var parts = createPropertyValue(row2_1, row2_2);
|
|
193
|
+
propertyValue = parts[0];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
propertyValue.typedInput('show');
|
|
197
|
+
propertyValue.typedInput('value', rule.to);
|
|
198
|
+
propertyValue.typedInput('type', rule.tot);
|
|
199
|
+
|
|
200
|
+
row2.show();
|
|
201
|
+
row3.hide();
|
|
202
|
+
row4.hide();
|
|
203
|
+
} else {
|
|
204
|
+
row2.hide();
|
|
205
|
+
row3.hide();
|
|
206
|
+
row4.hide();
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
selectField.val(rule.t);
|
|
211
|
+
propertyName.typedInput('value', rule.p);
|
|
212
|
+
propertyName.typedInput('type', rule.pt);
|
|
213
|
+
selectField.change();
|
|
214
|
+
container[0].appendChild(fragment);
|
|
215
|
+
},
|
|
216
|
+
removable: true,
|
|
217
|
+
sortable: true
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
for (var i = 0; i < this.rules.length; i++) {
|
|
221
|
+
var rule = this.rules[i];
|
|
222
|
+
$("#node-input-assert-values-rule-container").editableList('addItem', rule);
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
oneditcancel: function() {
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
oneditsave: function() {
|
|
230
|
+
var rules = $("#node-input-assert-values-rule-container").editableList('items');
|
|
231
|
+
|
|
232
|
+
var node = this;
|
|
233
|
+
node.rules = [];
|
|
234
|
+
|
|
235
|
+
rules.each(function (i) {
|
|
236
|
+
var rule = $(this);
|
|
237
|
+
var type = rule.find(".node-input-rule-type").val();
|
|
238
|
+
|
|
239
|
+
var r = {
|
|
240
|
+
t: type,
|
|
241
|
+
p: rule.find(".node-input-rule-property-name").typedInput('value'),
|
|
242
|
+
pt: rule.find(".node-input-rule-property-name").typedInput('type')
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
if (type !== "notset" && type !== "debug" && type !== "set") {
|
|
246
|
+
r.to = rule.find(".node-input-rule-property-value").typedInput('value');
|
|
247
|
+
r.tot = rule.find(".node-input-rule-property-value").typedInput('type');
|
|
248
|
+
}
|
|
249
|
+
node.rules.push(r);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
oneditresize: function(size) {
|
|
255
|
+
var rows = $("#dialog-form>div:not(.node-input-assert-values-rule-container-row)");
|
|
256
|
+
var height = size.height;
|
|
257
|
+
for (var i = 0; i < rows.length; i++) {
|
|
258
|
+
height -= $(rows[i]).outerHeight(true);
|
|
259
|
+
}
|
|
260
|
+
var editorRow = $("#dialog-form>div.node-input-assert-values-rule-container-row");
|
|
261
|
+
height -= (parseInt(editorRow.css("marginTop")) + parseInt(editorRow.css("marginBottom")));
|
|
262
|
+
height += 16;
|
|
263
|
+
$("#node-input-assert-values-rule-container").editableList('height', height);
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
});
|
|
268
|
+
})();
|
|
269
|
+
|
|
270
|
+
</script>
|
|
271
|
+
|
|
272
|
+
<script type="text/html" data-template-name="ut-assert-values">
|
|
273
|
+
<style>
|
|
274
|
+
ol#node-input-assert-values-rule-container .red-ui-typedInput-container {
|
|
275
|
+
flex: 1;
|
|
276
|
+
}
|
|
277
|
+
</style>
|
|
278
|
+
<div class="form-row">
|
|
279
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
|
|
280
|
+
<input type="text" id="node-input-name" style="width: calc(100% - 105px)" data-i18n="[placeholder]node-red:common.label.name">
|
|
281
|
+
</div>
|
|
282
|
+
<div class="form-row" style="margin-bottom:0;">
|
|
283
|
+
<label><i class="fa fa-list"></i> <span data-i18n="ut-assert-values.label.rules"></span></label>
|
|
284
|
+
</div>
|
|
285
|
+
<div class="form-row node-input-rule-container-row node-input-assert-values-rule-container-row">
|
|
286
|
+
<ol id="node-input-assert-values-rule-container"></ol>
|
|
287
|
+
</div>
|
|
288
|
+
</script>
|