Module: ActivityTypesHelper

Defined in:
app/helpers/activity_types_helper.rb

Overview

View helper: activity types.

Instance Method Summary collapse

Instance Method Details

#setup_activity_type(activity_type) ⇒ ActivityType

Prepares an activity type form object by ensuring nested records exist.

Builds a blank activity_chain_types row when none are present, and one
activity_type_assignment_queues row per sales company, skipping companies
that already have a queue assignment.

Parameters:

  • activity_type (ActivityType)

    the activity type to populate with nested records

Returns:

  • (ActivityType)

    the same activity type, with nested records built in memory



12
13
14
15
16
17
18
19
# File 'app/helpers/activity_types_helper.rb', line 12

def setup_activity_type(activity_type)
  activity_type.tap do |at|
    at.activity_chain_types.build if at.activity_chain_types.blank?
    Company.sales_companies.ids.each do |cid|
      at.activity_type_assignment_queues.build(company_id: cid) unless at.activity_type_assignment_queues.any? { |e| e.company_id == cid }
    end
  end
end