mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Use real status label names, even if deployed
This commit is contained in:
parent
f4623bd277
commit
6bfd428c2e
|
@ -34,7 +34,8 @@ class AssetsTransformer
|
|||
'eol' => ($asset->purchase_date!='') ? Helper::getFormattedDateObject($asset->present()->eol_date(), 'date') : null ,
|
||||
'status_label' => ($asset->assetstatus) ? [
|
||||
'id' => (int) $asset->assetstatus->id,
|
||||
'name'=> e($asset->present()->statusText),
|
||||
'name'=> e($asset->assetstatus->name),
|
||||
'status_type'=> e($asset->assetstatus->getStatuslabelType()),
|
||||
'status_meta' => e($asset->present()->statusMeta),
|
||||
] : null,
|
||||
'category' => ($asset->model->category) ? [
|
||||
|
|
|
@ -417,6 +417,47 @@ class AssetPresenter extends Presenter
|
|||
return $this->model->assetstatus->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* This handles the status label "meta" status of "deployed" if
|
||||
* it's assigned. Results look like:
|
||||
*
|
||||
* (if assigned and the status label is "Ready to Deploy"):
|
||||
* (Deployed)
|
||||
*
|
||||
* (f assigned and status label is not "Ready to Deploy":)
|
||||
* Deployed (Another Status Label)
|
||||
*
|
||||
* (if not deployed:)
|
||||
* Another Status Label
|
||||
*/
|
||||
public function fullStatusText() {
|
||||
// Make sure the status is valid
|
||||
if ($this->assetstatus) {
|
||||
|
||||
// If the status is assigned to someone or something...
|
||||
if ($this->model->assigned) {
|
||||
|
||||
// If it's assigned and not set to the default "ready to deploy" status
|
||||
if ($this->assetstatus->name != trans('general.ready_to_deploy')) {
|
||||
return trans('general.deployed'). ' (' . $this->model->assetstatus->name.')';
|
||||
}
|
||||
|
||||
// If it's assigned to the default "ready to deploy" status, just
|
||||
// say it's deployed - otherwise it's confusing to have a status that is
|
||||
// both "ready to deploy" and deployed at the same time.
|
||||
return trans('general.deployed');
|
||||
}
|
||||
|
||||
// Return just the status name
|
||||
return $this->model->assetstatus->name;
|
||||
}
|
||||
|
||||
// This status doesn't seem valid - either data has been manually edited or
|
||||
// the status label was deleted.
|
||||
return 'Invalid status';
|
||||
}
|
||||
|
||||
/**
|
||||
* Date the warantee expires.
|
||||
* @return false|string
|
||||
|
|
|
@ -90,7 +90,12 @@
|
|||
<td>
|
||||
|
||||
@if (($asset->assignedTo) && ($asset->deleted_at==''))
|
||||
<i class="fa fa-circle text-blue"></i> {{ trans('general.deployed') }} <i class="fa fa-long-arrow-right" aria-hidden="true"></i> {!! $asset->assignedTo->present()->glyph() !!}
|
||||
<i class="fa fa-circle text-blue"></i>
|
||||
{{ $asset->assetstatus->name }}
|
||||
<label class="label label-default">{{ trans('general.deployed') }}</label>
|
||||
|
||||
<i class="fa fa-long-arrow-right" aria-hidden="true"></i>
|
||||
{!! $asset->assignedTo->present()->glyph() !!}
|
||||
{!! $asset->assignedTo->present()->nameUrl() !!}
|
||||
@else
|
||||
@if (($asset->assetstatus) && ($asset->assetstatus->deployable=='1'))
|
||||
|
@ -555,13 +560,13 @@
|
|||
<!-- checked out assets table -->
|
||||
<div class="table-responsive">
|
||||
<table
|
||||
name="assetAssets"
|
||||
name="assetAssetsTable"
|
||||
data-toolbar="#toolbar"
|
||||
class="table table-striped snipe-table"
|
||||
id="assetAssets"
|
||||
id="assetAssetsTable"
|
||||
data-search="false"
|
||||
data-url="{{route('api.assets.index',['assigned_to' => $asset->id, 'assigned_type' => 'App\Models\Asset']) }}"
|
||||
data-export-options='{"fileName": "asset-assets"}'
|
||||
data-show-export="true"
|
||||
data-cookie="true"
|
||||
data-show-footer="true"
|
||||
data-cookie-id-table="assetAssetsTable"
|
||||
|
|
|
@ -79,7 +79,6 @@
|
|||
@endif
|
||||
refresh: 'fa-refresh'
|
||||
},
|
||||
showExport: true,
|
||||
exportDataType: 'all',
|
||||
exportTypes: ['csv', 'excel', 'doc', 'txt','json', 'xml', 'pdf'],
|
||||
exportOptions: {
|
||||
|
@ -173,26 +172,31 @@
|
|||
|
||||
var text_color;
|
||||
var icon_style;
|
||||
var text_help;
|
||||
|
||||
switch (value.status_meta) {
|
||||
case 'deployed':
|
||||
case '{{ strtolower(trans('general.deployed')) }}':
|
||||
text_color = 'blue';
|
||||
icon_style = 'fa-circle';
|
||||
text_help = '<label class="label label-default">{{ trans('general.deployed') }}</label>';
|
||||
break;
|
||||
case 'deployable':
|
||||
case '{{ strtolower(trans('admin/hardware/general.deployable')) }}':
|
||||
text_color = 'green';
|
||||
icon_style = 'fa-circle';
|
||||
text_help = '';
|
||||
break;
|
||||
case 'pending':
|
||||
case '{{ strtolower(trans('general.pending')) }}':
|
||||
text_color = 'orange';
|
||||
icon_style = 'fa-circle';
|
||||
text_help = '';
|
||||
break;
|
||||
default:
|
||||
text_color = 'red';
|
||||
icon_style = 'fa-times';
|
||||
text_help = '';
|
||||
}
|
||||
|
||||
return '<nobr><a href="{{ url('/') }}/' + destination + '/' + value.id + '" data-tooltip="true" title="'+ value.status_meta + '"> <i class="fa ' + icon_style + ' text-' + text_color + '"></i> ' + value.name + '</a></nobr>';
|
||||
return '<nobr><a href="{{ url('/') }}/' + destination + '/' + value.id + '" data-tooltip="true" title="'+ value.status_meta + '"> <i class="fa ' + icon_style + ' text-' + text_color + '"></i> ' + value.name + ' ' + text_help + ' </a> </nobr>';
|
||||
} else if ((value) && (value.name)) {
|
||||
return '<nobr><a href="{{ url('/') }}/' + destination + '/' + value.id + '"> ' + value.name + '</a></span>';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue