Skip to content
This repository has been archived by the owner on Oct 10, 2018. It is now read-only.

Commit

Permalink
Update implementation of ItemHistoryWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
erik-epineer committed Oct 3, 2018
1 parent 3585a67 commit 45b06fc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion resources/views/widgets/itemHistory.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ul>
@foreach($entries as $entry)
<li lang="en" data-kontour-entry-action="{{ $entry['action'] }}"@if($entry['user']) data-kontour-username="{{ $entry['user']->getDisplayName() }}"@endif>
<span>{{ $entry['action'] }}</span>
<span>{{ ucfirst($entry['action']) }}</span>
<time datetime="{{ $entry['datetime']->toDateTimeString() }}">{{ $entry['datetime']->diffForHumans() }}</time>
@if($entry['user'])
<span>by</span> <span>{{ $entry['user']->getDisplayName() }}</span>
Expand Down
8 changes: 4 additions & 4 deletions src/Widgets/ItemHistoryWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public function addEntry(string $action, \DateTime $datetime, AdminUser $user =
return $this;
}

public function addCreateEntry(\DateTime $datetime, AdminUser $user = null): ItemHistoryWidgetContract
public function addCreatedEntry(\DateTime $datetime, AdminUser $user = null): ItemHistoryWidgetContract
{
return $this->addEntry('create', $datetime, $user);
return $this->addEntry('created', $datetime, $user);
}

public function addUpdateEntry(\DateTime $datetime, AdminUser $user = null): ItemHistoryWidgetContract
public function addUpdatedEntry(\DateTime $datetime, AdminUser $user = null): ItemHistoryWidgetContract
{
return $this->addEntry('update', $datetime, $user);
return $this->addEntry('updated', $datetime, $user);
}

public function isAuthorized(Authorizable $user = null): bool
Expand Down
3 changes: 2 additions & 1 deletion tests/Feature/Fakes/UserlandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public function edit($id)
{
$widget = app(ItemHistoryWidget::class);
$this->registerAdminWidget($widget);
$widget->addCreateEntry(new \DateTime(), Auth::guard(config('kontour.guard'))->user());
$widget->addCreatedEntry(new \DateTime(), Auth::guard(config('kontour.guard'))->user());
$widget->addUpdatedEntry(new \DateTime(), Auth::guard(config('kontour.guard'))->user());

return view('userland::index');
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Feature/UserlandControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function test_item_history_widget()
{
$response = $this->actingAs($this->user)->get(route('userland.edit', 1));
$response->assertSee('<section data-kontour-widget="itemHistory">');
$response->assertSee('<li lang="en" data-kontour-entry-action="create" data-kontour-username="'.$this->user->getDisplayName() .'">');
$response->assertSee('<li lang="en" data-kontour-entry-action="created" data-kontour-username="'.$this->user->getDisplayName() .'">');
$response->assertSee('<li lang="en" data-kontour-entry-action="updated" data-kontour-username="'.$this->user->getDisplayName() .'">');
}
}

0 comments on commit 45b06fc

Please sign in to comment.