Skip to content

Commit 3545f3b

Browse files
committed
[fix] Fix issue #16
1 parent 16102ce commit 3545f3b

File tree

2 files changed

+112
-80
lines changed

2 files changed

+112
-80
lines changed

resources/views/list.blade.php

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,37 @@
7474
showCancelButton: true,
7575
confirmButtonColor: "#DD6B55",
7676
confirmButtonText: "{{ trans('admin.confirm') }}",
77+
showLoaderOnConfirm: true,
7778
closeOnConfirm: false,
78-
cancelButtonText: "{{ trans('admin.cancel') }}"
79-
},
80-
function(){
81-
$.ajax({
82-
method: 'delete',
83-
url: '{{ $url['delete'] }}',
84-
data: {
85-
'files[]':[path],
86-
_token:LA.token,
87-
},
88-
success: function (data) {
89-
$.pjax.reload('#pjax-container');
90-
91-
if (typeof data === 'object') {
92-
if (data.status) {
93-
swal(data.message, '', 'success');
94-
} else {
95-
swal(data.message, '', 'error');
79+
cancelButtonText: "{{ trans('admin.cancel') }}",
80+
preConfirm: function() {
81+
return new Promise(function(resolve) {
82+
83+
$.ajax({
84+
method: 'delete',
85+
url: '{{ $url['delete'] }}',
86+
data: {
87+
'files[]':[path],
88+
_token:LA.token
89+
},
90+
success: function (data) {
91+
$.pjax.reload('#pjax-container');
92+
93+
resolve(data);
9694
}
97-
}
95+
});
96+
97+
});
98+
}
99+
}).then(function(result){
100+
var data = result.value;
101+
if (typeof data === 'object') {
102+
if (data.status) {
103+
swal(data.message, '', 'success');
104+
} else {
105+
swal(data.message, '', 'error');
98106
}
99-
});
107+
}
100108
});
101109
});
102110
@@ -215,29 +223,37 @@ function closeModal() {
215223
showCancelButton: true,
216224
confirmButtonColor: "#DD6B55",
217225
confirmButtonText: "{{ trans('admin.confirm') }}",
226+
showLoaderOnConfirm: true,
218227
closeOnConfirm: false,
219-
cancelButtonText: "{{ trans('admin.cancel') }}"
220-
},
221-
function(){
222-
$.ajax({
223-
method: 'delete',
224-
url: '{{ $url['delete'] }}',
225-
data: {
226-
'files[]': files,
227-
_token:LA.token,
228-
},
229-
success: function (data) {
230-
$.pjax.reload('#pjax-container');
231-
232-
if (typeof data === 'object') {
233-
if (data.status) {
234-
swal(data.message, '', 'success');
235-
} else {
236-
swal(data.message, '', 'error');
228+
cancelButtonText: "{{ trans('admin.cancel') }}",
229+
preConfirm: function() {
230+
return new Promise(function(resolve) {
231+
232+
$.ajax({
233+
method: 'delete',
234+
url: '{{ $url['delete'] }}',
235+
data: {
236+
'files[]': files,
237+
_token:LA.token
238+
},
239+
success: function (data) {
240+
$.pjax.reload('#pjax-container');
241+
242+
resolve(data);
237243
}
238-
}
244+
});
245+
246+
});
247+
}
248+
}).then(function (result) {
249+
var data = result.value;
250+
if (typeof data === 'object') {
251+
if (data.status) {
252+
swal(data.message, '', 'success');
253+
} else {
254+
swal(data.message, '', 'error');
239255
}
240-
});
256+
}
241257
});
242258
});
243259
});

resources/views/table.blade.php

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -52,29 +52,37 @@
5252
showCancelButton: true,
5353
confirmButtonColor: "#DD6B55",
5454
confirmButtonText: "{{ trans('admin.confirm') }}",
55+
showLoaderOnConfirm: true,
5556
closeOnConfirm: false,
56-
cancelButtonText: "{{ trans('admin.cancel') }}"
57-
},
58-
function(){
59-
$.ajax({
60-
method: 'delete',
61-
url: '{{ $url['delete'] }}',
62-
data: {
63-
'files[]':[path],
64-
_token:LA.token,
65-
},
66-
success: function (data) {
67-
$.pjax.reload('#pjax-container');
68-
69-
if (typeof data === 'object') {
70-
if (data.status) {
71-
swal(data.message, '', 'success');
72-
} else {
73-
swal(data.message, '', 'error');
57+
cancelButtonText: "{{ trans('admin.cancel') }}",
58+
preConfirm: function() {
59+
return new Promise(function(resolve) {
60+
61+
$.ajax({
62+
method: 'delete',
63+
url: '{{ $url['delete'] }}',
64+
data: {
65+
'files[]':[path],
66+
_token:LA.token
67+
},
68+
success: function (data) {
69+
$.pjax.reload('#pjax-container');
70+
71+
resolve(data);
7472
}
75-
}
73+
});
74+
75+
});
76+
}
77+
}).then(function(result){
78+
var data = result.value;
79+
if (typeof data === 'object') {
80+
if (data.status) {
81+
swal(data.message, '', 'success');
82+
} else {
83+
swal(data.message, '', 'error');
7684
}
77-
});
85+
}
7886
});
7987
});
8088
@@ -215,29 +223,37 @@ function closeModal() {
215223
showCancelButton: true,
216224
confirmButtonColor: "#DD6B55",
217225
confirmButtonText: "{{ trans('admin.confirm') }}",
226+
showLoaderOnConfirm: true,
218227
closeOnConfirm: false,
219-
cancelButtonText: "{{ trans('admin.cancel') }}"
220-
},
221-
function(){
222-
$.ajax({
223-
method: 'delete',
224-
url: '{{ $url['delete'] }}',
225-
data: {
226-
'files[]': files,
227-
_token:LA.token,
228-
},
229-
success: function (data) {
230-
$.pjax.reload('#pjax-container');
231-
232-
if (typeof data === 'object') {
233-
if (data.status) {
234-
swal(data.message, '', 'success');
235-
} else {
236-
swal(data.message, '', 'error');
228+
cancelButtonText: "{{ trans('admin.cancel') }}",
229+
preConfirm: function() {
230+
return new Promise(function(resolve) {
231+
232+
$.ajax({
233+
method: 'delete',
234+
url: '{{ $url['delete'] }}',
235+
data: {
236+
'files[]': files,
237+
_token:LA.token
238+
},
239+
success: function (data) {
240+
$.pjax.reload('#pjax-container');
241+
242+
resolve(data);
237243
}
238-
}
244+
});
245+
246+
});
247+
}
248+
}).then(function (result) {
249+
var data = result.value;
250+
if (typeof data === 'object') {
251+
if (data.status) {
252+
swal(data.message, '', 'success');
253+
} else {
254+
swal(data.message, '', 'error');
239255
}
240-
});
256+
}
241257
});
242258
});
243259

0 commit comments

Comments
 (0)