Module: Admin::EventRulesHelper

Defined in:
app/helpers/admin/event_rules_helper.rb

Instance Method Summary collapse

Instance Method Details

#action_fields_for(object, actions, &content) ⇒ Object



41
42
43
# File 'app/helpers/admin/event_rules_helper.rb', line 41

def action_fields_for(object, actions, &content)
  fields_for_event_rule_group(object, actions, 'action', &content)
end

#action_select(form) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'app/helpers/admin/event_rules_helper.rb', line 18

def action_select(form)
  form.select :action, [
    ["change Lead score",    :change_lead_score],
    ["send notification",    :send_notification],
    ["add tag",              :add_tag],
    ["remove tag",           :remove_tag],
    ["add to mailing group", :add_to_mailing_list_group]
  ], {}, :class => "action_select"
end

#add_event_rule_button(f) ⇒ Object



3
4
5
6
7
8
# File 'app/helpers/admin/event_rules_helper.rb', line 3

def add_event_rule_button(f)
  fields = f.fields_for "new_event_rule", EventRule.new do |builder|
    render("form", :r => builder, :index => "new_event_rule")
  end
  button_tag 'Add New Rule', :class => "add_event_rule", "data-content" => "#{fields}"
end

#event_category_select(form) ⇒ Object



10
11
12
13
14
15
16
# File 'app/helpers/admin/event_rules_helper.rb', line 10

def event_category_select(form)
  form.select :event_category, [
    ["Cloudfuji event", :cloudfuji_event_received],
    ["Page loaded",     :page_loaded],
    ["Lead attribute",  :lead_attribute_changed]
  ], {}, :class => "event_category_select"
end

#event_fields_for(object, events, &content) ⇒ Object



37
38
39
# File 'app/helpers/admin/event_rules_helper.rb', line 37

def event_fields_for(object, events, &content)
  fields_for_event_rule_group(object, events, 'event_category', &content)
end

#fields_for_event_rule_group(object, subjects, field) ⇒ Object

Generates divs with form field groups for event rules



29
30
31
32
33
34
35
# File 'app/helpers/admin/event_rules_helper.rb', line 29

def fields_for_event_rule_group(object, subjects, field)
  subjects = [subjects].flatten
  (:div, :class => subjects.map {|s| "#{field}_#{s}" }.join(" ") << " #{field}_fields",
                    :style => (subjects.none? {|s| s == object.send(field) } ? "display: none;" : "")) do
    yield
  end
end

#lead_attributesObject



45
46
47
# File 'app/helpers/admin/event_rules_helper.rb', line 45

def lead_attributes
  Lead.attribute_names - %w(id deleted_at updated_at created_at)
end