@@ -433,6 +433,10 @@ lynx_app.teams_list = (Vue, axios, $) => {
433
433
methods : {
434
434
editTeamAction ( id ) {
435
435
console . log ( "Edit team with ID:" , id ) ;
436
+ //$('input[name="uuid"]').val(id);
437
+ //$('form#update_team_form').attr('action', function(i, val) {
438
+ // return val.replace('UUID', id);
439
+ //});
436
440
} ,
437
441
438
442
formatDatetime ( datatime ) {
@@ -520,7 +524,21 @@ lynx_app.users_list = (Vue, axios, $) => {
520
524
} ,
521
525
methods : {
522
526
editUserAction ( id ) {
523
- console . log ( "Edit user with ID:" , id ) ;
527
+ $ ( 'input[name="uuid"]' ) . val ( id ) ;
528
+ $ ( 'form#update_user_form' ) . attr ( 'action' , function ( i , val ) {
529
+ return val . replace ( 'UUID' , id ) ;
530
+ } ) ;
531
+ axios . get ( $ ( "#update_user_form" ) . attr ( "action" ) )
532
+ . then ( ( response ) => {
533
+ if ( response . status >= 200 ) {
534
+ $ ( 'form#update_user_form input[name="name"]' ) . val ( response . data . name ) ;
535
+ $ ( 'form#update_user_form select[name="role"]' ) . val ( response . data . role ) ;
536
+ $ ( 'form#update_user_form input[name="email"]' ) . val ( response . data . email ) ;
537
+ }
538
+ } )
539
+ . catch ( ( error ) => {
540
+ show_notification ( error . response . data . errorMessage ) ;
541
+ } ) ;
524
542
} ,
525
543
526
544
formatDatetime ( datatime ) {
@@ -585,6 +603,50 @@ lynx_app.users_list = (Vue, axios, $) => {
585
603
} ) ;
586
604
}
587
605
606
+
607
+ lynx_app . edit_user_modal = ( Vue , axios , $ ) => {
608
+
609
+ return new Vue ( {
610
+ delimiters : [ '${' , '}' ] ,
611
+ el : '#edit_user_modal' ,
612
+ data ( ) {
613
+ return {
614
+ isInProgress : false
615
+ }
616
+ } ,
617
+ methods : {
618
+ updateUserAction ( event ) {
619
+ event . preventDefault ( ) ;
620
+ this . isInProgress = true ;
621
+
622
+ let inputs = { } ;
623
+ let _self = $ ( event . target ) ;
624
+ let _form = _self . closest ( "form" ) ;
625
+
626
+ _form . serializeArray ( ) . map ( ( item , index ) => {
627
+ inputs [ item . name ] = item . value ;
628
+ } ) ;
629
+
630
+ axios . put ( _form . attr ( 'action' ) , inputs )
631
+ . then ( ( response ) => {
632
+ if ( response . status >= 200 ) {
633
+ show_notification ( _globals . update_user_message ) ;
634
+
635
+ setTimeout ( ( ) => {
636
+ location . reload ( ) ;
637
+ } , 2000 ) ;
638
+ }
639
+ } )
640
+ . catch ( ( error ) => {
641
+ this . isInProgress = false ;
642
+ // Show error
643
+ show_notification ( error . response . data . errorMessage ) ;
644
+ } ) ;
645
+ }
646
+ }
647
+ } ) ;
648
+ }
649
+
588
650
// Projects list
589
651
lynx_app . projects_list = ( Vue , axios , $ ) => {
590
652
@@ -1249,4 +1311,12 @@ $(document).ready(() => {
1249
1311
$
1250
1312
) ;
1251
1313
}
1314
+
1315
+ if ( document . getElementById ( "edit_user_modal" ) ) {
1316
+ lynx_app . edit_user_modal (
1317
+ Vue ,
1318
+ axios ,
1319
+ $
1320
+ ) ;
1321
+ }
1252
1322
} ) ;
0 commit comments