From 0adebd1ec8095cdc931f0e58f2d8966f93849e00 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 21 Nov 2017 20:33:30 -0800 Subject: [PATCH] Add sorting and additional category types to dashboard categories BREAKING CHANGE: Category type now reports as `category_type`, instead of `type` --- app/Http/Controllers/Api/CategoriesController.php | 2 +- app/Http/Transformers/CategoriesTransformer.php | 2 +- app/Presenters/CategoryPresenter.php | 2 +- resources/views/dashboard.blade.php | 10 +++++++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Api/CategoriesController.php b/app/Http/Controllers/Api/CategoriesController.php index e86eea78fa..006eea0ff6 100644 --- a/app/Http/Controllers/Api/CategoriesController.php +++ b/app/Http/Controllers/Api/CategoriesController.php @@ -21,7 +21,7 @@ class CategoriesController extends Controller public function index(Request $request) { $this->authorize('view', Category::class); - $allowed_columns = ['id', 'name','category_type','use_default_eula','eula_text', 'require_acceptance','checkin_email', 'assets_count', 'accessories_count', 'consumables_count', 'components_count', 'image']; + $allowed_columns = ['id', 'name','category_type', 'category_type','use_default_eula','eula_text', 'require_acceptance','checkin_email', 'assets_count', 'accessories_count', 'consumables_count', 'components_count', 'image']; $categories = Category::select(['id', 'created_at', 'updated_at', 'name','category_type','use_default_eula','eula_text', 'require_acceptance','checkin_email','image']) ->withCount('assets', 'accessories', 'consumables', 'components'); diff --git a/app/Http/Transformers/CategoriesTransformer.php b/app/Http/Transformers/CategoriesTransformer.php index 0c77917d42..77bf07aa29 100644 --- a/app/Http/Transformers/CategoriesTransformer.php +++ b/app/Http/Transformers/CategoriesTransformer.php @@ -26,7 +26,7 @@ class CategoriesTransformer 'id' => (int) $category->id, 'name' => e($category->name), 'image' => ($category->image) ? app('categories_upload_url').e($category->image) : null, - 'type' => e($category->category_type), + 'category_type' => e($category->category_type), 'eula' => ($category->getEula()) ? true : false, 'checkin_email' => ($category->checkin_email =='1') ? true : false, 'require_acceptance' => ($category->require_acceptance =='1') ? true : false, diff --git a/app/Presenters/CategoryPresenter.php b/app/Presenters/CategoryPresenter.php index db864f43e7..0df0bf13c6 100644 --- a/app/Presenters/CategoryPresenter.php +++ b/app/Presenters/CategoryPresenter.php @@ -40,7 +40,7 @@ class CategoryPresenter extends Presenter "visible" => true, "formatter" => 'imageFormatter', ],[ - "field" => "type", + "field" => "category_type", "searchable" => true, "sortable" => true, "title" => trans('general.type'), diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 37c3c49b95..2c6da09c5e 100755 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -219,11 +219,15 @@ id="table" data-height="440" - data-url="{{ route('api.categories.index') }}"> + data-url="{{ route('api.categories.index', ['sort' => 'assets_count', 'order' => 'asc']) }}"> - {{ trans('general.name') }} - + {{ trans('general.name') }} + {{ trans('general.type') }} + + + +