From 7e8d337ed584aa24ca60c37e685dae4d34472087 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 8 Mar 2019 16:49:05 -0800 Subject: [PATCH 1/3] Moved kit icon --- resources/views/layouts/default.blade.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index 44ba4d49ad..2d84259449 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -492,6 +492,15 @@ @endcan + @can('view', \App\Models\PredefinedKit::class) + + + + {{ trans('general.kits') }} + + + @endcan + @can('view', \App\Models\User::class) @@ -665,12 +674,7 @@ @endcan - - - - Predefined kits{{-- TODO: trans --}} - - + From 1b0d855c00b9de42fdf138b967d1708bb51538e7 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 13 Mar 2019 12:15:48 -0700 Subject: [PATCH 2/3] Added translation, removed commented out code --- .../Api/PredefinedKitsController.php | 14 +++++------ app/Services/PredefinedKitCheckoutService.php | 13 +++++----- resources/lang/en/admin/kits/general.php | 16 ++++++++++++ resources/lang/en/general.php | 1 + resources/views/kits/checkout.blade.php | 7 ++---- resources/views/kits/create.blade.php | 8 +++--- resources/views/kits/edit.blade.php | 9 +++---- resources/views/kits/index.blade.php | 25 ++----------------- 8 files changed, 42 insertions(+), 51 deletions(-) create mode 100644 resources/lang/en/admin/kits/general.php diff --git a/app/Http/Controllers/Api/PredefinedKitsController.php b/app/Http/Controllers/Api/PredefinedKitsController.php index 6cf0f7bca1..97e179ecb3 100644 --- a/app/Http/Controllers/Api/PredefinedKitsController.php +++ b/app/Http/Controllers/Api/PredefinedKitsController.php @@ -55,7 +55,7 @@ class PredefinedKitsController extends Controller $kit->fill($request->all()); if ($kit->save()) { - return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Created was successfull')); // TODO: trans + return response()->json(Helper::formatStandardApiResponse('success', $kit, trans('admin/kits/general.create_success'))); } return response()->json(Helper::formatStandardApiResponse('error', null, $kit->getErrors())); @@ -89,7 +89,7 @@ class PredefinedKitsController extends Controller $kit->fill($request->all()); if ($kit->save()) { - return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Update was successfull')); // TODO: trans + return response()->json(Helper::formatStandardApiResponse('success', $kit, trans('admin/kits/general.update_success'))); // TODO: trans } return response()->json(Helper::formatStandardApiResponse('error', null, $kit->getErrors())); @@ -113,7 +113,7 @@ class PredefinedKitsController extends Controller $kit->accessories()->detach(); $kit->delete(); - return response()->json(Helper::formatStandardApiResponse('success', null, 'Delete was successfull')); // TODO: trans + return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/kits/general.delete_success'))); // TODO: trans } @@ -214,7 +214,7 @@ class PredefinedKitsController extends Controller $kit = PredefinedKit::findOrFail($kit_id); $kit->licenses()->detach($license_id); - return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Delete was successfull')); // TODO: trans + return response()->json(Helper::formatStandardApiResponse('success', $kit, trans('admin/kits/general.delete_success'))); } /** @@ -238,7 +238,7 @@ class PredefinedKitsController extends Controller */ public function storeModel(Request $request, $kit_id) { - //return response()->json(Helper::formatStandardApiResponse('error', 'string11', dd($request))); // TODO: trans + $this->authorize('update', PredefinedKit::class); @@ -256,7 +256,7 @@ class PredefinedKitsController extends Controller } $relation->attach($model_id, ['quantity' => $quantity]); - return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Model added successfull')); // TODO: trans + return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Model added successfull')); } /** @@ -291,7 +291,7 @@ class PredefinedKitsController extends Controller $kit = PredefinedKit::findOrFail($kit_id); $kit->models()->detach($model_id); - return response()->json(Helper::formatStandardApiResponse('success', $kit, 'Delete was successfull')); // TODO: trans + return response()->json(Helper::formatStandardApiResponse('success', $kit, trans('admin/kits/general.model_removed_success'))); } diff --git a/app/Services/PredefinedKitCheckoutService.php b/app/Services/PredefinedKitCheckoutService.php index abc95b31a9..4249e9613b 100644 --- a/app/Services/PredefinedKitCheckoutService.php +++ b/app/Services/PredefinedKitCheckoutService.php @@ -95,7 +95,7 @@ class PredefinedKitCheckoutService } } if ($quantity > 0) { - $errors[] = "Don't have available assets for model " . $model->name . '. Need ' . $model->pivot->quantity . ' assets.'; // TODO: trans + $errors[] = trans('admin/kits/general.none_models', ['model'=> $model->name, 'qty' => $model->pivot->quantity]); } } @@ -111,7 +111,7 @@ class PredefinedKitCheckoutService foreach ($licenses as $license) { $quantity = $license->pivot->quantity; if ($quantity > count($license->freeSeats)) { - $errors[] = "Don't have free seats for license " . $license->name . '. Need ' . $quantity . ' seats.'; // TODO: trans + $errors[] = trans('admin/kits/general.none_licenses', ['license'=> $license->name, 'qty' => $license->pivot->quantity]); } for ($i = 0; $i < $quantity; $i++) { $seats_to_add[] = $license->freeSeats[$i]; @@ -122,11 +122,10 @@ class PredefinedKitCheckoutService protected function getConsumablesToAdd($kit, &$errors) { - // $consumables = $kit->consumables()->withCount('consumableAssignments as consumable_assignments_count')->get(); $consumables = $kit->consumables()->with('users')->get(); foreach ($consumables as $consumable) { if ($consumable->numRemaining() < $consumable->pivot->quantity) { - $errors[] = "Don't have available consumable " . $consumable->name . '. Need ' . $consumable->pivot->quantity; // TODO: trans + $errors[] = trans('admin/kits/general.none_consumables', ['consumable'=> $consumable->name, 'qty' => $consumable->pivot->quantity]); } } return $consumables; @@ -135,9 +134,9 @@ class PredefinedKitCheckoutService protected function getAccessoriesToAdd($kit, &$errors) { $accessories = $kit->accessories()->with('users')->get(); - foreach ($accessories as $accossory) { - if ($accossory->numRemaining() < $accossory->pivot->quantity) { - $errors[] = "Don't have available accossory " . $accossory->name . '. Need ' . $accossory->pivot->quantity; // TODO: trans + foreach ($accessories as $accessory) { + if ($accessory->numRemaining() < $accessory->pivot->quantity) { + $errors[] = trans('admin/kits/general.none_accessory', ['consumable'=> $accessory->name, 'qty' => $accessory->pivot->quantity]); } } return $accessories; diff --git a/resources/lang/en/admin/kits/general.php b/resources/lang/en/admin/kits/general.php new file mode 100644 index 0000000000..030f790677 --- /dev/null +++ b/resources/lang/en/admin/kits/general.php @@ -0,0 +1,16 @@ + 'About Predefined Kits', + 'checkout' => 'Checkout Kit ', + 'create_success' => 'Kit was successfully created.', + 'create' => 'Create Predefined Kit', + 'update' => 'Update Predefined Kit', + 'delete_success' => 'Kit was successfully deleted.', + 'update_success' => 'Kit was successfully updated.', + 'none_models' => 'There are not enough available assets for :model to checkout. :qty are required. ', + 'none_licenses' => 'There are not enough available seats for :license to checkout. :qty are required. ', + 'none_consumables' => 'There are not enough available units of :consumable to checkout. :qty are required. ', + 'none_accessory' => 'There are not enough available units of :accessory to checkout. :qty are required. ', + +); diff --git a/resources/lang/en/general.php b/resources/lang/en/general.php index 3c902c24eb..ec823a4877 100644 --- a/resources/lang/en/general.php +++ b/resources/lang/en/general.php @@ -112,6 +112,7 @@ 'asset_maintenances' => 'Asset Maintenances', 'item' => 'Item', 'insufficient_permissions' => 'Insufficient permissions!', + 'kits' => 'Predefined Kits', 'language' => 'Language', 'last' => 'Last', 'last_login' => 'Last Login', diff --git a/resources/views/kits/checkout.blade.php b/resources/views/kits/checkout.blade.php index d9ca25f55f..b8e836778b 100644 --- a/resources/views/kits/checkout.blade.php +++ b/resources/views/kits/checkout.blade.php @@ -2,7 +2,7 @@ {{-- Page title --}} @section('title') - Apply predefined kit{{-- TODO: trans --}} + {{ trans('admin/kits/general.checkout') }} @parent @stop @@ -20,9 +20,6 @@
-
-

