Skip to content

Commit

Permalink
Merge pull request #15128 from snipe/fixes/nicer_consumables_layout
Browse files Browse the repository at this point in the history
Nicer consumables layout
  • Loading branch information
snipe authored Jul 20, 2024
2 parents f63fd25 + 38affea commit f2acb98
Show file tree
Hide file tree
Showing 8 changed files with 548 additions and 319 deletions.
14 changes: 13 additions & 1 deletion app/Http/Controllers/Consumables/ConsumablesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function destroy($consumableId)
*/
public function show($consumableId = null)
{
$consumable = Consumable::find($consumableId);
$consumable = Consumable::withCount('users as users_consumables')->find($consumableId);
$this->authorize($consumable);
if (isset($consumable->id)) {
return view('consumables/view', compact('consumable'));
Expand All @@ -209,4 +209,16 @@ public function show($consumableId = null)
return redirect()->route('consumables.index')
->with('error', trans('admin/consumables/message.does_not_exist'));
}

public function clone(Consumable $consumable) : View
{
$this->authorize('create', $consumable);
$consumable_to_close = $consumable;
$consumable = clone $consumable_to_close;
$consumable->id = null;
$consumable->image = null;
$consumable->user_id = null;

return view('consumables/edit')->with('item', $consumable);
}
}
1 change: 1 addition & 0 deletions app/Http/Transformers/ConsumablesTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function transformConsumable(Consumable $consumable)
'checkin' => Gate::allows('checkin', Consumable::class),
'update' => Gate::allows('update', Consumable::class),
'delete' => Gate::allows('delete', Consumable::class),
'clone' => (Gate::allows('create', Consumable::class) && ($consumable->deleted_at == '')),
];
$array += $permissions_array;

Expand Down
1 change: 1 addition & 0 deletions resources/lang/en-US/admin/consumables/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
'remaining' => 'Remaining',
'total' => 'Total',
'update' => 'Update Consumable',
'inventory_warning' => 'The inventory of this consumable is below the minimum amount of :min_count',
);
10 changes: 10 additions & 0 deletions resources/lang/en-US/button.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'checkin_and_delete' => 'Checkin All / Delete User',
'delete' => 'Delete',
'edit' => 'Edit',
'clone' => 'Clone',
'restore' => 'Restore',
'remove' => 'Remove',
'request' => 'Request',
Expand All @@ -21,4 +22,13 @@
'add_maintenance' => 'Add Maintenance',
'append' => 'Append',
'new' => 'New',
'var' => [
'clone' => 'Clone :item_type',
'edit' => 'Edit :item_type',
'delete' => 'Delete :item_type',
'restore' => 'Delete :item_type',
'create' => 'Create New :item_type',
'checkout' => 'Checkout :item_type',
'checkin' => 'Checkin :item_type',
]
];
1 change: 1 addition & 0 deletions resources/lang/en-US/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,5 +557,6 @@
'close' => 'Close',
'expires' => 'Expires',
'map_fields'=> 'Map :item_type Field',
'remaining_var' => ':count Remaining',

];
2 changes: 1 addition & 1 deletion resources/views/accessories/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ class="table table-striped snipe-table"
<a href="{{ route('accessories.edit', $accessory->id) }}" style="margin-right:5px; width:100%" class="btn btn-primary btn-sm">{{ trans('admin/accessories/general.edit') }}</a>
</div>
@endcan
@can('update', \App\Models\Accessory::class)
@can('create', \App\Models\Accessory::class)
<div class="text-center" style="padding-top:5px;">
<a href="{{ route('clone/accessories', $accessory->id) }}" style="margin-right:5px; width:100%" class="btn btn-primary btn-sm">{{ trans('admin/accessories/general.clone') }}</a>
</div>
Expand Down
Loading

0 comments on commit f2acb98

Please sign in to comment.