Class: Crm::EmployeeGoalPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- BasePresenter
- Crm::EmployeeGoalPresenter
- Defined in:
- app/presenters/crm/employee_goal_presenter.rb
Overview
Presenter: employee goal presenter.
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
-
#delete_link ⇒ ActiveSupport::SafeBuffer?
Link to delete the goal.
-
#department ⇒ String?
Department of the reviewed employee.
-
#display_name ⇒ ActiveSupport::SafeBuffer
Goal name with an info icon showing the description on hover.
-
#due_date ⇒ String?
Formatted due date for the goal.
-
#edit_link ⇒ ActiveSupport::SafeBuffer?
Link to edit/review the goal.
-
#employee ⇒ Party?
The goal's employee (party record).
-
#employee_goal_link ⇒ ActiveSupport::SafeBuffer, String
Link to the goal, or the plain name when not permitted.
-
#employee_goal_state_label(options = {}) ⇒ String
Renders a badge showing the employee goal's state.
-
#employee_link ⇒ ActiveSupport::SafeBuffer, ...
Link to the goal's employee, or the plain name when not permitted.
-
#employee_review_link ⇒ ActiveSupport::SafeBuffer?
Link to the parent employee review.
-
#reward_info ⇒ ActiveSupport::SafeBuffer
Earned vs.
Methods inherited from BasePresenter
Methods inherited from BasePresenter
#can?, #capture, #concat, #content_tag, #fa_icon, #h, #initialize, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u
Constructor Details
This class inherits a constructor from Crm::BasePresenter
Instance Method Details
#delete_link ⇒ ActiveSupport::SafeBuffer?
Link to delete the goal.
94 95 96 97 98 |
# File 'app/presenters/crm/employee_goal_presenter.rb', line 94 def delete_link return unless can?(:destroy, r) link_to(fa_icon('trash'), r, data: { turbo_method: :delete, turbo_confirm: "Are you sure want to delete this review?" }) end |
#department ⇒ String?
Department of the reviewed employee.
65 66 67 |
# File 'app/presenters/crm/employee_goal_presenter.rb', line 65 def department r.employee_review&.employee_record&.department end |
#display_name ⇒ ActiveSupport::SafeBuffer
Goal name with an info icon showing the description on hover.
102 103 104 |
# File 'app/presenters/crm/employee_goal_presenter.rb', line 102 def display_name fa_icon('info-circle', text: r.name, title: r.description) end |
#due_date ⇒ String?
Formatted due date for the goal.
50 51 52 |
# File 'app/presenters/crm/employee_goal_presenter.rb', line 50 def due_date h.render_date(r.due_date) end |
#edit_link ⇒ ActiveSupport::SafeBuffer?
Link to edit/review the goal.
9 10 11 12 13 14 15 |
# File 'app/presenters/crm/employee_goal_presenter.rb', line 9 def edit_link return unless can?(:update, r) link_to(fa_icon('pen-square', text: 'Edit/Review'), h.edit_employee_goal_path(r), class: "btn btn-#{r.defined? ? 'info' : 'default'}") end |
#employee ⇒ Party?
The goal's employee (party record).
71 72 73 |
# File 'app/presenters/crm/employee_goal_presenter.rb', line 71 def employee r.employee_review&.employee_record&.party end |
#employee_goal_link ⇒ ActiveSupport::SafeBuffer, String
Link to the goal, or the plain name when not permitted.
77 78 79 80 81 |
# File 'app/presenters/crm/employee_goal_presenter.rb', line 77 def employee_goal_link return r.name unless h.can?(:read, r) link_to r.name, h.employee_goal_path(r) end |
#employee_goal_state_label(options = {}) ⇒ String
Renders a badge showing the employee goal's state.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/presenters/crm/employee_goal_presenter.rb', line 23 def employee_goal_state_label( = {}) case r.state.to_sym when :reached css_class = 'bg-success' when :missed css_class = 'bg-danger' when :cancelled css_class = 'badge-default' end css_class ||= 'bg-info' [:style] ||= 'font-size: 1em' content_tag(:span, r.human_state_name.titleize, class: "badge #{css_class}", **) end |
#employee_link ⇒ ActiveSupport::SafeBuffer, ...
Link to the goal's employee, or the plain name when not permitted.
56 57 58 59 60 61 |
# File 'app/presenters/crm/employee_goal_presenter.rb', line 56 def employee_link return unless employee return employee.full_name unless h.can?(:read, employee) link_to employee.full_name, h.employee_path(employee) end |
#employee_review_link ⇒ ActiveSupport::SafeBuffer?
Link to the parent employee review.
85 86 87 88 89 90 |
# File 'app/presenters/crm/employee_goal_presenter.rb', line 85 def employee_review_link return unless r.employee_review return unless h.can?(:read, r.employee_review) link_to r.employee_review.review_name, h.employee_review_path(r.employee_review) end |
#reward_info ⇒ ActiveSupport::SafeBuffer
Earned vs. potential reward amounts.
40 41 42 43 44 45 46 |
# File 'app/presenters/crm/employee_goal_presenter.rb', line 40 def reward_info capture do concat number_to_currency(r.earned_reward || 0.0) concat " / " concat number_to_currency(r.potential_reward || 0.0) end end |