mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
Pull image formatter out of dynamic loop, pass full url to formatter
This commit is contained in:
parent
04bb180a80
commit
75d35273c9
|
@ -22,7 +22,7 @@ class AssetModelsTransformer
|
||||||
'id' => $assetmodel->id,
|
'id' => $assetmodel->id,
|
||||||
'name' => e($assetmodel->name),
|
'name' => e($assetmodel->name),
|
||||||
'manufacturer' => ($assetmodel->manufacturer_id) ? $assetmodel->manufacturer : null,
|
'manufacturer' => ($assetmodel->manufacturer_id) ? $assetmodel->manufacturer : null,
|
||||||
'image' => e($assetmodel->image),
|
'image' => ($assetmodel->image!='') ? url('/').'/uploads/models/'.e($assetmodel->image) : '',
|
||||||
'model_number' => e($assetmodel->model_number),
|
'model_number' => e($assetmodel->model_number),
|
||||||
'depreciation' => ($assetmodel->depreciation) ? $assetmodel->depreciation : 'No',
|
'depreciation' => ($assetmodel->depreciation) ? $assetmodel->depreciation : 'No',
|
||||||
'assets_count' => $assetmodel->assets_count,
|
'assets_count' => $assetmodel->assets_count,
|
||||||
|
|
|
@ -34,8 +34,8 @@ class AssetsTransformer
|
||||||
'expected_checkin' => $asset->expected_checkin,
|
'expected_checkin' => $asset->expected_checkin,
|
||||||
'order_number' => $asset->order_number,
|
'order_number' => $asset->order_number,
|
||||||
'companyName' => $asset->companyName,
|
'companyName' => $asset->companyName,
|
||||||
'location' => ($asset->assetLoc) ? $asset->assetLoc : '',
|
'location' => ($asset->assetLoc) ? $asset->assetLoc : null,
|
||||||
'image' => $asset->image,
|
'image' => ($asset->getImageUrl()) ? $asset->getImageUrl() : null,
|
||||||
'assigned_to' => ($asset->assigneduser) ? (new UsersTransformer)->transformUser($asset->assigneduser) : null,
|
'assigned_to' => ($asset->assigneduser) ? (new UsersTransformer)->transformUser($asset->assigneduser) : null,
|
||||||
'created_at' => $asset->created_at,
|
'created_at' => $asset->created_at,
|
||||||
'purchase_date' => $asset->purchase_date,
|
'purchase_date' => $asset->purchase_date,
|
||||||
|
|
|
@ -271,6 +271,17 @@ class Asset extends Depreciable
|
||||||
return $this->belongsTo('\App\Models\Location', 'rtd_location_id');
|
return $this->belongsTo('\App\Models\Location', 'rtd_location_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getImageUrl() {
|
||||||
|
if ($this->image && !empty($this->image)) {
|
||||||
|
return url('/').'/uploads/assets/'.$this->image;
|
||||||
|
} elseif ($this->model && !empty($this->model->image)) {
|
||||||
|
return url('/').'/uploads/models/'.$this->model->image;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get action logs for this asset
|
* Get action logs for this asset
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
@endif
|
@endif
|
||||||
<th data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
|
<th data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
|
||||||
<th data-field="companyName" data-formatter="companiesLinkObjFormatter" data-searchable="true" data-sortable="true" data-switchable="true" data-visible="false">{{ trans('general.company') }}</th>
|
<th data-field="companyName" data-formatter="companiesLinkObjFormatter" data-searchable="true" data-sortable="true" data-switchable="true" data-visible="false">{{ trans('general.company') }}</th>
|
||||||
<th data-sortable="true" data-field="image" data-visible="false">{{ trans('admin/hardware/table.image') }}</th>
|
<th data-sortable="true" data-field="image" data-formatter="imageFormatter" data-visible="false">{{ trans('admin/hardware/table.image') }}</th>
|
||||||
<th data-sortable="true" data-field="name" data-visible="false" data-formatter="hardwareLinkFormatter">{{ trans('admin/hardware/form.name') }}</th>
|
<th data-sortable="true" data-field="name" data-visible="false" data-formatter="hardwareLinkFormatter">{{ trans('admin/hardware/form.name') }}</th>
|
||||||
<th data-sortable="true" data-field="asset_tag" data-formatter="hardwareLinkFormatter">{{ trans('admin/hardware/table.asset_tag') }}</th>
|
<th data-sortable="true" data-field="asset_tag" data-formatter="hardwareLinkFormatter">{{ trans('admin/hardware/table.asset_tag') }}</th>
|
||||||
<th data-sortable="true" data-field="serial" data-formatter="hardwareLinkFormatter">{{ trans('admin/hardware/table.serial') }}</th>
|
<th data-sortable="true" data-field="serial" data-formatter="hardwareLinkFormatter">{{ trans('admin/hardware/table.serial') }}</th>
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
|
<th data-sortable="true" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
|
||||||
<th data-sortable="true" data-field="name" data-formatter="modelsLinkFormatter">{{ trans('general.name') }}</th>
|
<th data-sortable="true" data-field="name" data-formatter="modelsLinkFormatter">{{ trans('general.name') }}</th>
|
||||||
<th data-sortable="true" data-field="image" data-formatter="modelsImageFormatter" data-visible="false">{{ trans('admin/hardware/table.image') }}</th>
|
<th data-sortable="true" data-field="image" data-formatter="imageFormatter" data-visible="false">{{ trans('admin/hardware/table.image') }}</th>
|
||||||
<th data-sortable="false" data-field="manufacturer" data-formatter="manufacturersLinkObjFormatter">{{ trans('general.manufacturer') }}</th>
|
<th data-sortable="false" data-field="manufacturer" data-formatter="manufacturersLinkObjFormatter">{{ trans('general.manufacturer') }}</th>
|
||||||
|
|
||||||
<th data-sortable="true" data-field="model_number">{{ trans('admin/models/table.modelnumber') }}</th>
|
<th data-sortable="true" data-field="model_number">{{ trans('admin/models/table.modelnumber') }}</th>
|
||||||
|
|
|
@ -115,13 +115,7 @@ $('.snipe-table').bootstrapTable({
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function genericPublicImageFormatter(destination) {
|
|
||||||
return function (value,row) {
|
|
||||||
if (value) {
|
|
||||||
return '<img src="{{ url('/') }}/uploads/' + destination + '/' + value + '" height="50" width="50">';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var formatters = [
|
var formatters = [
|
||||||
'hardware',
|
'hardware',
|
||||||
|
@ -142,7 +136,6 @@ $('.snipe-table').bootstrapTable({
|
||||||
window[formatters[i] + 'LinkFormatter'] = genericRowLinkFormatter(formatters[i]);
|
window[formatters[i] + 'LinkFormatter'] = genericRowLinkFormatter(formatters[i]);
|
||||||
window[formatters[i] + 'LinkObjFormatter'] = genericColumnObjLinkFormatter(formatters[i]);
|
window[formatters[i] + 'LinkObjFormatter'] = genericColumnObjLinkFormatter(formatters[i]);
|
||||||
window[formatters[i] + 'ActionsFormatter'] = genericActionsFormatter(formatters[i]);
|
window[formatters[i] + 'ActionsFormatter'] = genericActionsFormatter(formatters[i]);
|
||||||
window[formatters[i] + 'ImageFormatter'] = genericPublicImageFormatter(formatters[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -168,6 +161,13 @@ $('.snipe-table').bootstrapTable({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function imageFormatter(value, row) {
|
||||||
|
console.log(value);
|
||||||
|
if (value) {
|
||||||
|
return '<img src="' + value + '" height="50" width="50">';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
$('#bulkEdit').click(function () {
|
$('#bulkEdit').click(function () {
|
||||||
var selectedIds = $('.snipe-table').bootstrapTable('getSelections');
|
var selectedIds = $('.snipe-table').bootstrapTable('getSelections');
|
||||||
|
|
Loading…
Reference in a new issue