Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: display job openings on company tab #1376

Merged
merged 2 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function index(): Response
$positions = CompanyHRViewHelper::positions($company);
$ama = CompanyHRViewHelper::askMeAnythingUpcomingSession($company);
$statistics = CompanyViewHelper::information($company);
$jobOpenings = CompanyHRViewHelper::openedJobOpenings($company);

return Inertia::render('Company/HR/Index', [
'tab' => 'hr',
Expand All @@ -36,6 +37,7 @@ public function index(): Response
'genders' => $genders,
'positions' => $positions,
'askMeAnythingSession' => $ama,
'jobOpenings' => $jobOpenings,
'notifications' => NotificationHelper::getNotifications($employee),
]);
}
Expand Down
54 changes: 54 additions & 0 deletions app/Http/ViewHelpers/Company/HR/CompanyHRViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Models\Company\ECoffee;
use App\Models\Company\Employee;
use App\Models\Company\Position;
use App\Models\Company\JobOpening;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use App\Models\Company\AskMeAnythingSession;
Expand Down Expand Up @@ -215,4 +216,57 @@ public static function askMeAnythingUpcomingSession(Company $company): array
]),
];
}

/**
* Get the information about open job openings.
*
* @param Company $company
* @return array
*/
public static function openedJobOpenings(Company $company): array
{
$openings = JobOpening::where('company_id', $company->id)
->where('active', true)
->where('fulfilled', false)
->with('candidates')
->orderBy('created_at', 'desc')
->take(3)
->get();

$numberOfJobOpeningsTotal = JobOpening::where('company_id', $company->id)
->where('active', true)
->where('fulfilled', false)
->count();

$openingsCollection = collect([]);
foreach ($openings as $opening) {
$team = $opening->team;

$openingsCollection->push([
'id' => $opening->id,
'title' => $opening->title,
'reference_number' => $opening->reference_number,
'team' => $team ? [
'id' => $team->id,
'name' => $team->name,
'url' => route('team.show', [
'company' => $company,
'team' => $team,
]),
] : null,
'url' => route('jobs.company.show.incognito', [
'company' => $company->slug,
'job' => $opening->slug,
]),
]);
}

return [
'jobOpenings' => $openingsCollection,
'count' => $numberOfJobOpeningsTotal,
'url_view_all' => route('jobs.company.index', [
'company' => $company->slug,
]),
];
}
}
9 changes: 8 additions & 1 deletion resources/js/Pages/Company/HR/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
color: #fff;
padding: 5px;
}

</style>

<template>
Expand Down Expand Up @@ -49,6 +48,8 @@
<div class="fl w-50-l w-100 pl4-l">
<ask-me-anything-session :data="askMeAnythingSession" />

<job-openings v-if="jobOpenings.count > 0" :data="jobOpenings" />

<genders
:genders="genders"
/>
Expand All @@ -64,6 +65,7 @@ import eCoffees from '@/Pages/Company/HR/Partials/eCoffees';
import Genders from '@/Pages/Company/HR/Partials/Genders';
import Positions from '@/Pages/Company/HR/Partials/Positions';
import AskMeAnythingSession from '@/Pages/Company/HR/Partials/AskMeAnythingSession';
import JobOpenings from '@/Pages/Company/HR/Partials/JobOpenings';
import Tab from '@/Pages/Company/Partials/Tab';
import HeaderComponent from '@/Pages/Company/Partials/Header';

Expand All @@ -72,6 +74,7 @@ export default {
Layout,
eCoffees,
Genders,
JobOpenings,
Positions,
Tab,
HeaderComponent,
Expand Down Expand Up @@ -103,6 +106,10 @@ export default {
type: Object,
default: null,
},
jobOpenings: {
type: Object,
default: null,
},
notifications: {
type: Array,
default: null,
Expand Down
72 changes: 72 additions & 0 deletions resources/js/Pages/Company/HR/Partials/JobOpenings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<style lang="scss" scoped>
.opening-item {
&:first-child:hover {
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}

&:last-child {
border-bottom: 0;

&:hover {
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
}
}

.icon-view {
border-bottom: 0;

svg {
width: 15px;
}

&:hover {
border-bottom: 0;
}
}
</style>

<template>
<div class="mb4">
<span class="db fw5 mb2 relative">
<span class="mr1">
🥇
</span> {{ $t('company.hr_job_openings_title') }}
</span>

<div class="br3 bg-white box z-1 relative">
<div v-for="jobOpening in data.jobOpenings" :key="jobOpening.id" class="pa3 flex justify-between items-center bb bb-gray bb-gray-hover opening-item">
<div>
<p class="fw4 mt0 mb1">
{{ jobOpening.title }}
</p>
<p v-if="jobOpening.team" class="ma0 f7 gray"><inertia-link :href="jobOpening.team.url">{{ jobOpening.team.name }}</inertia-link></p>
</div>

<inertia-link :href="jobOpening.url" class="icon-view no-underline">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
</svg>
</inertia-link>
</div>

<div class="ph3 pv2 tc f6">
<inertia-link :href="data.url_view_all">{{ $t('company.hr_job_openings_view_all', {count: data.count}) }}</inertia-link>
</div>
</div>
</div>
</template>

<script>

export default {
props: {
data: {
type: Object,
default: null,
},
},
};
</script>
2 changes: 1 addition & 1 deletion resources/js/Pages/Recruiting/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<span v-if="jobOpening.reference_number" class="reference-number f7 code fw4">{{ jobOpening.reference_number }}</span>
</div>

<p v-if="jobOpening.team" class="ma0 f7 gray">For <inertia-link :href="jobOpening.team.url">{{ jobOpening.team.name }}</inertia-link></p>
<p v-if="jobOpening.team" class="ma0 f7 gray"><inertia-link :href="jobOpening.team.url">{{ jobOpening.team.name }}</inertia-link></p>
</div>
</li>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions resources/js/Shared/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ nav {
<inertia-link :href="'/' + $page.props.auth.company.id + '/company'" class="mr2 no-underline pa2 bb-0 special" data-cy="header-teams-link">
<span class="mr1">⛺️</span> {{ $t('app.header_company') }}
</inertia-link>
<!-- <inertia-link :href="'/' + $page.props.auth.company.id + '/recruiting/job-openings'" class="mr2 no-underline pa2 bb-0 special">
<inertia-link v-if="$page.props.auth.employee.permission_level < 300" :href="'/' + $page.props.auth.company.id + '/recruiting/job-openings'" class="mr2 no-underline pa2 bb-0 special">
<span class="mr1">🥇</span> {{ $t('app.header_recruiting') }}
</inertia-link> -->
</inertia-link>
<a data-cy="header-find-link" class="mr2 no-underline pa2 bb-0 special pointer" @click="showFindModal">
<span class="mr1">🔍</span> {{ $t('app.header_find') }}
</a>
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/en/company.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,6 @@
'hr_ama_delete_title' => 'Delete the session',
'hr_ama_delete_description' => 'Would you like to delete this session? If you proceed, all questions will also be deleted permanently.',
'hr_ama_delete_success' => 'The session has been deleted.',
'hr_job_openings_title' => 'Open job positions',
'hr_job_openings_view_all' => 'View all open job positions ({count})',
];