PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.3
JetFormBuilder — Dynamic Blocks Form Builder v3.1.3
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / assets / src / admin-package / mixins / SaveTabByAjax.js
jetformbuilder / assets / src / admin-package / mixins Last commit date
GetIncoming.js 2 years ago ParseIncomingValueMixin.js 2 years ago PromiseWrapper.js 2 years ago SaveTabByAjax.js 2 years ago i18n.js 2 years ago
SaveTabByAjax.js
97 lines
1 export default {
2 methods: {
3 saveByAjax( currentTab, tabSlug ) {
4 const self = this;
5 let ajaxRequest = {};
6
7 try {
8 ajaxRequest = this.getAjaxObject( currentTab, tabSlug );
9 } catch ( error ) {
10 if ( ! error ) {
11 return;
12 }
13
14 if ( 'object' === typeof error.noticeOptions ) {
15 self.$CXNotice.add( {
16 message: 'Invalid request data.',
17 type: 'error',
18 duration: 2000,
19 ...error.noticeOptions,
20 } );
21
22 return;
23 }
24
25 self.$CXNotice.add( {
26 message: error,
27 type: 'error',
28 duration: 2000,
29 } );
30
31 return;
32 }
33
34 jfbEventBus.$emit( 'request-state', { state: 'begin', slug: tabSlug } );
35
36 jQuery.ajax( ajaxRequest )
37 .done( function( response ) {
38
39 if ( 'function' === typeof currentTab.onSaveDone ) {
40 currentTab.onSaveDone( response );
41 } else {
42 if ( response.success ) {
43 self.$CXNotice.add( {
44 message: response.data.message,
45 type: 'success',
46 duration: 5000,
47 } );
48 if ( 'function' === typeof currentTab.onSaveDoneSuccess ) {
49 currentTab.onSaveDoneSuccess( response );
50 }
51 } else {
52 self.$CXNotice.add( {
53 message: response.data.message,
54 type: 'error',
55 duration: 5000,
56 } );
57 if ( 'function' === typeof currentTab.onSaveDoneError ) {
58 currentTab.onSaveDoneError( response );
59 }
60 }
61 }
62 jfbEventBus.$emit( 'request-state', { state: 'end', slug: tabSlug } );
63 } )
64 .fail( function( jqXHR, textStatus, errorThrown ) {
65 if ( 'function' === typeof currentTab.onSaveFail ) {
66 currentTab.onSaveFail( jqXHR, textStatus, errorThrown );
67 } else {
68 self.$CXNotice.add( {
69 message: errorThrown,
70 type: 'error',
71 duration: 5000,
72 } );
73 }
74 jfbEventBus.$emit( 'request-state', { state: 'end', slug: tabSlug } );
75 } );
76 },
77
78 getAjaxObject( currentTab, tabSlug ) {
79 const ajaxRequest = {
80 url: window.ajaxurl,
81 type: 'POST',
82 dataType: 'json',
83 ...currentTab.getRequestOnSave(),
84 };
85 ajaxRequest.data = {
86 action: `jet_fb_save_tab__${ tabSlug }`,
87 ...ajaxRequest.data,
88 };
89
90 if ( window?.JetFBPageConfigPackage?.nonce ) {
91 ajaxRequest.data._nonce = window.JetFBPageConfigPackage.nonce;
92 }
93
94 return ajaxRequest;
95 },
96 },
97 }