PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.4.3
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.4.3
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / assets / spa / components / component-table / index.js

index.js in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.4.3, at assets/spa/components/component-table/index.js

146 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 Vue.component( 'wpuf-table', {
2 template: '#tmpl-wpuf-component-table',
3 mixins: [weForms.mixins.Loading, weForms.mixins.Paginate, weForms.mixins.BulkAction],
4 props: {
5 has_export: String,
6 action: String,
7 delete: String,
8 id: [String, Number],
9 status: [String],
10 },
11
12 data() {
13 return {
14 loading: false,
15 columns: [],
16 items: [],
17 ajaxAction: this.action,
18 nonce: weForms.nonce,
19 index: 'id',
20 bulkDeleteAction: this.delete ? this.delete : 'weforms_form_entry_trash_bulk'
21 };
22 },
23
24 created() {
25 this.fetchData();
26 },
27
28 computed: {
29 columnLength: function() {
30 return Object.keys(this.columns).length;
31 },
32 },
33 methods: {
34
35 fetchData: function() {
36 var self = this;
37
38 this.loading = true;
39
40 wp.ajax.send( self.action, {
41 data: {
42 id: self.id,
43 page: self.currentPage,
44 status: self.status,
45 _wpnonce: weForms.nonce
46 },
47 success: function(response) {
48 self.loading = false;
49 self.columns = response.columns;
50 self.items = response.entries;
51 self.form_title = response.form_title;
52 self.totalItems = response.pagination.total;
53 self.perPage = response.pagination.per_page;
54 self.totalPage = response.pagination.pages;
55
56 self.$emit('ajaxsuccess', response);
57 },
58 error: function(error) {
59 self.loading = false;
60 alert(error);
61 }
62 });
63 },
64
65 handleBulkAction: function() {
66 if ( '-1' === this.bulkAction ) {
67 alert( 'Please chose a bulk action to perform' );
68 return;
69 }
70
71 if ( 'delete' === this.bulkAction ) {
72 if ( ! this.checkedItems.length ) {
73 alert( 'Please select atleast one entry to delete.' );
74 return;
75 }
76
77 if ( confirm( 'Are you sure to delete the entries?' ) ) {
78 this.deleteBulk();
79 }
80 }
81
82 if ( 'restore' === this.bulkAction ) {
83 if ( ! this.checkedItems.length ) {
84 alert( 'Please select atleast one entry to restore.' );
85 return;
86 }
87
88 this.restoreBulk();
89 }
90 },
91 restore: function(entry_id){
92 var self = this;
93 self.loading = true;
94
95 wp.ajax.send( 'weforms_form_entry_restore', {
96 data: {
97 entry_id: entry_id,
98 _wpnonce: weForms.nonce
99 },
100 success: function(response) {
101 self.loading = false;
102 self.fetchData();
103 },
104 error: function(error) {
105 self.loading = false;
106 alert(error);
107 }
108 });
109 },
110 deletePermanently: function(entry_id){
111
112 if ( confirm( 'Are you sure to delete this entry?' ) ) {
113
114 var self = this;
115 self.loading = true;
116
117 wp.ajax.send( 'weforms_form_entry_delete', {
118 data: {
119 entry_id: entry_id,
120 _wpnonce: weForms.nonce
121 },
122 success: function(response) {
123 self.loading = false;
124 self.fetchData();
125 },
126 error: function(error) {
127 self.loading = false;
128 alert(error);
129 }
130 });
131 }
132 }
133 },
134
135 watch: {
136 id: function(){
137 this.fetchData();
138 },
139 status: function(){
140 this.currentPage = 1;
141 this.bulkAction = -1;
142 this.fetchData();
143 },
144 }
145 } );
146