@@ -14,32 +14,37 @@ const componentDef = {
1414 methods : {
1515 perform : function ( ) {
1616 const self = this
17- axios ( {
18- method : self . componentConfig [ "method" ] ,
19- url : self . componentConfig [ "action_path" ] ,
20- data : self . componentConfig [ "data" ] ,
21- headers : {
22- 'X-CSRF-Token' : document . getElementsByName ( "csrf-token" ) [ 0 ] . getAttribute ( 'content' )
23- }
24- } )
25- . then ( function ( response ) {
26- if ( self . componentConfig [ "success" ] != undefined && self . componentConfig [ "success" ] [ "emit" ] != undefined ) {
27- matestackEventHub . $emit ( self . componentConfig [ "success" ] [ "emit" ] , response . data ) ;
28- }
29- if ( self . componentConfig [ "success" ] != undefined && self . componentConfig [ "success" ] [ "transition" ] != undefined && self . $store != undefined ) {
30- let path = self . componentConfig [ "success" ] [ "transition" ] [ "path" ]
31- self . $store . dispatch ( 'navigateTo' , { url : path , backwards : false } )
32- }
33- } )
34- . catch ( function ( error ) {
35- if ( self . componentConfig [ "failure" ] != undefined && self . componentConfig [ "failure" ] [ "emit" ] != undefined ) {
36- matestackEventHub . $emit ( self . componentConfig [ "failure" ] [ "emit" ] , error . response . data ) ;
37- }
38- if ( self . componentConfig [ "failure" ] != undefined && self . componentConfig [ "failure" ] [ "transition" ] != undefined && self . $store != undefined ) {
39- let path = self . componentConfig [ "failure" ] [ "transition" ] [ "path" ]
40- self . $store . dispatch ( 'navigateTo' , { url : path , backwards : false } )
41- }
42- } )
17+ if (
18+ ( self . componentConfig [ "confirm" ] == undefined ) || confirm ( self . componentConfig [ "confirm_text" ] )
19+ )
20+ {
21+ axios ( {
22+ method : self . componentConfig [ "method" ] ,
23+ url : self . componentConfig [ "action_path" ] ,
24+ data : self . componentConfig [ "data" ] ,
25+ headers : {
26+ 'X-CSRF-Token' : document . getElementsByName ( "csrf-token" ) [ 0 ] . getAttribute ( 'content' )
27+ }
28+ } )
29+ . then ( function ( response ) {
30+ if ( self . componentConfig [ "success" ] != undefined && self . componentConfig [ "success" ] [ "emit" ] != undefined ) {
31+ matestackEventHub . $emit ( self . componentConfig [ "success" ] [ "emit" ] , response . data ) ;
32+ }
33+ if ( self . componentConfig [ "success" ] != undefined && self . componentConfig [ "success" ] [ "transition" ] != undefined && self . $store != undefined ) {
34+ let path = self . componentConfig [ "success" ] [ "transition" ] [ "path" ]
35+ self . $store . dispatch ( 'navigateTo' , { url : path , backwards : false } )
36+ }
37+ } )
38+ . catch ( function ( error ) {
39+ if ( self . componentConfig [ "failure" ] != undefined && self . componentConfig [ "failure" ] [ "emit" ] != undefined ) {
40+ matestackEventHub . $emit ( self . componentConfig [ "failure" ] [ "emit" ] , error . response . data ) ;
41+ }
42+ if ( self . componentConfig [ "failure" ] != undefined && self . componentConfig [ "failure" ] [ "transition" ] != undefined && self . $store != undefined ) {
43+ let path = self . componentConfig [ "failure" ] [ "transition" ] [ "path" ]
44+ self . $store . dispatch ( 'navigateTo' , { url : path , backwards : false } )
45+ }
46+ } )
47+ }
4348 }
4449 }
4550}
0 commit comments