Class: DailyFocus::WorkDayIndicator

Inherits:
Object
  • Object
show all
Defined in:
app/services/daily_focus/work_day_indicator.rb

Overview

Maps +Employee#work_status_on_day+ / +working_on_day?+ to two briefing-adjacent badges: "Not working" or "Partially working".

Defined Under Namespace

Classes: Result

Constant Summary collapse

PARTIAL_ICON_CLASS =

Partial icon class.

'fa-solid fa-clock me-1'
NOT_WORKING_ICON_CLASS =

Not working icon class.

'fa-solid fa-mug-hot me-1'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(employee:, date:) ⇒ WorkDayIndicator

Returns a new instance of WorkDayIndicator.



19
20
21
22
# File 'app/services/daily_focus/work_day_indicator.rb', line 19

def initialize(employee:, date:)
  @employee = employee
  @date = date
end

Class Method Details

.call(employee:, date:) ⇒ Result?

Returns nil when the rep is treated as a full working day for Daily Focus / capacity.

Returns:

  • (Result, nil)

    nil when the rep is treated as a full working day for Daily Focus / capacity.



15
16
17
# File 'app/services/daily_focus/work_day_indicator.rb', line 15

def self.call(employee:, date:)
  new(employee:, date: date.to_date).call
end

Instance Method Details

#callObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/services/daily_focus/work_day_indicator.rb', line 24

def call
  return nil if show_nothing?

  if partial_day?
    Result.new(
      label: 'Partially working',
      css_class: 'bg-warning text-dark',
      title: partial_title,
      icon_class: PARTIAL_ICON_CLASS
    )
  else
    Result.new(
      label: 'Not working',
      css_class: 'bg-secondary',
      title: not_working_title,
      icon_class: NOT_WORKING_ICON_CLASS
    )
  end
end