Add sorting and additional category types to dashboard categories

BREAKING CHANGE: Category type now reports as `category_type`, instead of `type`
This commit is contained in:
snipe 2017-11-21 20:33:30 -08:00
parent 43c1e893c0
commit 0adebd1ec8
4 changed files with 10 additions and 6 deletions

View file

@ -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');

View file

@ -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,

View file

@ -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'),

View file

@ -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']) }}">
<thead>
<tr>
<th class="col-sm-2" data-field="name" data-formatter="categoriesLinkFormatter">{{ trans('general.name') }}</th>
<th class="col-sm-2" data-field="assets_count"><i class="fa fa-barcode"></i></th>
<th class="col-sm-3" data-field="name" data-formatter="categoriesLinkFormatter" data-sortable="true">{{ trans('general.name') }}</th>
<th class="col-sm-3" data-field="category_type" data-sortable="true">{{ trans('general.type') }}</th>
<th class="col-sm-1" data-field="assets_count" data-sortable="true"><i class="fa fa-barcode"></i></th>
<th class="col-sm-1" data-field="accessories_count" data-sortable="true"><i class="fa fa-keyboard-o"></i></th>
<th class="col-sm-1" data-field="consumables_count" data-sortable="true"><i class="fa fa-tint"></i></th>
<th class="col-sm-1" data-field="components_count" data-sortable="true"><i class="fa fa-hdd-o"></i></th>
</tr>
</thead>
</table>