Skip to content

Commit 819bcdd

Browse files
committed
add support for values i forms
1 parent e6cb2ad commit 819bcdd

4 files changed

Lines changed: 24 additions & 2 deletions

File tree

OpenFlow/src/public/Controllers.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,15 @@ module openflow {
11771177
if (res.length > 0) { this.model = res[0]; } else { console.error(this.id + " workflow instances not found!"); return; }
11781178
if (this.model.form !== "") {
11791179
var res = await this.api.Query("forms", { _id: this.model.form }, null, { _created: -1 }, 1);
1180-
if (res.length > 0) { this.form = res[0]; } else { console.error(this.id + " form not found!"); return; }
1180+
if (res.length > 0) { this.form = res[0]; } else {
1181+
if (this.model.state == "completed") {
1182+
this.$location.path("/main");
1183+
if (!this.$scope.$$phase) { this.$scope.$apply(); }
1184+
return;
1185+
} else {
1186+
console.error(this.id + " form not found! " + this.model.state); return;
1187+
}
1188+
}
11811189
} else {
11821190
console.debug("Model contains no form");
11831191
}
@@ -1237,6 +1245,7 @@ module openflow {
12371245
this.form.formData = JSON.parse((this.form.formData as any));
12381246
}
12391247
for (var i = 0; i < this.form.formData.length; i++) {
1248+
console.log(this.form.formData[i]);
12401249
var value = this.model.payload[this.form.formData[i].name];
12411250
if (value == undefined || value == null) { value = ""; }
12421251
this.form.formData[i].userData = [value];
@@ -1248,6 +1257,15 @@ module openflow {
12481257
if (value == undefined || value == null) { value = ""; }
12491258
this.form.formData[i].label = value;
12501259
}
1260+
if (this.model.values[this.form.formData[i].name] !== null && this.model.values[this.form.formData[i].name] !== undefined) {
1261+
console.log("set values for " + this.form.formData[i].name);
1262+
value = this.model.values[this.form.formData[i].name];
1263+
console.log(value);
1264+
if (value == undefined || value == null) { value = []; }
1265+
this.form.formData[i].values = value;
1266+
} else {
1267+
console.log("No values for " + this.form.formData[i].name);
1268+
}
12511269
}
12521270
var formRenderOpts = {
12531271
formData: this.form.formData,

OpenFlow/src/public/Entities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ module openflow {
100100
}
101101
public queue: string;
102102
public payload: any;
103+
public values: any;
103104
public jwt: string;
104105
public state: string;
105106
public form: string;

OpenFlowNodeRED/src/nodered/nodes/workflow_nodes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export class workflow_in_node {
9696
} catch (error) {
9797
}
9898
result.payload = data.payload;
99+
result.values = data.values;
99100
if (data.payload._id !== null && data.payload._id !== undefined && data.payload._id !== "") {
100101
var res = await NoderedUtil.Query("workflow_instances", { "_id": data.payload._id }, null, null, 1, 0, data.jwt);
101102
if (res.length == 0) {
@@ -191,6 +192,7 @@ export class workflow_out_node {
191192
if (typeof msg.payload === 'string' || msg.payload instanceof String) {
192193
msg.payload = { data: msg.payload };
193194
}
195+
194196
if (msg._id !== null && msg._id !== undefined && msg._id !== "") {
195197
var res = await NoderedUtil._UpdateOne("workflow_instances", null, msg, 1, false, msg.jwt);
196198
}
@@ -204,6 +206,7 @@ export class workflow_out_node {
204206
}
205207
//data.error = msg.error;
206208
data.payload = msg.payload;
209+
data.values = msg.values;
207210
data.jwt = msg.jwt;
208211
data.payload._id = msg._id;
209212
msg.amqpacknowledgment(JSON.stringify(data));

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.290
1+
0.0.291

0 commit comments

Comments
 (0)