Hopefully clearer status label meta info

This commit is contained in:
snipe 2017-09-29 12:03:02 -07:00
parent b9e79c27a8
commit fe1975067a
4 changed files with 25 additions and 6 deletions

View file

@ -34,7 +34,7 @@ class AssetsTransformer
'status_label' => ($asset->assetstatus) ? [ 'status_label' => ($asset->assetstatus) ? [
'id' => (int) $asset->assetstatus->id, 'id' => (int) $asset->assetstatus->id,
'name'=> e($asset->assetstatus->name), 'name'=> e($asset->assetstatus->name),
'status_type' => e($asset->assetstatus->getStatuslabelType()), 'status_meta' => e($asset->present()->statusMeta),
] : null, ] : null,
'category' => ($asset->model->category) ? [ 'category' => ($asset->model->category) ? [
'id' => (int) $asset->model->category->id, 'id' => (int) $asset->model->category->id,

View file

@ -325,13 +325,32 @@ class AssetPresenter extends Presenter
return $interval; return $interval;
} }
/**
* @return string
* This handles the status label "meta" status of "deployed" if
* it's assigned. Should maybe deprecate.
*/
public function statusMeta()
{
if ($this->model->assignedTo) {
return strtolower(trans('general.deployed'));
}
return $this->model->assetstatus->getStatuslabelType();
}
/**
* @return string
* This handles the status label "meta" status of "deployed" if
* it's assigned. Should maybe deprecate.
*/
public function statusText() public function statusText()
{ {
if ($this->model->assignedTo) { if ($this->model->assignedTo) {
return trans('general.deployed'); return strtolower(trans('general.deployed'));
} }
return $this->model->assetstatus->name; return $this->model->assetstatus->name;
} }
/** /**
* Date the warantee expires. * Date the warantee expires.
* @return false|string * @return false|string

View file

@ -87,8 +87,8 @@
&nbsp; &nbsp;</span> &nbsp; &nbsp;</span>
</span> </span>
@endif @endif
<a href="{{ route('statuslabels.show', $asset->assetstatus->id) }}">{{ $asset->present()->statusText() }}</a> <a href="{{ route('statuslabels.show', $asset->assetstatus->id) }}">{{ $asset->assetstatus->name }}</a>
<label class="label label-default">{{ $asset->assetstatus->getStatuslabelType() }}</label> <label class="label label-default">{{ $asset->present()->statusMeta }}</label>
</td> </td>
</tr> </tr>
@endif @endif

View file

@ -139,8 +139,8 @@ $('.snipe-table').bootstrapTable({
// Use this when we're introspecting into a column object and need to link // Use this when we're introspecting into a column object and need to link
function genericColumnObjLinkFormatter(destination) { function genericColumnObjLinkFormatter(destination) {
return function (value,row) { return function (value,row) {
if ((value) && (value.status_type)) { if ((value) && (value.status_meta)) {
return '<a href="{{ url('/') }}/' + destination + '/' + value.id + '"> ' + value.name + '</a> ' + '<label class="label label-default">'+ value.status_type + '</label>'; return '<label class="label label-default">'+ value.status_meta + '</label> <a href="{{ url('/') }}/' + destination + '/' + value.id + '"> ' + value.name + '</a> ';
} else if ((value) && (value.name)) { } else if ((value) && (value.name)) {
return '<a href="{{ url('/') }}/' + destination + '/' + value.id + '"> ' + value.name + '</a>'; return '<a href="{{ url('/') }}/' + destination + '/' + value.id + '"> ' + value.name + '</a>';
} }