@@ -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 ,
0 commit comments