@@ 211-273 (lines=63) @@ | ||
208 | * |
|
209 | * @return string |
|
210 | */ |
|
211 | protected function renderDelete() |
|
212 | { |
|
213 | $deleteConfirm = trans('admin.delete_confirm'); |
|
214 | $confirm = trans('admin.confirm'); |
|
215 | $cancel = trans('admin.cancel'); |
|
216 | ||
217 | $class = uniqid(); |
|
218 | ||
219 | $script = <<<SCRIPT |
|
220 | ||
221 | $('.{$class}-delete').unbind('click').click(function() { |
|
222 | ||
223 | swal({ |
|
224 | title: "$deleteConfirm", |
|
225 | type: "warning", |
|
226 | showCancelButton: true, |
|
227 | confirmButtonColor: "#DD6B55", |
|
228 | confirmButtonText: "$confirm", |
|
229 | showLoaderOnConfirm: true, |
|
230 | cancelButtonText: "$cancel", |
|
231 | preConfirm: function() { |
|
232 | return new Promise(function(resolve) { |
|
233 | $.ajax({ |
|
234 | method: 'post', |
|
235 | url: '{$this->getDeletePath()}', |
|
236 | data: { |
|
237 | _method:'delete', |
|
238 | _token:LA.token, |
|
239 | }, |
|
240 | success: function (data) { |
|
241 | $.pjax({container:'#pjax-container', url: '{$this->getListPath()}' }); |
|
242 | ||
243 | resolve(data); |
|
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'); |
|
255 | } |
|
256 | } |
|
257 | }); |
|
258 | }); |
|
259 | ||
260 | SCRIPT; |
|
261 | ||
262 | $delete = trans('admin.delete'); |
|
263 | ||
264 | Admin::script($script); |
|
265 | ||
266 | return <<<HTML |
|
267 | <div class="btn-group pull-right" style="margin-right: 5px"> |
|
268 | <a href="javascript:void(0);" class="btn btn-sm btn-danger {$class}-delete" title="{$delete}"> |
|
269 | <i class="fa fa-trash"></i><span class="hidden-xs"> {$delete}</span> |
|
270 | </a> |
|
271 | </div> |
|
272 | HTML; |
|
273 | } |
|
274 | ||
275 | /** |
|
276 | * Render custom tools. |
@@ 199-261 (lines=63) @@ | ||
196 | * |
|
197 | * @return string |
|
198 | */ |
|
199 | protected function renderDelete() |
|
200 | { |
|
201 | $deleteConfirm = trans('admin.delete_confirm'); |
|
202 | $confirm = trans('admin.confirm'); |
|
203 | $cancel = trans('admin.cancel'); |
|
204 | ||
205 | $class = uniqid(); |
|
206 | ||
207 | $script = <<<SCRIPT |
|
208 | ||
209 | $('.{$class}-delete').unbind('click').click(function() { |
|
210 | ||
211 | swal({ |
|
212 | title: "$deleteConfirm", |
|
213 | type: "warning", |
|
214 | showCancelButton: true, |
|
215 | confirmButtonColor: "#DD6B55", |
|
216 | confirmButtonText: "$confirm", |
|
217 | showLoaderOnConfirm: true, |
|
218 | cancelButtonText: "$cancel", |
|
219 | preConfirm: function() { |
|
220 | return new Promise(function(resolve) { |
|
221 | $.ajax({ |
|
222 | method: 'post', |
|
223 | url: '{$this->getDeletePath()}', |
|
224 | data: { |
|
225 | _method:'delete', |
|
226 | _token:LA.token, |
|
227 | }, |
|
228 | success: function (data) { |
|
229 | $.pjax({container:'#pjax-container', url: '{$this->getListPath()}' }); |
|
230 | ||
231 | resolve(data); |
|
232 | } |
|
233 | }); |
|
234 | }); |
|
235 | } |
|
236 | }).then(function(result) { |
|
237 | var data = result.value; |
|
238 | if (typeof data === 'object') { |
|
239 | if (data.status) { |
|
240 | swal(data.message, '', 'success'); |
|
241 | } else { |
|
242 | swal(data.message, '', 'error'); |
|
243 | } |
|
244 | } |
|
245 | }); |
|
246 | }); |
|
247 | ||
248 | SCRIPT; |
|
249 | ||
250 | $delete = trans('admin.delete'); |
|
251 | ||
252 | Admin::script($script); |
|
253 | ||
254 | return <<<HTML |
|
255 | <div class="btn-group pull-right" style="margin-right: 5px"> |
|
256 | <a href="javascript:void(0);" class="btn btn-sm btn-danger {$class}-delete" title="{$delete}"> |
|
257 | <i class="fa fa-trash"></i><span class="hidden-xs"> {$delete}</span> |
|
258 | </a> |
|
259 | </div> |
|
260 | HTML; |
|
261 | } |
|
262 | ||
263 | /** |
|
264 | * Add a tool. |