mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge fc36e0cbca
into c9f55bfd94
This commit is contained in:
commit
fe1ec71e98
|
@ -139,7 +139,8 @@ class AssetsController extends Controller
|
|||
'model.category',
|
||||
'model.manufacturer',
|
||||
'model.fieldset',
|
||||
'supplier'
|
||||
'supplier',
|
||||
'assignedAssets',
|
||||
); // it might be tempting to add 'assetlog' here, but don't. It blows up update-heavy users.
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ use App\Models\Accessory;
|
|||
use App\Models\AccessoryCheckout;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Setting;
|
||||
use Barryvdh\Debugbar\Controllers\AssetController;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Carbon\Carbon;
|
||||
|
@ -28,7 +29,6 @@ class AssetsTransformer
|
|||
{
|
||||
// This uses the getSettings() method so we're pulling from the cache versus querying the settings on single asset
|
||||
$setting = Setting::getSettings();
|
||||
|
||||
$array = [
|
||||
'id' => (int) $asset->id,
|
||||
'name' => e($asset->name),
|
||||
|
@ -40,7 +40,7 @@ class AssetsTransformer
|
|||
] : null,
|
||||
'byod' => ($asset->byod ? true : false),
|
||||
'requestable' => ($asset->requestable ? true : false),
|
||||
|
||||
'child_asset_count' => $asset->assignedAssets->count(),
|
||||
'model_number' => (($asset->model) && ($asset->model->model_number)) ? e($asset->model->model_number) : null,
|
||||
'eol' => (($asset->asset_eol_date != '') && ($asset->purchase_date != '')) ? Carbon::parse($asset->asset_eol_date)->diffInMonths($asset->purchase_date).' months' : null,
|
||||
'asset_eol_date' => ($asset->asset_eol_date != '') ? Helper::getFormattedDateObject($asset->asset_eol_date, 'date') : null,
|
||||
|
@ -155,7 +155,7 @@ class AssetsTransformer
|
|||
'clone' => Gate::allows('create', Asset::class) ? true : false,
|
||||
'restore' => ($asset->deleted_at!='' && Gate::allows('create', Asset::class)) ? true : false,
|
||||
'update' => ($asset->deleted_at=='' && Gate::allows('update', Asset::class)) ? true : false,
|
||||
'delete' => ($asset->deleted_at=='' && $asset->assigned_to =='' && Gate::allows('delete', Asset::class) && ($asset->deleted_at == '')) ? true : false,
|
||||
'delete' => ($asset->deleted_at=='' && $asset->assigned_to =='' && Gate::allows('delete', Asset::class) && ($asset->deleted_at == '')) && ($asset->assignedAssets->count() === 0) ? true : false,
|
||||
];
|
||||
|
||||
|
||||
|
|
|
@ -496,6 +496,7 @@ return [
|
|||
'no_autoassign_licenses_help' => 'Do not include user for bulk-assigning through the license UI or cli tools.',
|
||||
'modal_confirm_generic' => 'Are you sure?',
|
||||
'cannot_be_deleted' => 'This item cannot be deleted',
|
||||
'cannot_delete_parent_asset' => 'Cannot delete asset until attached assets are checked in.',
|
||||
'cannot_be_edited' => 'This item cannot be edited.',
|
||||
'undeployable_tooltip' => 'This item cannot be checked out. Check the quantity remaining.',
|
||||
'serial_number' => 'Serial Number',
|
||||
|
|
|
@ -308,7 +308,6 @@
|
|||
return '<a href="{{ config('app.url') }}/hardware/audit/' + row.id + '/" class="btn btn-sm bg-yellow" data-tooltip="true" title="Audit this item">{{ trans('general.audit') }}</a>';
|
||||
}
|
||||
|
||||
|
||||
// Make the edit/delete buttons
|
||||
function genericActionsFormatter(owner_name, element_name) {
|
||||
if (!element_name) {
|
||||
|
@ -360,9 +359,12 @@
|
|||
} else {
|
||||
// Do not show the delete button on things that are already deleted
|
||||
if ((row.available_actions) && (row.available_actions.restore != true)) {
|
||||
actions += '<span data-tooltip="true" title="{{ trans('general.cannot_be_deleted') }}"><a class="btn btn-danger btn-sm delete-asset disabled" onClick="return false;"><x-icon type="delete" /><span class="sr-only">{{ trans('general.cannot_be_deleted') }}</span></a></span> ';
|
||||
var message = "{{trans('general.cannot_be_deleted')}}";
|
||||
if(row.child_asset_count > 0){
|
||||
message = "{{trans('general.cannot_delete_parent_asset')}}";
|
||||
}
|
||||
actions += '<span data-tooltip="true" title="'+message+'"><a class="btn btn-danger btn-sm delete-asset disabled" onClick="return false;"><x-icon type="delete" /><span class="sr-only">{{ trans('general.cannot_be_deleted') }}</span></a></span> ';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue