Skip to content

Commit

Permalink
feat: make the avatar of the employee clickable on dashboard (#836)
Browse files Browse the repository at this point in the history
  • Loading branch information
djaiss committed May 1, 2021
1 parent 69ffb00 commit 7b92f2e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/Http/ViewHelpers/Dashboard/DashboardViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public static function information(Employee $employee, string $currentTab): ?arr
'can_manage_expenses' => $employee->can_manage_expenses,
'is_manager' => $employee->directReports->count() > 0,
'can_manage_hr' => $employee->permission_level <= config('officelife.permission_level.hr'),
'url' => route('employees.show', [
'company' => $employee->company,
'employee' => $employee,
]),
];
}
}
1 change: 1 addition & 0 deletions database/factories/Company/EmployeeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function definition()
'company_id' => $company->id,
]),
'amount_of_allowed_holidays' => 30,
'can_manage_expenses' => false,
];
}

Expand Down
2 changes: 1 addition & 1 deletion resources/js/Pages/Dashboard/Partials/DashboardMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="cf mw7 center br3 mt5 mb5">
<!-- employee information -->
<div class="flex items-center mb5">
<avatar :avatar="employee.avatar" :size="55" :class="'pointer avatar br-100 mr4'" />
<avatar :avatar="employee.avatar" :size="55" :url="employee.url" :class="'pointer avatar br-100 mr4'" />

<div>
<h2 class="fw3 mt0 mb2">
Expand Down
35 changes: 35 additions & 0 deletions tests/Unit/ViewHelpers/Dashboard/DashboardViewHelperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Tests\Unit\ViewHelpers\Dashboard;

use Carbon\Carbon;
use Tests\TestCase;
use App\Helpers\ImageHelper;
use App\Http\ViewHelpers\Dashboard\DashboardViewHelper;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class DashboardViewHelperTest extends TestCase
{
use DatabaseTransactions;

/** @test */
public function it_gets_information_about_the_employee(): void
{
Carbon::setTestNow(Carbon::create(2018, 1, 1));
$michael = $this->createAdministrator();

$this->assertEquals(
[
'id' => $michael->id,
'name' => $michael->name,
'avatar' => ImageHelper::getAvatar($michael, 55),
'dashboard_view' => 'info',
'can_manage_expenses' => false,
'is_manager' => false,
'can_manage_hr' => true,
'url' => env('APP_URL') . '/' . $michael->company_id . '/employees/' . $michael->id,
],
DashboardViewHelper::information($michael, 'info')
);
}
}

0 comments on commit 7b92f2e

Please sign in to comment.