Skip to content

Commit

Permalink
feat: add help icons on various pages (#893)
Browse files Browse the repository at this point in the history
  • Loading branch information
djaiss committed May 21, 2021
1 parent 299f430 commit ffd18e4
Show file tree
Hide file tree
Showing 18 changed files with 262 additions and 156 deletions.
23 changes: 23 additions & 0 deletions app/Http/ViewHelpers/Company/CompanyViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Helpers\BirthdayHelper;
use App\Models\Company\Company;
use App\Models\Company\Employee;
use App\Models\Company\Question;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use App\Services\Company\GuessEmployeeGame\CreateGuessEmployeeGame;
Expand Down Expand Up @@ -54,6 +55,7 @@ public static function latestQuestions(Company $company): array
$latestQuestions = DB::table('questions')
->join('answers', 'questions.id', '=', 'answers.question_id')
->where('company_id', '=', $company->id)
->where('questions.active', false)
->groupBy('questions.id', 'questions.title')
->orderByDesc('questions.id')
->limit(3)
Expand All @@ -69,19 +71,40 @@ public static function latestQuestions(Company $company): array
'id' => $question->id,
'title' => $question->title,
'number_of_answers' => $question->count,
'active' => false,
'url' => route('company.questions.show', [
'company' => $company,
'question' => $question->id,
]),
];
});

// get the active question, if it exists
$activeQuestion = Question::where('company_id', $company->id)
->active()
->withCount('answers')
->first();

if ($activeQuestion) {
$activeQuestion = [
'id' => $activeQuestion->id,
'title' => $activeQuestion->title,
'number_of_answers' => (int) $activeQuestion->answers_count,
'active' => true,
'url' => route('company.questions.show', [
'company' => $company,
'question' => $activeQuestion->id,
]),
];
}

return [
'total_number_of_questions' => $questionsCount,
'all_questions_url' => route('company.questions.index', [
'company' => $company->id,
]),
'questions' => $questionCollection,
'active_question' => $activeQuestion ? $activeQuestion : null,
];
}

Expand Down
7 changes: 5 additions & 2 deletions config/officelife.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
'manager_expenses' => 'manage/employee-management.html#expenses',
'accoutant_expenses' => 'manage/employee-management.html#expenses',
'accountants' => 'manage/employee-management.html#expenses',
'worklogs' => 'communicate/worklogs.html#work-logs',
'employee_hiring_date' => 'manage/employee-management.html#hiring-date',
'employee_work_anniversaries' => 'manage/employee-management.html#work-anniversaries',
'employee_statuses' => 'manage/employee-management.html#employee-statuses',
Expand All @@ -188,7 +189,7 @@
'import_employees' => 'manage/employee-management.html#importing-employees',
'employee_morale' => 'manage/employee-management.html#employee-morale',
'team_morale' => 'manage/team-management.html#team-morale',
'manager_rate_manager' => 'manage/overview.html',
'manager_rate_manager' => 'grow/rate-your-manager.html',
'account_hardware_create' => 'introduction.html',
'team_recent_ship' => 'introduction.html',
'team_recent_ship_create' => 'introduction.html',
Expand All @@ -197,12 +198,14 @@
'account_general_logo' => 'manage/company-management.html#logo',
'account_general_founded_date' => 'manage/company-management.html#defining-the-company-s-founded-date',
'account_cancellation' => 'manage/company-management.html#account-cancellation',
'one_on_ones' => 'introduction.html',
'one_on_ones' => 'grow/one-on-ones.html#overview',
'project' => 'operate/project-management.html#overview',
'project_decisions' => 'operate/project-management.html#project-decisions',
'project_messages' => 'operate/project-management.html#project-messages',
'project_tasks' => 'operate/project-management.html#project-tasks',
'project_files' => 'operate/project-management.html#project-files',
'ecoffee' => 'grow/e-coffee.html#overview',
'questions' => 'communicate/get-to-know-your-colleagues.html',
'time_tracking' => 'operate/time-tracking.html',
],
];
2 changes: 1 addition & 1 deletion database/factories/Company/QuestionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function definition()
return [
'company_id' => Company::factory(),
'title' => $this->faker->sentence(),
'active' => true,
'active' => false,
];
}
}
4 changes: 4 additions & 0 deletions resources/js/Pages/Adminland/Question/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
<div class="pa3 mt5">
<h2 class="tc normal mb4">
{{ $t('account.questions_title', { company: $page.props.auth.company.name}) }}

<help :url="$page.props.help_links.questions" :top="'1px'" />
</h2>

