Class: Crm::EmployeeReviewPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- BasePresenter
- Crm::EmployeeReviewPresenter
- Defined in:
- app/presenters/crm/employee_review_presenter.rb
Overview
Presenter: employee review 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 review, redirecting back to the employee's reviews tab.
-
#dynamic_status_drop_down ⇒ ActiveSupport::SafeBuffer
Status dropdown for the review.
-
#edit_review_link ⇒ ActiveSupport::SafeBuffer?
Link to review/edit the employee review.
-
#employee_review_state_label ⇒ ActiveSupport::SafeBuffer
Badge showing the review's workflow state.
-
#goals_unfinished_alert ⇒ ActiveSupport::SafeBuffer?
Warning alert listing goals that block review completion.
-
#new_goal_link ⇒ ActiveSupport::SafeBuffer?
Link to define a new goal while the review is in progress.
-
#next_step_alert ⇒ ActiveSupport::SafeBuffer?
Info alert with the next available workflow action.
-
#render_employee_goals ⇒ String?
Renders the employee goals partial for quarterly reviews.
-
#render_reward_allocations ⇒ String?
Renders the reward allocations partial once the review reaches reward stages.
-
#setup_employee_review_for_reward_allocations ⇒ EmployeeReview
Builds reward allocations up to three rows for the form.
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 review, redirecting back to the employee's reviews tab.
94 95 96 97 98 |
# File 'app/presenters/crm/employee_review_presenter.rb', line 94 def delete_link return unless h.can?(:destroy, r) h.delete_link r, destroy: { success_url: h.employee_path(r.employee_record.party, tab: "reviews") } end |
#dynamic_status_drop_down ⇒ ActiveSupport::SafeBuffer
Status dropdown for the review.
35 36 37 |
# File 'app/presenters/crm/employee_review_presenter.rb', line 35 def dynamic_status_drop_down h.dynamic_status_drop_down r end |
#edit_review_link ⇒ ActiveSupport::SafeBuffer?
Link to review/edit the employee review.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/presenters/crm/employee_review_presenter.rb', line 77 def edit_review_link return unless h.can?(:update, r) if employee_review.in_progress? css_class = "btn btn-outline-success" label = 'Review' else css_class = "btn btn-outline-primary" label = 'Edit' end link_to(fa_icon('pen-square', text: label), h.edit_employee_review_path(employee_review), class: css_class) end |
#employee_review_state_label ⇒ ActiveSupport::SafeBuffer
Badge showing the review's workflow state.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/presenters/crm/employee_review_presenter.rb', line 9 def employee_review_state_label css_class_state = { in_progress: 'info', process_reward: 'success', allocate_reward: 'success', complete: 'primary', cancelled: 'secondary' }[employee_review.state&.to_sym] css_class = "badge bg-#{css_class_state}" content_tag(:span, employee_review.human_state_name, class: css_class) end |
#goals_unfinished_alert ⇒ ActiveSupport::SafeBuffer?
Warning alert listing goals that block review completion.
41 42 43 44 45 46 47 48 49 |
# File 'app/presenters/crm/employee_review_presenter.rb', line 41 def goals_unfinished_alert return unless r.in_progress? && !r.all_goals_finalized? return if r.employee_goals.unfinalized.blank? content_tag(:div, class: 'alert alert-warning') do concat content_tag(:h4, 'Before the review can be completed:') concat content_tag(:p, "Goal(s): #{r.employee_goals.unfinalized.pluck(:name).to_sentence} must be marked complete, not reached or cancelled") end end |
#new_goal_link ⇒ ActiveSupport::SafeBuffer?
Link to define a new goal while the review is in progress.
24 25 26 27 28 29 30 31 |
# File 'app/presenters/crm/employee_review_presenter.rb', line 24 def new_goal_link return unless employee_review.in_progress? && can?(:update, employee_review) css_class = 'btn btn-outline-primary' link_to(fa_icon('plus-circle', text: 'Define a new goal'), h.new_employee_review_employee_goal_path(employee_review), class: css_class) end |
#next_step_alert ⇒ ActiveSupport::SafeBuffer?
Info alert with the next available workflow action.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/presenters/crm/employee_review_presenter.rb', line 53 def next_step_alert if r.can_complete_review? && r.employee_goals.present? alert = "This review is ready to complete." wf_action = :complete_review elsif r.can_complete_allocate_reward? alert = "Rewards are ready to be allocated for this review." wf_action = :complete_allocate_reward end return unless wf_action content_tag :div, class: 'alert alert-info' do h.centered_row do concat alert concat link_to(fa_icon('check', text: wf_action.to_s.humanize), h.workflow_action_employee_review_path(r, wf_action: wf_action), method: :post, class: 'btn btn-success') end end end |
#render_employee_goals ⇒ String?
Renders the employee goals partial for quarterly reviews.
102 103 104 105 106 |
# File 'app/presenters/crm/employee_review_presenter.rb', line 102 def render_employee_goals return unless employee_review.quarterly? h.render partial: 'employee_goals', locals: { erp: self } end |
#render_reward_allocations ⇒ String?
Renders the reward allocations partial once the review reaches reward stages.
110 111 112 113 114 |
# File 'app/presenters/crm/employee_review_presenter.rb', line 110 def render_reward_allocations return unless r.allocate_reward? || r.process_reward? || r.complete? h.render partial: 'reward_allocations', locals: { erp: self } end |
#setup_employee_review_for_reward_allocations ⇒ EmployeeReview
Builds reward allocations up to three rows for the form.
118 119 120 121 122 |
# File 'app/presenters/crm/employee_review_presenter.rb', line 118 def setup_employee_review_for_reward_allocations employee_review.tap do |er| [3 - er.reward_allocations.size, 0].max.times { er.reward_allocations.build } end end |