Sha256: 9028da6114322a152b04f444ce96729805a6b28586e157037695389bb4c57232
Contents?: true
Size: 1.33 KB
Versions: 12
Compression:
Stored size: 1.33 KB
Contents
# frozen_string_literal: true # A nav item related to a Bit Core Tool. class ToolNavItem def self.for_participant(participant) participant.active_group.arm.non_home_tools.order(:position) .map { |t| new(participant, t) } end def initialize(participant, tool) @participant = participant @tool = tool end def title @tool.title end def alert case @tool.type when nil any_incomplete_tasks_today? && display_alert(@tool) ? "New!" : nil else count = @participant.count_all_incomplete(@tool) count > 0 ? count : nil end end def display_alert(tool) !%w(RELAX SUPPORT).include?(tool.title) end def active?(current_module) current_module.bit_core_tool_id == @tool.id end def generic_tool? @tool.type.nil? end def module_nav_items available_content_modules .position_greater_than(1) .non_visualization .available_by(Time.zone.today) .order_by_position .latest_duplicate end def any_incomplete_tasks_today? available_content_modules .non_visualization .not_completed .available_on(Time.zone.today) .exists? end private def available_content_modules AvailableContentModule .for_tool(@tool) .for_participant(@participant) .not_terminated_on(Time.zone.today) end end
Version data entries
12 entries across 12 versions & 1 rubygems