mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
More improvements (#3116)
* Restore display of deleted items in the logs * Fix functional tests.
This commit is contained in:
parent
8a782bf34a
commit
3a6bbcc615
|
@ -119,7 +119,7 @@ class Actionlog extends SnipeModel
|
|||
|
||||
public function target()
|
||||
{
|
||||
return $this->morphTo('target');
|
||||
return $this->morphTo('target')->withTrashed();
|
||||
}
|
||||
|
||||
public function childlogs()
|
||||
|
|
|
@ -19,7 +19,7 @@ class ActionlogPresenter extends Presenter
|
|||
'icon' => '<i class="'.$this->parseItemIcon().'"></i>',
|
||||
'created_at' => date("M d, Y g:iA", strtotime($this->created_at)),
|
||||
'action_type' => strtolower(trans('general.'.str_replace(' ', '_', $this->action_type))),
|
||||
'admin' => $this->model->user ? $this->model->user->present()->nameUrl() : '',
|
||||
'admin' => $this->admin(),
|
||||
'target' => $this->target(),
|
||||
'item' => $this->item(),
|
||||
'item_type' => $this->itemType(),
|
||||
|
@ -30,6 +30,15 @@ class ActionlogPresenter extends Presenter
|
|||
|
||||
public function admin()
|
||||
{
|
||||
if ($user = $this->model->user) {
|
||||
if(empty($user->deleted_at)) {
|
||||
return $user->present()->nameUrl();
|
||||
}
|
||||
// The user was deleted
|
||||
return '<del>'.$user->present()->name()."</del> (deleted)";
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function item()
|
||||
|
@ -38,32 +47,42 @@ class ActionlogPresenter extends Presenter
|
|||
if($this->action_type=='uploaded') {
|
||||
return (string) link_to_route('show/userfile', $this->model->filename, [$this->model->item->id, $this->model->id]);
|
||||
}
|
||||
if ($this->model->item) {
|
||||
return $this->model->item->present()->nameUrl();
|
||||
if ($item = $this->model->item) {
|
||||
if (empty($item->deleted_at)) {
|
||||
return $this->model->item->present()->nameUrl();
|
||||
}
|
||||
// The item was deleted
|
||||
return '<del>'.$item->present()->name().'</del> (deleted)';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
public function target()
|
||||
{
|
||||
$target = null;
|
||||
// Target is messy.
|
||||
// On an upload, the target is the item we are uploading to, stored as the "item" in the log.
|
||||
if ($this->action_type=='uploaded') {
|
||||
return $this->model->item->present()->nameUrl();
|
||||
}
|
||||
$target = $this->model->item;
|
||||
} elseif (($this->action_type=='accepted') || ($this->action_type=='declined')) {
|
||||
// If we are logging an accept/reject, the target is not stored directly,
|
||||
// so we access it through who the item is assigned to.
|
||||
// FIXME: On a reject it's not assigned to anyone.
|
||||
if (($this->action_type=='accepted') || ($this->action_type=='declined')) {
|
||||
return $this->model->item->assignedTo->nameUrl();
|
||||
$target = $this->model->item->assignedTo;
|
||||
} elseif ($this->action_type=='requested') {
|
||||
if ($this->model->user) {
|
||||
return $this->model->user->present()->nameUrl();
|
||||
$target = $this->model->user;
|
||||
}
|
||||
} elseif ($this->model->target) {
|
||||
// Otherwise, we'll just take the target of the log.
|
||||
$target = $this->model->target;
|
||||
}
|
||||
// Otherwise, we'll just take the target of the log.
|
||||
if ($this->model->target) {
|
||||
return $this->model->target->present()->nameUrl();
|
||||
|
||||
if($target) {
|
||||
if (empty($target->deleted_at)) {
|
||||
return $target->present()->nameUrl();
|
||||
}
|
||||
return '<del>'.$target->present()->name().'</del>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -58,9 +58,15 @@ class ConsumablePresenter extends Presenter
|
|||
}
|
||||
|
||||
/**
|
||||
* Link to this consumables name
|
||||
* Displayable name of consumable
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function name()
|
||||
{
|
||||
return $this->model->name;
|
||||
}
|
||||
|
||||
public function nameUrl()
|
||||
{
|
||||
return (string)link_to_route('consumables.show', $this->name, $this->id);
|
||||
|
|
|
@ -30,7 +30,6 @@ $factory->defineAs(App\Models\Asset::class, 'asset', function (Faker\Generator $
|
|||
'purchase_cost' => $faker->randomFloat(2),
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'supplier_id' => $faker->numberBetween(1, 5),
|
||||
'requestable' => $faker->numberBetween(0, 1),
|
||||
'company_id' => Company::inRandomOrder()->first()->id,
|
||||
'requestable' => $faker->boolean()
|
||||
];
|
||||
|
|
|
@ -34,12 +34,13 @@ class AssetsCest
|
|||
public function passesCreateAndCheckout(FunctionalTester $I)
|
||||
{
|
||||
$asset = factory(App\Models\Asset::class,'asset')->make();
|
||||
$userId = $I->getUserId();
|
||||
$values = [
|
||||
'company_id' => $asset->company_id,
|
||||
'asset_tag' => $asset->asset_tag,
|
||||
'model_id' => $asset->model_id,
|
||||
'status_id' => $asset->status_id,
|
||||
'assigned_user' => $I->getUserId(),
|
||||
'assigned_user' => $userId,
|
||||
'serial' => $asset->serial,
|
||||
'name' => $asset->name,
|
||||
'purchase_date' => '2016-01-01',
|
||||
|
@ -57,7 +58,7 @@ class AssetsCest
|
|||
'asset_tag' => $asset->asset_tag,
|
||||
'model_id' => $asset->model_id,
|
||||
'status_id' => $asset->status_id,
|
||||
'assigned_to' => $I->getUserId(),
|
||||
'assigned_to' => $userId,
|
||||
'assigned_type' => 'App\\Models\\User',
|
||||
'serial' => $asset->serial,
|
||||
'name' => $asset->name,
|
||||
|
|
Loading…
Reference in a new issue