Module: ForemanTasks::ForemanTasksHelper

Defined in:
app/helpers/foreman_tasks/foreman_tasks_helper.rb

Instance Method Summary collapse

Instance Method Details

#date_f(f, attr, field_options = {}, date_options = {}, html_options = {}) ⇒ Object



43
44
45
46
47
48
49
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 43

def date_f(f, attr, field_options = {}, date_options = {}, html_options = {})
  f.fields_for attr do |fields|
    field(fields, attr, field_options) do
      fields.date_select attr, date_options, html_options
    end
  end
end

#datetime_f(f, attr, field_options = {}, datetime_options = {}, html_options = {}) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 51

def datetime_f(f, attr, field_options = {}, datetime_options = {}, html_options = {})
  f.fields_for attr do |fields|
    field(fields, attr, field_options) do
      [
        (:span, nil, :class => 'date', :style => 'white-space: nowrap;') do
          fields.date_select(attr, datetime_options, html_options)
        end,
        ' — ',
        (:span, nil, :class => 'time', :style => 'white-space: nowrap;') do
          fields.time_select(attr, datetime_options.merge(:ignore_date => true), html_options)
        end
      ].join
    end
  end
end

#inline_checkboxes_f(f, attr, field_options = {}, checkboxes = {}, options = {}) ⇒ Object



67
68
69
70
71
72
73
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 67

def inline_checkboxes_f(f, attr, field_options = {}, checkboxes = {}, options = {})
  field(f, attr, field_options) do
    checkboxes.map do |key, name|
      [f.check_box(key, options), " #{name} "]
    end.flatten.join('')
  end
end

#recurring_logic_action_buttons(recurring_logic) ⇒ Object



19
20
21
22
23
24
25
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 19

def recurring_logic_action_buttons(recurring_logic)
  buttons = []
  if authorized_for(:permission => :edit_recurring_logics, :auth_object => recurring_logic)
    buttons << link_to(N_("Cancel"), cancel_foreman_tasks_recurring_logic_path(recurring_logic), :method => :post, :class => 'btn btn-danger') unless %w(cancelled finished).include? recurring_logic.state
  end
  button_group buttons
end

#recurring_logic_next_occurrence(recurring_logic) ⇒ Object



27
28
29
30
31
32
33
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 27

def recurring_logic_next_occurrence(recurring_logic)
  if %w(finished cancelled).include? recurring_logic.state
    '-'
  else
    recurring_logic.next_occurrence_time
  end
end

#recurring_logic_state(recurring_logic) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 5

def recurring_logic_state(recurring_logic)
  icon, status = case recurring_logic.state
         when 'active'
           'glyphicon-info-sign'
         when 'finished'
           ['glyphicon-ok-sign', 'status-ok']
         when 'cancelled'
           ['glyphicon-warning-sign', 'status-error']
         else
           'glyphicon-question-sign'
         end
  (:i, '&nbsp'.html_safe, :class => "glyphicon #{icon}") + (:span, recurring_logic.humanized_state, :class => status)
end

#time_f(f, attr, field_options = {}, time_options = {}, html_options = {}) ⇒ Object



35
36
37
38
39
40
41
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 35

def time_f(f, attr, field_options = {}, time_options = {}, html_options = {})
  f.fields_for attr do |fields|
    field(fields, attr, field_options) do
      fields.time_select attr, time_options, html_options
    end
  end
end

#trigger_selector(f, triggering = Triggering.new, options = {}) ⇒ Object



75
76
77
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 75

def trigger_selector(f, triggering = Triggering.new, options = {})
  render :partial => 'common/trigger_form', :locals => { :f => f, :triggering => triggering }
end