<!-- add a question -->
Expand Down Expand Up @@ -212,13 +214,15 @@ import TextInput from '@/Shared/TextInput';
import Errors from '@/Shared/Errors';
import LoadingButton from '@/Shared/LoadingButton';
import Layout from '@/Shared/Layout';
import Help from '@/Shared/Help';
export default {
components: {
Layout,
TextInput,
Errors,
LoadingButton,
Help,
},
props: {
Expand Down
25 changes: 23 additions & 2 deletions resources/js/Pages/Company/Partials/Questions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
.answer-item:last-child {
margin-bottom: 0;
}
.past-questions {
background-color: #eef3f9;
}
</style>

<template>
Expand All @@ -10,15 +14,26 @@
<span class="mr1">
🎓
</span> {{ $t('employee.question_title') }}

<help :url="$page.props.help_links.questions" />
</span>

<div class="br3 bg-white box z-1">
<!-- list of questions -->
<ul v-if="questions.total_number_of_questions > 0" class="list pa3 ma0">
<!-- active question, if defined -->
<div v-if="questions.active_question" class="pa3 bb bb-gray">
<p class="f7 gray ma0">Active question</p>
<inertia-link :href="questions.active_question.url" class="dib ma0 mt2 fw6">{{ questions.active_question.title }}</inertia-link>
</div>


<!-- list of inactive questions -->
<ul v-if="questions.total_number_of_questions > 0" class="list pa3 ma0 past-questions">
<li v-for="question in questions.questions" :key="question.id" class="answer-item mb3" :data-cy="'question-title-' + question.id">
<inertia-link :href="question.url" class="fw5 f5 lh-copy mb2">{{ question.title }}</inertia-link> <span class="gray f7">({{ question.number_of_answers }})</span>
</li>
</ul>

<!-- Link to view all questions -->
<div v-if="questions.total_number_of_questions > 0" class="ph3 pv2 tc f6 bt bb-gray">
<inertia-link :href="questions.all_questions_url">{{ $t('company.questions_view_all', { count: questions.total_number_of_questions }) }}</inertia-link>
</div>
Expand All @@ -30,7 +45,13 @@
</template>

<script>
import Help from '@/Shared/Help';
export default {
components: {
Help,
},
props: {
questions: {
type: Object,
Expand Down
4 changes: 4 additions & 0 deletions resources/js/Pages/Company/Question/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
<div class="pa3 mt3">
<h2 class="tc normal mb4">
{{ $t('company.questions_title') }}

<help :url="$page.props.help_links.questions" :top="'1px'" />
</h2>

<!-- LIST OF QUESTIONS -->
Expand Down Expand Up @@ -57,10 +59,12 @@

<script>
import Layout from '@/Shared/Layout';
import Help from '@/Shared/Help';
export default {
components: {
Layout,
Help,
},
props: {
Expand Down
7 changes: 0 additions & 7 deletions resources/js/Pages/Dashboard/Me/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
:question="question"
/>

<task
:employee="employee"
:tasks="tasks"
/>

<expense
:employee="employee"
:categories="categories"
Expand All @@ -76,7 +71,6 @@ import Worklogs from '@/Pages/Dashboard/Me/Partials/Worklogs';
import Morale from '@/Pages/Dashboard/Me/Partials/Morale';
import WorkFromHome from '@/Pages/Dashboard/Me/Partials/WorkFromHome';
import Question from '@/Pages/Dashboard/Me/Partials/Question';
import Task from '@/Pages/Dashboard/Me/Partials/Task';
import Expense from '@/Pages/Dashboard/Me/Partials/Expense';
import RateYourManager from '@/Pages/Dashboard/Me/Partials/RateYourManager';
import OneOnOneWithManager from '@/Pages/Dashboard/Me/Partials/OneOnOneWithManager';
Expand All @@ -92,7 +86,6 @@ export default {
Worklogs,
Morale,
Question,
Task,
Expense,
WorkFromHome,
RateYourManager,
Expand Down
6 changes: 5 additions & 1 deletion resources/js/Pages/Dashboard/Me/Partials/Question.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@

<template>
<div :class="question ? 'mb5' : ''">
<template v-if="question">
<template v-if="localQuestion">
<div class="cf mw7 center mb2 fw5">
<span class="mr1">
🎓
</span> {{ $t('dashboard.question_title') }}

<help :url="$page.props.help_links.questions" />
</div>

<!-- employee hasnt already answered -->
Expand Down Expand Up @@ -146,13 +148,15 @@ import Errors from '@/Shared/Errors';
import LoadingButton from '@/Shared/LoadingButton';
import TextArea from '@/Shared/TextArea';
import SmallNameAndAvatar from '@/Shared/SmallNameAndAvatar';
import Help from '@/Shared/Help';
export default {
components: {
Errors,
LoadingButton,
TextArea,
SmallNameAndAvatar,
Help,
},
props: {
Expand Down
4 changes: 4 additions & 0 deletions resources/js/Pages/Dashboard/Me/Partials/Worklogs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<span class="mr1">
🔨
</span> {{ $t('dashboard.worklog_title') }}

<help :url="$page.props.help_links.worklogs" />
</div>

<div class="cf mw7 center br3 mb3 bg-white box pa3">
Expand Down Expand Up @@ -65,12 +67,14 @@
import LoadingButton from '@/Shared/LoadingButton';
import TextArea from '@/Shared/TextArea';
import Errors from '@/Shared/Errors';
import Help from '@/Shared/Help';
export default {
components: {
LoadingButton,
Errors,
TextArea,
Help,
},
props: {
Expand Down
6 changes: 5 additions & 1 deletion resources/js/Pages/Dashboard/Team/Partials/Worklogs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
<div class="mb5">
<div class="cf mw7 center mb2 fw5">
🔨 {{ $t('dashboard.team_worklog_title') }}

<help :url="$page.props.help_links.worklogs" />
</div>

<div v-show="teams.length != 0" class="cf mw7 center br3 mb3 bg-white box">
Expand Down Expand Up @@ -113,10 +115,12 @@

<script>
import SmallNameAndAvatar from '@/Shared/SmallNameAndAvatar';
import Help from '@/Shared/Help';
export default {
components: {
SmallNameAndAvatar
SmallNameAndAvatar,
Help,
},
props: {
Expand Down

0 comments on commit ffd18e4

Please sign in to comment.