Apply predefined kit {{ $kit->name }} to user {{-- TODO: trans --}}

-
{{ csrf_field() }} @@ -64,7 +61,7 @@
diff --git a/resources/views/kits/create.blade.php b/resources/views/kits/create.blade.php index 4be2bb5dca..801f4c4800 100644 --- a/resources/views/kits/create.blade.php +++ b/resources/views/kits/create.blade.php @@ -1,10 +1,10 @@ @extends('layouts/edit-form', [ - 'createText' => 'Create kit', - 'updateText' => 'Update kit', + 'createText' => trans('admin/kits/general.create'), + 'updateText' => trans('admin/kits/general.update'), 'formAction' => ($item) ? route('kits.update', ['kit' => $item->id]) : route('kits.store'), ]) {{-- Page content --}} @section('inputFields') -@include ('partials.forms.edit.name', ['translated_name' => 'Name']) {{-- TODO: trans --}} -@stop \ No newline at end of file +@include ('partials.forms.edit.name', ['translated_name' => trans('general.name')]) +@stop diff --git a/resources/views/kits/edit.blade.php b/resources/views/kits/edit.blade.php index 7d26142d02..60b1c9e2d9 100644 --- a/resources/views/kits/edit.blade.php +++ b/resources/views/kits/edit.blade.php @@ -1,6 +1,6 @@ @extends('layouts/edit-form', [ - 'createText' => 'Create kit', - 'updateText' => 'Update kit', + 'createText' => trans('admin/kits/general.create'), + 'updateText' => trans('admin/kits/general.update'), 'formAction' => ($item) ? route('kits.update', ['kit' => $item->id]) : route('kits.store'), ]) @@ -16,8 +16,7 @@
- {{--

Models Append

--}} -

Assets (by models){{-- TODO: trans --}}

+

{{ trans('general.asset_models') }}

@@ -152,4 +151,4 @@ @section('moar_scripts') @include ('partials.bootstrap-table') -@stop \ No newline at end of file +@stop diff --git a/resources/views/kits/index.blade.php b/resources/views/kits/index.blade.php index 6cf41e73f7..ffc808f80d 100644 --- a/resources/views/kits/index.blade.php +++ b/resources/views/kits/index.blade.php @@ -2,7 +2,7 @@ {{-- Web site Title --}} @section('title') -Kits + {{ trans('general.kits') }} @parent @stop @@ -39,28 +39,7 @@ Kits }'>
- {{--

Test

-
- -
-
--}} +
From 2c79ed5fc11279a7eea432b164878f5f9a02af24 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 13 Mar 2019 12:15:54 -0700 Subject: [PATCH 3/3] Added kit permissions --- config/permissions.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/config/permissions.php b/config/permissions.php index 0550886167..7692477548 100644 --- a/config/permissions.php +++ b/config/permissions.php @@ -252,6 +252,41 @@ return array( ), + 'Kits' => array( + array( + 'permission' => 'kits.view', + 'label' => 'View ', + 'note' => 'These are predefined kits that can be used to quickly checkout assets, licenses, etc.', + 'display' => true, + ), + array( + 'permission' => 'kits.create', + 'label' => 'Create ', + 'note' => '', + 'display' => true, + ), + array( + 'permission' => 'kits.edit', + 'label' => 'Edit ', + 'note' => '', + 'display' => true, + ), + array( + 'permission' => 'kits.delete', + 'label' => 'Delete ', + 'note' => '', + 'display' => true, + ), + + array( + 'permission' => 'kits.checkout', + 'label' => 'Checkout ', + 'note' => '', + 'display' => true, + ), + ), + + 'Users' => array( array( 'permission' => 'users.view',