@@ -432,8 +432,14 @@ lynx_app.teams_list = (Vue, axios, $) => {
432
432
} ,
433
433
methods : {
434
434
editTeamAction ( id ) {
435
- $ ( 'input[name="uuid"]' ) . val ( id ) ;
435
+ let current = $ ( 'form#update_team_form input[name="uuid"]' ) . val ( )
436
+ if ( current != "" ) {
437
+ $ ( 'form#update_team_form' ) . attr ( 'action' , function ( i , val ) {
438
+ return val . replace ( current , "UUID" ) ;
439
+ } ) ;
440
+ }
436
441
442
+ $ ( 'form#update_team_form input[name="uuid"]' ) . val ( id ) ;
437
443
$ ( 'form#update_team_form' ) . attr ( 'action' , function ( i , val ) {
438
444
return val . replace ( 'UUID' , id ) ;
439
445
} ) ;
@@ -602,7 +608,14 @@ lynx_app.users_list = (Vue, axios, $) => {
602
608
} ,
603
609
methods : {
604
610
editUserAction ( id ) {
605
- $ ( 'input[name="uuid"]' ) . val ( id ) ;
611
+ let current = $ ( 'form#update_user_form input[name="uuid"]' ) . val ( )
612
+ if ( current != "" ) {
613
+ $ ( 'form#update_user_form' ) . attr ( 'action' , function ( i , val ) {
614
+ return val . replace ( current , "UUID" ) ;
615
+ } ) ;
616
+ }
617
+
618
+ $ ( 'form#update_user_form input[name="uuid"]' ) . val ( id ) ;
606
619
$ ( 'form#update_user_form' ) . attr ( 'action' , function ( i , val ) {
607
620
return val . replace ( 'UUID' , id ) ;
608
621
} ) ;
@@ -750,8 +763,14 @@ lynx_app.projects_list = (Vue, axios, $) => {
750
763
} ,
751
764
methods : {
752
765
editProjectAction ( id ) {
753
- $ ( 'form#update_project_form input[name="uuid"]' ) . val ( id ) ;
766
+ let current = $ ( 'form#update_project_form input[name="uuid"]' ) . val ( )
767
+ if ( current != "" ) {
768
+ $ ( 'form#update_project_form' ) . attr ( 'action' , function ( i , val ) {
769
+ return val . replace ( current , "UUID" ) ;
770
+ } ) ;
771
+ }
754
772
773
+ $ ( 'form#update_project_form input[name="uuid"]' ) . val ( id ) ;
755
774
$ ( 'form#update_project_form' ) . attr ( 'action' , function ( i , val ) {
756
775
return val . replace ( 'UUID' , id ) ;
757
776
} ) ;
@@ -1046,7 +1065,30 @@ lynx_app.environments_list = (Vue, axios, $) => {
1046
1065
} ,
1047
1066
methods : {
1048
1067
editEnvironmentAction ( id ) {
1049
- console . log ( "Edit environment with ID:" , id ) ;
1068
+ let current = $ ( 'form#update_environment_form input[name="uuid"]' ) . val ( )
1069
+ if ( current != "" ) {
1070
+ $ ( 'form#update_environment_form' ) . attr ( 'action' , function ( i , val ) {
1071
+ return val . replace ( current , "UUID" ) ;
1072
+ } ) ;
1073
+ }
1074
+
1075
+ $ ( 'form#update_environment_form input[name="uuid"]' ) . val ( id ) ;
1076
+ $ ( 'form#update_environment_form' ) . attr ( 'action' , function ( i , val ) {
1077
+ return val . replace ( 'UUID' , id ) ;
1078
+ } ) ;
1079
+
1080
+ axios . get ( $ ( "#update_environment_form" ) . attr ( "action" ) )
1081
+ . then ( ( response ) => {
1082
+ if ( response . status >= 200 ) {
1083
+ $ ( 'form#update_environment_form input[name="name"]' ) . val ( response . data . name ) ;
1084
+ $ ( 'form#update_environment_form input[name="slug"]' ) . val ( response . data . slug ) ;
1085
+ $ ( 'form#update_environment_form input[name="username"]' ) . val ( response . data . username ) ;
1086
+ $ ( 'form#update_environment_form input[name="secret"]' ) . val ( response . data . secret ) ;
1087
+ }
1088
+ } )
1089
+ . catch ( ( error ) => {
1090
+ show_notification ( error . response . data . errorMessage ) ;
1091
+ } ) ;
1050
1092
} ,
1051
1093
1052
1094
formatDatetime ( datatime ) {
@@ -1135,6 +1177,49 @@ lynx_app.environments_list = (Vue, axios, $) => {
1135
1177
} ) ;
1136
1178
}
1137
1179
1180
+ lynx_app . edit_environment_modal = ( Vue , axios , $ ) => {
1181
+
1182
+ return new Vue ( {
1183
+ delimiters : [ '${' , '}' ] ,
1184
+ el : '#edit_environment_modal' ,
1185
+ data ( ) {
1186
+ return {
1187
+ isInProgress : false
1188
+ }
1189
+ } ,
1190
+ methods : {
1191
+ updateEnvironmentAction ( event ) {
1192
+ event . preventDefault ( ) ;
1193
+ this . isInProgress = true ;
1194
+
1195
+ let inputs = { } ;
1196
+ let _self = $ ( event . target ) ;
1197
+ let _form = _self . closest ( "form" ) ;
1198
+
1199
+ _form . serializeArray ( ) . map ( ( item , index ) => {
1200
+ inputs [ item . name ] = item . value ;
1201
+ } ) ;
1202
+
1203
+ axios . put ( _form . attr ( 'action' ) , inputs )
1204
+ . then ( ( response ) => {
1205
+ if ( response . status >= 200 ) {
1206
+ show_notification ( _globals . update_environment_message ) ;
1207
+
1208
+ setTimeout ( ( ) => {
1209
+ location . reload ( ) ;
1210
+ } , 2000 ) ;
1211
+ }
1212
+ } )
1213
+ . catch ( ( error ) => {
1214
+ this . isInProgress = false ;
1215
+ // Show error
1216
+ show_notification ( error . response . data . errorMessage ) ;
1217
+ } ) ;
1218
+ }
1219
+ }
1220
+ } ) ;
1221
+ }
1222
+
1138
1223
// Snapshots list
1139
1224
lynx_app . snapshots_list = ( Vue , axios , $ ) => {
1140
1225
@@ -1495,4 +1580,12 @@ $(document).ready(() => {
1495
1580
$
1496
1581
) ;
1497
1582
}
1583
+
1584
+ if ( document . getElementById ( "edit_environment_modal" ) ) {
1585
+ lynx_app . edit_environment_modal (
1586
+ Vue ,
1587
+ axios ,
1588
+ $
1589
+ ) ;
1590
+ }
1498
1591
} ) ;
0 commit comments