@@ -1255,6 +1255,32 @@ lynx_app.snapshots_list = (Vue, axios, $) => {
1255
1255
$ ( "div#snapshot_info_modal_content" ) . text ( description ) ;
1256
1256
} ,
1257
1257
1258
+ editSnapshotAction ( id ) {
1259
+ let current = $ ( 'form#update_snapshot_form input[name="uuid"]' ) . val ( )
1260
+ if ( current != "" ) {
1261
+ $ ( 'form#update_snapshot_form' ) . attr ( 'action' , function ( i , val ) {
1262
+ return val . replace ( current , "UUID" ) ;
1263
+ } ) ;
1264
+ }
1265
+
1266
+ $ ( 'form#update_snapshot_form input[name="uuid"]' ) . val ( id ) ;
1267
+ $ ( 'form#update_snapshot_form' ) . attr ( 'action' , function ( i , val ) {
1268
+ return val . replace ( 'UUID' , id ) ;
1269
+ } ) ;
1270
+
1271
+ axios . get ( $ ( "#update_snapshot_form" ) . attr ( "action" ) )
1272
+ . then ( ( response ) => {
1273
+ if ( response . status >= 200 ) {
1274
+ $ ( 'form#update_snapshot_form input[name="title"]' ) . val ( response . data . title ) ;
1275
+ $ ( 'form#update_snapshot_form textarea[name="description"]' ) . val ( response . data . description ) ;
1276
+ $ ( 'form#update_snapshot_form select[name="team_id"]' ) . val ( response . data . team . id ) ;
1277
+ }
1278
+ } )
1279
+ . catch ( ( error ) => {
1280
+ show_notification ( error . response . data . errorMessage ) ;
1281
+ } ) ;
1282
+ } ,
1283
+
1258
1284
formatDatetime ( datatime ) {
1259
1285
return format_datetime ( datatime ) ;
1260
1286
} ,
@@ -1333,6 +1359,69 @@ lynx_app.snapshots_list = (Vue, axios, $) => {
1333
1359
} ) ;
1334
1360
}
1335
1361
1362
+ lynx_app . edit_snapshot_modal = ( Vue , axios , $ ) => {
1363
+
1364
+ return new Vue ( {
1365
+ delimiters : [ '${' , '}' ] ,
1366
+ el : '#edit_snapshot_modal' ,
1367
+ data ( ) {
1368
+ return {
1369
+ isInProgress : false ,
1370
+ teams : [ ]
1371
+ }
1372
+ } ,
1373
+ mounted ( ) {
1374
+ this . loadDataAction ( ) ;
1375
+ } ,
1376
+ methods : {
1377
+ loadDataAction ( ) {
1378
+ axios . get ( $ ( "#edit_snapshot_modal" ) . attr ( "data-action" ) , {
1379
+ params : {
1380
+ offset : 0 ,
1381
+ limit : 10000
1382
+ }
1383
+ } )
1384
+ . then ( ( response ) => {
1385
+ if ( response . status >= 200 ) {
1386
+ this . teams = response . data . teams ;
1387
+ }
1388
+ } )
1389
+ . catch ( ( error ) => {
1390
+ show_notification ( error . response . data . errorMessage ) ;
1391
+ } ) ;
1392
+ } ,
1393
+ updateSnapshotAction ( event ) {
1394
+ event . preventDefault ( ) ;
1395
+ this . isInProgress = true ;
1396
+
1397
+ let inputs = { } ;
1398
+ let _self = $ ( event . target ) ;
1399
+ let _form = _self . closest ( "form" ) ;
1400
+
1401
+ _form . serializeArray ( ) . map ( ( item , index ) => {
1402
+ inputs [ item . name ] = item . value ;
1403
+ } ) ;
1404
+
1405
+ axios . put ( _form . attr ( 'action' ) , inputs )
1406
+ . then ( ( response ) => {
1407
+ if ( response . status >= 200 ) {
1408
+ show_notification ( _globals . update_snapshot_message ) ;
1409
+
1410
+ setTimeout ( ( ) => {
1411
+ location . reload ( ) ;
1412
+ } , 2000 ) ;
1413
+ }
1414
+ } )
1415
+ . catch ( ( error ) => {
1416
+ this . isInProgress = false ;
1417
+ // Show error
1418
+ show_notification ( error . response . data . errorMessage ) ;
1419
+ } ) ;
1420
+ }
1421
+ }
1422
+ } ) ;
1423
+ }
1424
+
1336
1425
// Add Snapshot Modal
1337
1426
lynx_app . add_snapshot_modal = ( Vue , axios , $ ) => {
1338
1427
@@ -1600,4 +1689,12 @@ $(document).ready(() => {
1600
1689
$
1601
1690
) ;
1602
1691
}
1692
+
1693
+ if ( document . getElementById ( "edit_snapshot_modal" ) ) {
1694
+ lynx_app . edit_snapshot_modal (
1695
+ Vue ,
1696
+ axios ,
1697
+ $
1698
+ ) ;
1699
+ }
1603
1700
} ) ;
0 commit comments