Skip to content

A free open source IT asset/license management system

Improved messaging for cloning/editing assets that inherit images

snipe1d8493d38879
diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php
index 5fba9390fe..440f128232 100755
--- a/app/Http/Controllers/Assets/AssetsController.php
+++ b/app/Http/Controllers/Assets/AssetsController.php
@@ -652,8 +652,9 @@ class AssetsController extends Controller
*/
public function getClone(Asset $asset)
{
- $this->authorize('create', $asset);
+ $this->authorize('create', Asset::class);
$cloned = clone $asset;
+ $cloned_model = $asset;
$cloned->id = null;
$cloned->asset_tag = '';
$cloned->serial = '';
@@ -663,6 +664,7 @@ class AssetsController extends Controller
return view('hardware/edit')
->with('statuslabel_list', Helper::statusLabelList())
->with('statuslabel_types', Helper::statusTypeList())
+ ->with('cloned_model', $cloned_model)
->with('item', $cloned);
}
diff --git a/resources/lang/en-US/general.php b/resources/lang/en-US/general.php
index 1e2e2665b7..343c942ac0 100644
--- a/resources/lang/en-US/general.php
+++ b/resources/lang/en-US/general.php
@@ -600,6 +600,7 @@ return [
'build' => 'build',
'use_cloned_image' => 'Clone image from original',
'use_cloned_image_help' => 'You may clone the original image or you can upload a new one using the upload field below.',
+ 'use_cloned_no_image_help' => 'This item does not have an associated image and instead inherits from the model or category it belongs to. If you would like to use a specific image for this item, you can upload a new one below.',
'footer_credit' => '<a target="_blank" href="https://snipeitapp.com" rel="noopener">Snipe-IT</a> is open source software, made with <i class="fa fa-heart" aria-hidden="true" style="color: #a94442; font-size: 10px" /></i><span class="sr-only">love</span> by <a href="https://bsky.app/profile/snipeitapp.com" rel="noopener">@snipeitapp.com</a>.',
'set_password' => 'Set a Password',
diff --git a/resources/views/partials/forms/edit/image-upload.blade.php b/resources/views/partials/forms/edit/image-upload.blade.php
index 47a1411d12..61c961c5bb 100644
--- a/resources/views/partials/forms/edit/image-upload.blade.php
+++ b/resources/views/partials/forms/edit/image-upload.blade.php
@@ -35,6 +35,14 @@
{!! $errors->first('image_delete', '<span class="alert-msg">:message</span>') !!}
</div>
</div>
+ @elseif (isset($item) && (isset($item->model)) && ($item->model->image != ''))
+ <div class="form-group">
+ <div class="col-md-8 col-md-offset-3">
+ <p class="text-info">
+ <x-icon type="info-circle" /> {{ trans('general.use_cloned_no_image_help') }}
+ </p>
+ </div>
+ </div>
@endif
@endif
<!-- Image Upload and preview -->