Merge pull request #4153 from jaseelbavu/issue-4082
Added bulk category delete functionality
This commit is contained in:
commit
a0970f590d
|
|
@ -99,6 +99,14 @@ class CategoryDataGrid extends DataGrid
|
||||||
'route' => 'admin.catalog.categories.delete',
|
'route' => 'admin.catalog.categories.delete',
|
||||||
'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']),
|
'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']),
|
||||||
'icon' => 'icon trash-icon',
|
'icon' => 'icon trash-icon',
|
||||||
|
'function' => 'deleteFunction($event, "delete")'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->addMassAction([
|
||||||
|
'type' => 'delete',
|
||||||
|
'label' => trans('admin::app.datagrid.delete'),
|
||||||
|
'action' => route('admin.catalog.categories.massdelete'),
|
||||||
|
'method' => 'DELETE',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -335,6 +335,13 @@ Route::group(['middleware' => ['web']], function () {
|
||||||
|
|
||||||
Route::post('/categories/delete/{id}', 'Webkul\Category\Http\Controllers\CategoryController@destroy')->name('admin.catalog.categories.delete');
|
Route::post('/categories/delete/{id}', 'Webkul\Category\Http\Controllers\CategoryController@destroy')->name('admin.catalog.categories.delete');
|
||||||
|
|
||||||
|
//category massdelete
|
||||||
|
Route::post('categories/massdelete', 'Webkul\Category\Http\Controllers\CategoryController@massDestroy')->defaults('_config', [
|
||||||
|
'redirect' => 'admin.catalog.categories.index',
|
||||||
|
])->name('admin.catalog.categories.massdelete');
|
||||||
|
|
||||||
|
Route::post('/categories/product/count', 'Webkul\Category\Http\Controllers\CategoryController@categoryProductCount')->name('admin.catalog.categories.product.count');
|
||||||
|
|
||||||
|
|
||||||
// Catalog Attribute Routes
|
// Catalog Attribute Routes
|
||||||
Route::get('/attributes', 'Webkul\Attribute\Http\Controllers\AttributeController@index')->defaults('_config', [
|
Route::get('/attributes', 'Webkul\Attribute\Http\Controllers\AttributeController@index')->defaults('_config', [
|
||||||
|
|
|
||||||
|
|
@ -27,3 +27,57 @@
|
||||||
{!! view_render_event('bagisto.admin.catalog.categories.list.after') !!}
|
{!! view_render_event('bagisto.admin.catalog.categories.list.after') !!}
|
||||||
</div>
|
</div>
|
||||||
@stop
|
@stop
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("input[type='checkbox']").change(deleteFunction);
|
||||||
|
});
|
||||||
|
|
||||||
|
var deleteFunction = function(e,type) {
|
||||||
|
if (type == 'delete') {
|
||||||
|
var indexes = $(e.target).parent().attr('id');
|
||||||
|
} else {
|
||||||
|
$("input[type='checkbox']").attr('disabled', true);
|
||||||
|
|
||||||
|
var formData = {};
|
||||||
|
$.each($('form').serializeArray(), function(i, field) {
|
||||||
|
formData[field.name] = field.value;
|
||||||
|
});
|
||||||
|
|
||||||
|
var indexes = formData.indexes;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (indexes) {
|
||||||
|
$.ajax({
|
||||||
|
type : 'POST',
|
||||||
|
url : '{{route("admin.catalog.categories.product.count")}}',
|
||||||
|
data : {
|
||||||
|
_token: '{{csrf_token()}}',
|
||||||
|
indexes: indexes
|
||||||
|
},
|
||||||
|
success:function(data) {
|
||||||
|
$("input[type='checkbox']").attr('disabled', false);
|
||||||
|
if (data.product_count > 0) {
|
||||||
|
var message = "{{trans('ui::app.datagrid.massaction.delete-category-product')}}";
|
||||||
|
if (type == 'delete') {
|
||||||
|
doAction(e, message);
|
||||||
|
} else {
|
||||||
|
$('form').attr('onsubmit', 'return confirm("'+message+'")');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var message = "{{ __('ui::app.datagrid.click_on_action') }}";
|
||||||
|
if (type == 'delete') {
|
||||||
|
doAction(e, message);
|
||||||
|
} else {
|
||||||
|
$('form').attr('onsubmit', 'return confirm("'+message+'")');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$("input[type='checkbox']").attr('disabled', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
|
@ -153,7 +153,10 @@ class CategoryController extends Controller
|
||||||
try {
|
try {
|
||||||
Event::dispatch('catalog.category.delete.before', $id);
|
Event::dispatch('catalog.category.delete.before', $id);
|
||||||
|
|
||||||
$this->categoryRepository->delete($id);
|
if($category->products->count() > 0) {
|
||||||
|
$category->products()->delete();
|
||||||
|
}
|
||||||
|
$category->delete();
|
||||||
|
|
||||||
Event::dispatch('catalog.category.delete.after', $id);
|
Event::dispatch('catalog.category.delete.after', $id);
|
||||||
|
|
||||||
|
|
@ -175,36 +178,52 @@ class CategoryController extends Controller
|
||||||
*/
|
*/
|
||||||
public function massDestroy()
|
public function massDestroy()
|
||||||
{
|
{
|
||||||
$suppressFlash = false;
|
$suppressFlash = true;
|
||||||
|
$categoryIds = explode(',', request()->input('indexes'));
|
||||||
|
|
||||||
if (request()->isMethod('delete') || request()->isMethod('post')) {
|
foreach ($categoryIds as $categoryId) {
|
||||||
$indexes = explode(',', request()->input('indexes'));
|
$category = $this->categoryRepository->find($categoryId);
|
||||||
|
|
||||||
foreach ($indexes as $key => $value) {
|
if (isset($category)) {
|
||||||
try {
|
if(strtolower($category->name) == "root") {
|
||||||
Event::dispatch('catalog.category.delete.before', $value);
|
$suppressFlash = false;
|
||||||
|
session()->flash('warning', trans('admin::app.response.delete-category-root', ['name' => 'Category']));
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$suppressFlash = true;
|
||||||
|
Event::dispatch('catalog.category.delete.before', $categoryId);
|
||||||
|
|
||||||
$this->categoryRepository->delete($value);
|
if($category->products->count() > 0) {
|
||||||
|
$category->products()->delete();
|
||||||
|
}
|
||||||
|
$category->delete();
|
||||||
|
|
||||||
Event::dispatch('catalog.category.delete.after', $value);
|
Event::dispatch('catalog.category.delete.after', $categoryId);
|
||||||
} catch(\Exception $e) {
|
|
||||||
$suppressFlash = true;
|
|
||||||
|
|
||||||
continue;
|
} catch(\Exception $e) {
|
||||||
|
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Category']));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $suppressFlash) {
|
|
||||||
session()->flash('success', trans('admin::app.datagrid.mass-ops.delete-success'));
|
|
||||||
} else {
|
|
||||||
session()->flash('info', trans('admin::app.datagrid.mass-ops.partial-action', ['resource' => 'Attribute Family']));
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect()->back();
|
|
||||||
} else {
|
|
||||||
session()->flash('error', trans('admin::app.datagrid.mass-ops.method-error'));
|
|
||||||
|
|
||||||
return redirect()->back();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count($categoryIds) != 1 || $suppressFlash == true) {
|
||||||
|
session()->flash('success', trans('admin::app.datagrid.mass-ops.delete-success', ['resource' => 'Category']));
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route($this->_config['redirect']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function categoryProductCount() {
|
||||||
|
$indexes = explode(",", request()->input('indexes'));
|
||||||
|
$product_count = 0;
|
||||||
|
|
||||||
|
foreach($indexes as $index) {
|
||||||
|
$category = $this->categoryRepository->find($index);
|
||||||
|
$product_count += $category->products->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['product_count' => $product_count], 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9,6 +9,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Webkul\Category\Contracts\Category as CategoryContract;
|
use Webkul\Category\Contracts\Category as CategoryContract;
|
||||||
use Webkul\Attribute\Models\AttributeProxy;
|
use Webkul\Attribute\Models\AttributeProxy;
|
||||||
use Webkul\Category\Repositories\CategoryRepository;
|
use Webkul\Category\Repositories\CategoryRepository;
|
||||||
|
use Webkul\Product\Models\ProductProxy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Category
|
* Class Category
|
||||||
|
|
@ -129,4 +130,12 @@ class Category extends TranslatableModel implements CategoryContract
|
||||||
|
|
||||||
return $this->findInTree($category->children);
|
return $this->findInTree($category->children);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The products that belong to the category.
|
||||||
|
*/
|
||||||
|
public function products()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(ProductProxy::modelClass(), 'product_categories');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9,6 +9,7 @@ return [
|
||||||
'mass-update-status' => 'هل تريد حقا تحديث الحالة من منتقى :resource?',
|
'mass-update-status' => 'هل تريد حقا تحديث الحالة من منتقى :resource?',
|
||||||
'delete' => 'هل تريد حقا حذف هذا :resource?',
|
'delete' => 'هل تريد حقا حذف هذا :resource?',
|
||||||
'edit' => 'هل تريد حقا تحرير هذا :resource?',
|
'edit' => 'هل تريد حقا تحرير هذا :resource?',
|
||||||
|
'delete-category-product' => 'The selected categories contains products. Performing this action will remove the related products. Do you really want to perform this action?'
|
||||||
],
|
],
|
||||||
|
|
||||||
'zero-index' => 'يمكن أن تحتوي أعمدة الفهرس على قيم أكبر من الصفر فقط',
|
'zero-index' => 'يمكن أن تحتوي أعمدة الفهرس على قيم أكبر من الصفر فقط',
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ return [
|
||||||
'mass-update-status' => 'Möchten Sie den Status der ausgewählten :resource wirklich aktualisieren?',
|
'mass-update-status' => 'Möchten Sie den Status der ausgewählten :resource wirklich aktualisieren?',
|
||||||
'delete' => 'Möchten Sie diese Aktion wirklich ausführen?',
|
'delete' => 'Möchten Sie diese Aktion wirklich ausführen?',
|
||||||
'edit' => 'Möchten Sie :resource wirklich bearbeiten?',
|
'edit' => 'Möchten Sie :resource wirklich bearbeiten?',
|
||||||
|
'delete-category-product' => 'The selected categories contains products. Performing this action will remove the related products. Do you really want to perform this action?'
|
||||||
],
|
],
|
||||||
|
|
||||||
'zero-index' => 'Indexspalten können nur Werte größer als Null haben',
|
'zero-index' => 'Indexspalten können nur Werte größer als Null haben',
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ return [
|
||||||
'mass-update-status' => 'Do you really want to update status of these selected :resource?',
|
'mass-update-status' => 'Do you really want to update status of these selected :resource?',
|
||||||
'delete' => 'Do you really want to perform this action?',
|
'delete' => 'Do you really want to perform this action?',
|
||||||
'edit' => 'Do you really want to edit this :resource?',
|
'edit' => 'Do you really want to edit this :resource?',
|
||||||
|
'delete-category-product' => 'The selected categories contains products. Performing this action will remove the related products. Do you really want to perform this action?'
|
||||||
],
|
],
|
||||||
|
|
||||||
'zero-index' => 'Index columns can have values greater than zero only',
|
'zero-index' => 'Index columns can have values greater than zero only',
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ return [
|
||||||
'mass-update-status' => 'آیا واقعاً می خواهید وضعیت انتخاب شده را به روز کنید :resource?',
|
'mass-update-status' => 'آیا واقعاً می خواهید وضعیت انتخاب شده را به روز کنید :resource?',
|
||||||
'delete' => 'آیا واقعاً می خواهید این عمل را انجام دهید؟',
|
'delete' => 'آیا واقعاً می خواهید این عمل را انجام دهید؟',
|
||||||
'edit' => 'آیا واقعاً می خواهید این را ویرایش کنید :resource?',
|
'edit' => 'آیا واقعاً می خواهید این را ویرایش کنید :resource?',
|
||||||
|
'delete-category-product' => 'The selected categories contains products. Performing this action will remove the related products. Do you really want to perform this action?'
|
||||||
],
|
],
|
||||||
|
|
||||||
'zero-index' => 'ستون های فهرست می توانند مقادیری بیشتر از صفر داشته باشند',
|
'zero-index' => 'ستون های فهرست می توانند مقادیری بیشتر از صفر داشته باشند',
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ return [
|
||||||
'mass-update-status' => 'Vuoi aggiornare davvero lo stato dei :resource selezionati?',
|
'mass-update-status' => 'Vuoi aggiornare davvero lo stato dei :resource selezionati?',
|
||||||
'delete' => 'Vuoi davvero effettuare questa azione?',
|
'delete' => 'Vuoi davvero effettuare questa azione?',
|
||||||
'edit' => 'Vuoi davvero modificare questo :resource?',
|
'edit' => 'Vuoi davvero modificare questo :resource?',
|
||||||
|
'delete-category-product' => 'The selected categories contains products. Performing this action will remove the related products. Do you really want to perform this action?'
|
||||||
],
|
],
|
||||||
|
|
||||||
'zero-index' => 'Le colonnne indice possono avere solo valori maggiori di zero',
|
'zero-index' => 'Le colonnne indice possono avere solo valori maggiori di zero',
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ return [
|
||||||
'mass-update-status' => 'Do you really want to update status of these selected :resource?',
|
'mass-update-status' => 'Do you really want to update status of these selected :resource?',
|
||||||
'delete' => 'Wilt u deze actie echt uitvoeren?',
|
'delete' => 'Wilt u deze actie echt uitvoeren?',
|
||||||
'edit' => 'Wil je dit echt bewerken :resource?',
|
'edit' => 'Wil je dit echt bewerken :resource?',
|
||||||
|
'delete-category-product' => 'The selected categories contains products. Performing this action will remove the related products. Do you really want to perform this action?'
|
||||||
],
|
],
|
||||||
|
|
||||||
'zero-index' => 'Index columns can have values greater than zero only',
|
'zero-index' => 'Index columns can have values greater than zero only',
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ return [
|
||||||
'mass-update-status' => 'Czy naprawdę chcesz zaktualizować status tych wybranych :resource?',
|
'mass-update-status' => 'Czy naprawdę chcesz zaktualizować status tych wybranych :resource?',
|
||||||
'delete' => 'Czy naprawdę chcesz wykonać tę akcję?',
|
'delete' => 'Czy naprawdę chcesz wykonać tę akcję?',
|
||||||
'edit' => 'Czy naprawdę chcesz edytować :resource?',
|
'edit' => 'Czy naprawdę chcesz edytować :resource?',
|
||||||
|
'delete-category-product' => 'The selected categories contains products. Performing this action will remove the related products. Do you really want to perform this action?'
|
||||||
],
|
],
|
||||||
|
|
||||||
'zero-index' => 'Kolumny indeksu mogą mieć wartości większe niż tylko zero',
|
'zero-index' => 'Kolumny indeksu mogą mieć wartości większe niż tylko zero',
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ return [
|
||||||
'mass-update-status' => 'Você realmente deseja atualizar o status desses itens selecionados :resource?',
|
'mass-update-status' => 'Você realmente deseja atualizar o status desses itens selecionados :resource?',
|
||||||
'delete' => 'Você realmente deseja excluir este :resource?',
|
'delete' => 'Você realmente deseja excluir este :resource?',
|
||||||
'edit' => 'Você realmente quer editar este :resource?',
|
'edit' => 'Você realmente quer editar este :resource?',
|
||||||
|
'delete-category-product' => 'The selected categories contains products. Performing this action will remove the related products. Do you really want to perform this action?'
|
||||||
],
|
],
|
||||||
|
|
||||||
'zero-index' => 'Colunas do índice podem ter valores maiores que zero apenas',
|
'zero-index' => 'Colunas do índice podem ter valores maiores que zero apenas',
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ return [
|
||||||
'mass-update-status' => 'Seçili :resource kayıtlarının durumunu güncellemek istediğinizden emin misiniz?',
|
'mass-update-status' => 'Seçili :resource kayıtlarının durumunu güncellemek istediğinizden emin misiniz?',
|
||||||
'delete' => 'Bu işlemi gerçekleştirmek istediğinizden emin misiniz?',
|
'delete' => 'Bu işlemi gerçekleştirmek istediğinizden emin misiniz?',
|
||||||
'edit' => ':resource kaydını düzenlemek istediğinizden emin misiniz?',
|
'edit' => ':resource kaydını düzenlemek istediğinizden emin misiniz?',
|
||||||
|
'delete-category-product' => 'The selected categories contains products. Performing this action will remove the related products. Do you really want to perform this action?'
|
||||||
],
|
],
|
||||||
|
|
||||||
'zero-index' => 'Index sütunları sadece sıfırdan büyük değere sahip olmalı',
|
'zero-index' => 'Index sütunları sadece sıfırdan büyük değere sahip olmalı',
|
||||||
|
|
|
||||||
|
|
@ -48,25 +48,32 @@
|
||||||
|
|
||||||
@if ($toDisplay)
|
@if ($toDisplay)
|
||||||
<a
|
<a
|
||||||
@if ($action['method'] == 'GET')
|
id="{{ $record->{$action['index'] ?? $index} }}"
|
||||||
href="{{ route($action['route'], $record->{$action['index'] ?? $index}) }}"
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if ($action['method'] != 'GET')
|
@if ($action['method'] == 'GET')
|
||||||
v-on:click="doAction($event)"
|
href="{{ route($action['route'], $record->{$action['index'] ?? $index}) }}"
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
data-method="{{ $action['method'] }}"
|
@if ($action['method'] != 'GET')
|
||||||
data-action="{{ route($action['route'], $record->{$index}) }}"
|
@if (isset($action['function']))
|
||||||
data-token="{{ csrf_token() }}"
|
v-on:click="{{$action['function']}}"
|
||||||
|
@else
|
||||||
|
v-on:click="doAction($event)"
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
|
|
||||||
@if (isset($action['target']))
|
data-method="{{ $action['method'] }}"
|
||||||
target="{{ $action['target'] }}"
|
data-action="{{ route($action['route'], $record->{$index}) }}"
|
||||||
@endif
|
data-token="{{ csrf_token() }}"
|
||||||
|
|
||||||
@if (isset($action['title']))
|
@if (isset($action['target']))
|
||||||
title="{{ $action['title'] }}"
|
target="{{ $action['target'] }}"
|
||||||
@endif>
|
@endif
|
||||||
|
|
||||||
|
@if (isset($action['title']))
|
||||||
|
title="{{ $action['title'] }}"
|
||||||
|
@endif
|
||||||
|
>
|
||||||
<span class="{{ $action['icon'] }}"></span>
|
<span class="{{ $action['icon'] }}"></span>
|
||||||
</a>
|
</a>
|
||||||
@endif
|
@endif
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
<span class="icon checkbox-dash-icon"></span>
|
<span class="icon checkbox-dash-icon"></span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<form method="POST" id="mass-action-form" style="display: inline-flex;" action="" onsubmit="return confirm('{{ __('ui::app.datagrid.click_on_action') }}')">
|
<form method="POST" id="mass-action-form" style="display: inline-flex;" action="" :onsubmit="`return confirm('${massActionConfirmText}')`">
|
||||||
@csrf()
|
@csrf()
|
||||||
|
|
||||||
<input type="hidden" id="indexes" name="indexes" v-model="dataIds">
|
<input type="hidden" id="indexes" name="indexes" v-model="dataIds">
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,7 @@
|
||||||
massActions: @json($results['massactions']),
|
massActions: @json($results['massactions']),
|
||||||
massActionsToggle: false,
|
massActionsToggle: false,
|
||||||
massActionTarget: null,
|
massActionTarget: null,
|
||||||
|
massActionConfirmText: '{{ __('ui::app.datagrid.click_on_action') }}',
|
||||||
massActionType: null,
|
massActionType: null,
|
||||||
massActionValues: [],
|
massActionValues: [],
|
||||||
massActionTargets: [],
|
massActionTargets: [],
|
||||||
|
|
@ -457,7 +458,8 @@
|
||||||
for (let id in this.massActions) {
|
for (let id in this.massActions) {
|
||||||
targetObj = {
|
targetObj = {
|
||||||
'type': this.massActions[id].type,
|
'type': this.massActions[id].type,
|
||||||
'action': this.massActions[id].action
|
'action': this.massActions[id].action,
|
||||||
|
'confirm_text': this.massActions[id].confirm_text
|
||||||
};
|
};
|
||||||
|
|
||||||
this.massActionTargets.push(targetObj);
|
this.massActionTargets.push(targetObj);
|
||||||
|
|
@ -483,6 +485,7 @@
|
||||||
for (let i in this.massActionTargets) {
|
for (let i in this.massActionTargets) {
|
||||||
if (this.massActionTargets[i].type === 'delete') {
|
if (this.massActionTargets[i].type === 'delete') {
|
||||||
this.massActionTarget = this.massActionTargets[i].action;
|
this.massActionTarget = this.massActionTargets[i].action;
|
||||||
|
this.massActionConfirmText = this.massActionTargets[i].confirm_text ? this.massActionTargets[i].confirm_text : this.massActionConfirmText;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -493,6 +496,7 @@
|
||||||
for (let i in this.massActionTargets) {
|
for (let i in this.massActionTargets) {
|
||||||
if (this.massActionTargets[i].type === 'update') {
|
if (this.massActionTargets[i].type === 'update') {
|
||||||
this.massActionTarget = this.massActionTargets[i].action;
|
this.massActionTarget = this.massActionTargets[i].action;
|
||||||
|
this.massActionConfirmText = this.massActionTargets[i].confirm_text ? this.massActionTargets[i].confirm_text : this.massActionConfirmText;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -816,31 +820,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
doAction: function (e) {
|
|
||||||
var element = e.currentTarget;
|
|
||||||
|
|
||||||
if (confirm('{{__('ui::app.datagrid.massaction.delete') }}')) {
|
|
||||||
axios.post(element.getAttribute('data-action'), {
|
|
||||||
_token: element.getAttribute('data-token'),
|
|
||||||
_method: element.getAttribute('data-method')
|
|
||||||
}).then(function (response) {
|
|
||||||
this.result = response;
|
|
||||||
|
|
||||||
if (response.data.redirect) {
|
|
||||||
window.location.href = response.data.redirect;
|
|
||||||
} else {
|
|
||||||
location.reload();
|
|
||||||
}
|
|
||||||
}).catch(function (error) {
|
|
||||||
location.reload();
|
|
||||||
});
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
} else {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
captureColumn: function (id) {
|
captureColumn: function (id) {
|
||||||
element = document.getElementById(id);
|
element = document.getElementById(id);
|
||||||
|
|
||||||
|
|
@ -869,6 +848,37 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function doAction(e, message, type) {
|
||||||
|
var element = e.currentTarget;
|
||||||
|
if (message) {
|
||||||
|
element = e.target.parentElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
message = message || '{{__('ui::app.datagrid.massaction.delete') }}';
|
||||||
|
|
||||||
|
if (confirm(message)) {
|
||||||
|
axios.post(element.getAttribute('data-action'), {
|
||||||
|
_token: element.getAttribute('data-token'),
|
||||||
|
_method: element.getAttribute('data-method')
|
||||||
|
}).then(function (response) {
|
||||||
|
this.result = response;
|
||||||
|
|
||||||
|
if (response.data.redirect) {
|
||||||
|
window.location.href = response.data.redirect;
|
||||||
|
} else {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
}).catch(function (error) {
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
} else {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue