diff --git a/app/Models/PredefinedKit.php b/app/Models/PredefinedKit.php index 7564bafab5..ea6f478fa9 100644 --- a/app/Models/PredefinedKit.php +++ b/app/Models/PredefinedKit.php @@ -120,10 +120,6 @@ class PredefinedKit extends SnipeModel } - public function applyToUser(User $user) { - $models = $this->models(); - } - /** * ----------------------------------------------- * BEGIN QUERY SCOPES diff --git a/app/Presenters/PredefinedKitPresenter.php b/app/Presenters/PredefinedKitPresenter.php index 05f86441cb..26ae3bf6af 100644 --- a/app/Presenters/PredefinedKitPresenter.php +++ b/app/Presenters/PredefinedKitPresenter.php @@ -144,6 +144,11 @@ class PredefinedKitPresenter extends Presenter "sortable" => true, "title" => 'Name', // TODO: trans "formatter" => "licensesLinkFormatter" + ], [ + "field" => "quantity", + "searchable" => false, + "sortable" => false, + "title" => 'Quantity', // TODO: trans ], [ "field" => "actions", "searchable" => false, @@ -157,6 +162,110 @@ class PredefinedKitPresenter extends Presenter return json_encode($layout); } + /** + * Json Column Layout for bootstrap table + * @return string + */ + public static function dataTableAccessories() + { + $layout = [ + [ + "field" => "id", + "searchable" => false, + "sortable" => true, + "switchable" => true, + "title" => trans('general.id'), + "visible" => false + ], [ + "field" => "pivot_id", + "searchable" => false, + "sortable" => true, + "switchable" => true, + "title" => trans('general.id'), + "visible" => false + ], [ + "field" => "owner_id", + "searchable" => false, + "sortable" => true, + "switchable" => true, + "title" => trans('general.id'), + "visible" => false + ], [ + "field" => "name", + "searchable" => true, + "sortable" => true, + "title" => 'Name', // TODO: trans + "formatter" => "accessoriesLinkFormatter" // MYTODO: check + ], [ + "field" => "quantity", + "searchable" => false, + "sortable" => false, + "title" => 'Quantity', // TODO: trans + ], [ + "field" => "actions", + "searchable" => false, + "sortable" => false, + "switchable" => false, + "title" => trans('table.actions'), + "formatter" => "kits_accessoriesActionsFormatter", // MYTODO: check + ] + ]; + + return json_encode($layout); + } + + + /** + * Json Column Layout for bootstrap table + * @return string + */ + public static function dataTableConsumables() + { + $layout = [ + [ + "field" => "id", + "searchable" => false, + "sortable" => true, + "switchable" => true, + "title" => trans('general.id'), + "visible" => false + ], [ + "field" => "pivot_id", + "searchable" => false, + "sortable" => true, + "switchable" => true, + "title" => trans('general.id'), + "visible" => false + ], [ + "field" => "owner_id", + "searchable" => false, + "sortable" => true, + "switchable" => true, + "title" => trans('general.id'), + "visible" => false + ], [ + "field" => "name", + "searchable" => true, + "sortable" => true, + "title" => 'Name', // TODO: trans + "formatter" => "consumablesLinkFormatter" // MYTODO: check + ], [ + "field" => "quantity", + "searchable" => false, + "sortable" => false, + "title" => 'Quantity', // TODO: trans + ], [ + "field" => "actions", + "searchable" => false, + "sortable" => false, + "switchable" => false, + "title" => trans('table.actions'), + "formatter" => "kits_consumablesActionsFormatter", // MYTODO: check + ] + ]; + + return json_encode($layout); + } /** diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 0ccda1ea3b..4e17c798c2 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -64,7 +64,7 @@ class RouteServiceProvider extends ServiceProvider require base_path('routes/web/components.php'); require base_path('routes/web/users.php'); require base_path('routes/web/kits.php'); - require base_path('routes/web/dbtest.php'); + //require base_path('routes/web/dbtest.php'); require base_path('routes/web.php'); }); } diff --git a/resources/assets/js/snipeit_modals.js b/resources/assets/js/snipeit_modals.js index 56fcdcbc28..30791ce425 100644 --- a/resources/assets/js/snipeit_modals.js +++ b/resources/assets/js/snipeit_modals.js @@ -28,7 +28,7 @@ $(function () { //handle modal-add-interstitial calls - var model, select; + var model, select, refreshSelector; if($('#createModal').length == 0) { $('body').append(''); @@ -38,6 +38,8 @@ $(function () { var link = $(event.relatedTarget); model = link.data("dependency"); select = link.data("select"); + refreshSelector = link.data("refresh"); + $('#createModal').load(link.attr('href'),function () { //do we need to re-select2 this, after load? Probably. $('#createModal').find('select.select2').select2(); @@ -123,6 +125,12 @@ $(function () { $('#createModal').modal('hide'); $('#createModal').html(""); + var refreshTable = $('#' + refreshSelector); + + if(refreshTable.length > 0) { + refreshTable.bootstrapTable('refresh'); + } + // "select" is the original drop-down menu that someone // clicked 'add' on to add a new 'thing' // this code adds the newly created object to that select diff --git a/resources/views/kits/edit.blade.php b/resources/views/kits/edit.blade.php index 6e6ab87421..db16d9dd79 100644 --- a/resources/views/kits/edit.blade.php +++ b/resources/views/kits/edit.blade.php @@ -11,12 +11,13 @@ @section('content') @parent +{{-- Assets by model --}}
{{--

Models Append

--}} -

Models

+

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

@@ -39,21 +40,21 @@ "ignoreColumn": ["actions","image","change","checkbox","checkincheckout","icon"] }'> - Append + Append
+{{-- Licenses --}}
-

Licenses

+

Licenses{{-- TODO: trans --}}

diff --git a/resources/views/modals/kit-accessory.blade.php b/resources/views/modals/kit-accessory.blade.php new file mode 100644 index 0000000000..654116a445 --- /dev/null +++ b/resources/views/modals/kit-accessory.blade.php @@ -0,0 +1,38 @@ +{{-- See snipeit_modals.js for what powers this --}} + diff --git a/resources/views/modals/kit-consumable.blade.php b/resources/views/modals/kit-consumable.blade.php new file mode 100644 index 0000000000..ae948b8500 --- /dev/null +++ b/resources/views/modals/kit-consumable.blade.php @@ -0,0 +1,38 @@ +{{-- See snipeit_modals.js for what powers this --}} + diff --git a/resources/views/modals/kit-license.blade.php b/resources/views/modals/kit-license.blade.php new file mode 100644 index 0000000000..e3306ae867 --- /dev/null +++ b/resources/views/modals/kit-license.blade.php @@ -0,0 +1,38 @@ +{{-- See snipeit_modals.js for what powers this --}} + diff --git a/resources/views/modals/kit-model.blade.php b/resources/views/modals/kit-model.blade.php index 4f90f25724..1800184a73 100644 --- a/resources/views/modals/kit-model.blade.php +++ b/resources/views/modals/kit-model.blade.php @@ -24,7 +24,7 @@
- +
diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 28f93dad77..a965855557 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -341,6 +341,8 @@ var child_formatters = [ ['kits', 'models'], ['kits', 'licenses'], + ['kits', 'consumables'], + ['kits', 'accessories'], ]; for (var i in child_formatters) { diff --git a/routes/api.php b/routes/api.php index cf7f749612..ab038aa812 100644 --- a/routes/api.php +++ b/routes/api.php @@ -751,7 +751,8 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () { [ 'as' => 'api.activity.index', 'uses' => 'ReportsController@index' ] ); - // kits + /*--- Kits API ---*/ + Route::resource('kits', 'PredefinedKitsController', [ 'names' => @@ -770,6 +771,7 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () { Route::group([ 'prefix' => 'kits/{kit_id}' ], function () { + // kit licenses Route::get('licenses', [ 'as' => 'api.kits.licenses.index', @@ -798,7 +800,7 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () { ] ); - + // kit models Route::get('models', [ 'as' => 'api.kits.models.index', @@ -827,6 +829,64 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () { ] ); + // kit accessories + Route::get('accessories', + [ + 'as' => 'api.kits.accessories.index', + 'uses' => 'PredefinedKitsController@indexAccessories', + ] + ); + + Route::post('accessories', + [ + 'as' => 'api.kits.accessories.store', + 'uses' => 'PredefinedKitsController@storeAccessory', + ] + ); + + Route::put('accessories/{accessory_id}', + [ + 'as' => 'api.kits.accessories.update', + 'uses' => 'PredefinedKitsController@updateAccessory', + ] + ); + + Route::delete('accessories/{accessory_id}', + [ + 'as' => 'api.kits.accessories.destroy', + 'uses' => 'PredefinedKitsController@detachAccessory', + ] + ); + + // kit consumables + Route::get('consumables', + [ + 'as' => 'api.kits.consumables.index', + 'uses' => 'PredefinedKitsController@indexConsumables', + ] + ); + + Route::post('consumables', + [ + 'as' => 'api.kits.consumables.store', + 'uses' => 'PredefinedKitsController@storeConsumable', + ] + ); + + Route::put('consumables/{consumable_id}', + [ + 'as' => 'api.kits.consumables.update', + 'uses' => 'PredefinedKitsController@updateConsumable', + ] + ); + + Route::delete('consumables/{consumable_id}', + [ + 'as' => 'api.kits.consumables.destroy', + 'uses' => 'PredefinedKitsController@detachConsumable', + ] + ); + }); // kits }); diff --git a/routes/web/kits.php b/routes/web/kits.php index e53c702699..ca1ff534ab 100644 --- a/routes/web/kits.php +++ b/routes/web/kits.php @@ -30,6 +30,14 @@ Route::group([ 'prefix' => 'kits/{kit_id}', 'middleware' => ['auth'] ], function 'uses' => 'Kits\PredefinedKitsController@updateLicense', ] ); + + Route::get('licenses/{license_id}/edit', + [ + 'as' => 'kits.licenses.edit', + 'uses' => 'Kits\PredefinedKitsController@editLicense', + + ] + ); Route::delete('licenses/{license_id}', [ @@ -37,15 +45,10 @@ Route::group([ 'prefix' => 'kits/{kit_id}', 'middleware' => ['auth'] ], function 'uses' => 'Kits\PredefinedKitsController@detachLicense', ] ); + - - // Route::get('models', - // [ - // 'as' => 'kits.models.index', - // 'uses' => 'Kits\PredefinedKitsController@indexModels', - // ] - // ); - + // Models + Route::post('models', [ 'as' => 'kits.models.store', @@ -76,6 +79,71 @@ Route::group([ 'prefix' => 'kits/{kit_id}', 'middleware' => ['auth'] ], function ] ); + + // Consumables + + Route::post('consumables', + [ + 'as' => 'kits.consumables.store', + 'uses' => 'Kits\PredefinedKitsController@storeConsumable', + ] + ); + + Route::put('consumables/{consumable_id}', + [ + 'as' => 'kits.consumables.update', + 'uses' => 'Kits\PredefinedKitsController@updateConsumable', + 'parameters' => [2 => 'kit_id', 1 => 'consumable_id'] + ] + ); + + Route::get('consumables/{consumable_id}/edit', + [ + 'as' => 'kits.consumables.edit', + 'uses' => 'Kits\PredefinedKitsController@editConsumable', + + ] + ); + + Route::delete('consumables/{consumable_id}', + [ + 'as' => 'kits.consumables.detach', + 'uses' => 'Kits\PredefinedKitsController@detachConsumable', + ] + ); + + + // Accessories + + Route::post('accessories', + [ + 'as' => 'kits.accessories.store', + 'uses' => 'Kits\PredefinedKitsController@storeAccessory', + ] + ); + + Route::put('accessories/{accessory_id}', + [ + 'as' => 'kits.accessories.update', + 'uses' => 'Kits\PredefinedKitsController@updateAccessory', + 'parameters' => [2 => 'kit_id', 1 => 'accessory_id'] + ] + ); + + Route::get('accessories/{accessory_id}/edit', + [ + 'as' => 'kits.accessories.edit', + 'uses' => 'Kits\PredefinedKitsController@editAccessory', + + ] + ); + + Route::delete('accessories/{accessory_id}', + [ + 'as' => 'kits.accessories.detach', + 'uses' => 'Kits\PredefinedKitsController@detachAccessory', + ] + ); Route::get('checkout', [ 'as' => 'kits.checkout.show',