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