Skip to content

A free open source IT asset/license management system

category done!

spencerrlongg6159ee8c2c24
diff --git a/app/Http/Controllers/BulkCategoriesController.php b/app/Http/Controllers/BulkCategoriesController.php
index 05b3189543..449b08878d 100644
--- a/app/Http/Controllers/BulkCategoriesController.php
+++ b/app/Http/Controllers/BulkCategoriesController.php
@@ -24,32 +24,32 @@ class BulkCategoriesController extends Controller
foreach ($request->ids as $id) {
$category = Category::find($id);
if (is_null($category)) {
- $errors[] = 'Category not found';
+ $errors[] = trans('admin/categories/message.delete.not_found');
continue;
}
try {
DestroyCategoryAction::run(category: $category);
} catch (ModelStillHasAccessories $e) {
- $errors[] = "{$category->name} still has associated items";
+ $errors[] = trans('admin/categories/message.delete.bulk_assoc_accessories', ['category_name' => $category->name]);
} catch (ModelStillHasAssetModels) {
- $errors[] = "{$category->name} still has asset models";
+ $errors[] = trans('admin/categories/message.delete.bulk_assoc_models', ['category_name' => $category->name]);
} catch (ModelStillHasAssets) {
- $errors[] = "{$category->name} still has assets";
+ $errors[] = trans('admin/categories/message.delete.bulk_assoc_assets', ['category_name' => $category->name]);
} catch (ModelStillHasComponents) {
- $errors[] = "{$category->name} still has components";
+ $errors[] = trans('admin/categories/message.delete.bulk_assoc_components', ['category_name' => $category->name]);
} catch (ModelStillHasConsumables) {
- $errors[] = "{$category->name} still has consumables";
+ $errors[] = trans('admin/categories/message.delete.bulk_assoc_consumables', ['category_name' => $category->name]);
} catch (ModelStillHasLicenses) {
- $errors[] = "{$category->name} still has licenses";
+ $errors[] = trans('admin/categories/message.delete.bulk_assoc_licenses', ['category_name' => $category->name]);
} catch (\Exception $e) {
report($e);
- $errors[] = 'Something went wrong';
+ $errors[] = trans('general.something_went_wrong');
}
}
if (count($errors) > 0) {
- return redirect()->route('categories.index')->with('error', implode(', ', $errors));
+ return redirect()->route('categories.index')->with('multi_error_messages', $errors);
} else {
- return redirect()->route('categories.index')->with('success', trans('admin/categories/message.delete.success'));
+ return redirect()->route('categories.index')->with('success', trans('admin/categories/message.delete.bulk_success'));
}
}
}
diff --git a/app/Presenters/CategoryPresenter.php b/app/Presenters/CategoryPresenter.php
index d4a9f01a05..3131e61ef4 100644
--- a/app/Presenters/CategoryPresenter.php
+++ b/app/Presenters/CategoryPresenter.php
@@ -14,6 +14,11 @@ class CategoryPresenter extends Presenter
public static function dataTableLayout()
{
$layout = [
+ [
+ 'field' => 'checkbox',
+ 'checkbox' => true,
+ 'titleTooltip' => trans('general.select_all_none'),
+ ],
[
'field' => 'id',
'searchable' => false,
diff --git a/resources/lang/en-US/admin/categories/message.php b/resources/lang/en-US/admin/categories/message.php
index 4e493f68b6..e9ee739d4b 100644
--- a/resources/lang/en-US/admin/categories/message.php
+++ b/resources/lang/en-US/admin/categories/message.php
@@ -18,9 +18,17 @@ return array(
),
'delete' => array(
- 'confirm' => 'Are you sure you wish to delete this category?',
- 'error' => 'There was an issue deleting the category. Please try again.',
- 'success' => 'The category was deleted successfully.'
+ 'not_found' => 'Category not found.',
+ 'confirm' => 'Are you sure you wish to delete this category?',
+ 'error' => 'There was an issue deleting the category. Please try again.',
+ 'success' => 'The category was deleted successfully.',
+ 'bulk_success' => 'The Categories were deleted successfully.',
+ 'bulk_assoc_assets' => ':category_name still has associated assets and cannot be deleted. Please update your assets to no longer reference this supplier and try again.',
+ 'bulk_assoc_accessories' => ':category_name still has associated accessories and cannot be deleted. Please update your accessories to no longer reference this supplier and try again.',
+ 'bulk_assoc_consumables' => ':category_name still has associated consumables and cannot be deleted. Please update your consumables to no longer reference this supplier and try again.',
+ 'bulk_assoc_components' => ':category_name still has associated components and cannot be deleted. Please update your components to no longer reference this supplier and try again.',
+ 'bulk_assoc_licenses' => ':category_name still has associated licenses and cannot be deleted. Please update your licenses to no longer reference this supplier and try again.',
+ 'bulk_assoc_models' => ':category_name still has associated asset models and cannot be deleted. Please update your asset models to no longer reference this supplier and try again.',
)
);
diff --git a/resources/lang/en-US/admin/manufacturers/message.php b/resources/lang/en-US/admin/manufacturers/message.php
index 40ae777a81..41063d34e4 100644
--- a/resources/lang/en-US/admin/manufacturers/message.php
+++ b/resources/lang/en-US/admin/manufacturers/message.php
@@ -23,7 +23,7 @@ return array(
'delete' => array(
'not_found' => 'Manufacturer not found.',
- 'confirm' => 'Are you sure you wish to delete this manufacturer?',
+ 'confirm' => 'Are you sure you wish to delete this manufacturer?',
'error' => 'There was an issue deleting the manufacturer. Please try again.',
'success' => 'The Manufacturer was deleted successfully.',
'bulk_success' => 'The Manufacturers were deleted successfully.',
diff --git a/resources/views/categories/index.blade.php b/resources/views/categories/index.blade.php
index ee492af144..11dee11a41 100755
--- a/resources/views/categories/index.blade.php
+++ b/resources/views/categories/index.blade.php
@@ -19,6 +19,7 @@
<div class="col-md-12">
<div class="box box-default">
<div class="box-body">
+ @include('partials.category-bulk-actions')
<table
data-columns="{{ \App\Presenters\CategoryPresenter::dataTableLayout() }}"
data-cookie-id-table="categoryTable"
@@ -32,6 +33,11 @@
data-show-refresh="true"
data-sort-order="asc"
id="categoryTable"
+ {{-- begin stuff for bulk dropdown --}}
+ data-toolbar="#categoriesBulkEditToolbar"
+ data-bulk-button-id="#bulkCategoryEditButton"
+ data-bulk-form-id="#categoriesBulkForm"
+ {{-- end stuff for bulk dropdown --}}
class="table table-striped snipe-table"
data-url="{{ route('api.categories.index') }}"
data-export-options='{
diff --git a/resources/views/partials/category-bulk-actions.blade.php b/resources/views/partials/category-bulk-actions.blade.php
index dbe35bbd41..e273dfb21e 100644
--- a/resources/views/partials/category-bulk-actions.blade.php
+++ b/resources/views/partials/category-bulk-actions.blade.php
@@ -1,10 +1,10 @@
-<div id="{{ (isset($id_divname)) ? $id_divname : 'assetsBulkEditToolbar' }}" style="min-width:400px">
+<div id="{{ (isset($id_divname)) ? $id_divname : 'categoriesBulkEditToolbar' }}" style="min-width:400px">
<form
method="POST"
- action="{{ route('hardware/bulkedit') }}"
+ action="{{ route('categories.bulk.delete') }}"
accept-charset="UTF-8"
class="form-inline"
- id="{{ (isset($id_formname)) ? $id_formname : 'assetsBulkForm' }}"
+ id="{{ (isset($id_formname)) ? $id_formname : 'categoriesBulkForm' }}"
>
@csrf
@@ -20,10 +20,9 @@
@can('delete', \App\Models\Category::class)
<option value="delete">{{ trans('button.delete') }}</option>
@endcan
- <option value="labels" {{$snipeSettings->shortcuts_enabled == 1 ? "accesskey=l" : ''}}>{{ trans_choice('button.generate_labels', 2) }}</option>
</select>
- <button class="btn btn-primary" id="{{ (isset($id_button)) ? $id_button : 'bulkAssetEditButton' }}"
+ <button class="btn btn-primary" id="{{ (isset($id_button)) ? $id_button : 'bulkCategoryEditButton' }}"
disabled>{{ trans('button.go') }}</button>
</form>
</div>
diff --git a/resources/views/suppliers/index.blade.php b/resources/views/suppliers/index.blade.php
index 47371a06d4..fca1f83d14 100755
--- a/resources/views/suppliers/index.blade.php
+++ b/resources/views/suppliers/index.blade.php
@@ -23,7 +23,7 @@
<div class="row">
<div class="col-md-12">
- @include('partials.supplier-bulk-actions', [])
+ @include('partials.supplier-bulk-actions')
<table
data-columns="{{ \App\Presenters\SupplierPresenter::dataTableLayout() }}"