Module: ForemanTasks::ForemanTasksHelper
- Defined in:
- app/helpers/foreman_tasks/foreman_tasks_helper.rb
Instance Method Summary collapse
- #breadcrumb_items ⇒ Object
- #date_f(f, attr, field_options = {}, date_options = {}, html_options = {}) ⇒ Object
- #datetime_f(f, attr, field_options = {}, datetime_options = {}, html_options = {}) ⇒ Object
- #index_breadcrumb_item ⇒ Object
- #inline_checkboxes_f(f, attr, field_options = {}, checkboxes = {}, options = {}) ⇒ Object
- #recurring_logic_action_buttons(recurring_logic) ⇒ Object
- #recurring_logic_next_occurrence(recurring_logic) ⇒ Object
- #recurring_logic_state(recurring_logic) ⇒ Object
- #task_breadcrumb_item(task, active = false) ⇒ Object
- #time_f(f, attr, field_options = {}, time_options = {}, html_options = {}) ⇒ Object
- #trigger_selector(f, triggering = Triggering.new, _options = {}) ⇒ Object
- #troubleshooting_info ⇒ Object
- #troubleshooting_info_text ⇒ Object
- #username_link_task(owner, username) ⇒ Object
Instance Method Details
#breadcrumb_items ⇒ Object
115 116 117 118 119 120 121 |
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 115 def items = [] return items if action_name == 'index' items << (@task, action_name == 'show') items << { :caption => _('Sub tasks') } if action_name == 'sub_tasks' items end |
#date_f(f, attr, field_options = {}, date_options = {}, html_options = {}) ⇒ Object
67 68 69 70 71 72 73 |
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 67 def date_f(f, attr, = {}, = {}, = {}) f.fields_for attr do |fields| field(fields, attr, ) do fields.date_select attr, , end end end |
#datetime_f(f, attr, field_options = {}, datetime_options = {}, html_options = {}) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 75 def datetime_f(f, attr, = {}, = {}, = {}) f.fields_for attr do |fields| field(fields, attr, ) do [ content_tag(:span, nil, :class => 'date', :style => 'white-space: nowrap;') do fields.date_select(attr, , ) end, ' — ', content_tag(:span, nil, :class => 'time', :style => 'white-space: nowrap;') do fields.time_select(attr, .merge(:ignore_date => true), ) end, ].join end end end |
#index_breadcrumb_item ⇒ Object
109 110 111 112 113 |
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 109 def item = { :caption => _('Tasks') } item[:url] = foreman_tasks_tasks_url if action_name != 'index' item end |
#inline_checkboxes_f(f, attr, field_options = {}, checkboxes = {}, options = {}) ⇒ Object
91 92 93 94 95 96 97 |
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 91 def inline_checkboxes_f(f, attr, = {}, checkboxes = {}, = {}) field(f, attr, ) do checkboxes.map do |key, name| [f.check_box(key, ), " #{name} "] end.flatten.join('') end end |
#recurring_logic_action_buttons(recurring_logic) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 41 def (recurring_logic) = [] if (:permission => :edit_recurring_logics, :auth_object => recurring_logic) << link_to(N_('Enable'), enable_foreman_tasks_recurring_logic_path(recurring_logic), :method => :put, :class => '') if !recurring_logic.done? && recurring_logic.disabled? << link_to(N_('Disable'), disable_foreman_tasks_recurring_logic_path(recurring_logic), :method => :put, :class => '') if !recurring_logic.done? && recurring_logic.enabled? << link_to(N_('Cancel'), cancel_foreman_tasks_recurring_logic_path(recurring_logic), :method => :post, :class => '') unless recurring_logic.done? end end |
#recurring_logic_next_occurrence(recurring_logic) ⇒ Object
51 52 53 54 55 56 57 |
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 51 def recurring_logic_next_occurrence(recurring_logic) default = '-' return default if recurring_logic.done? || recurring_logic.disabled? upcoming_task = recurring_logic.next_task upcoming_task ? upcoming_task.start_at : default end |
#recurring_logic_state(recurring_logic) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 3 def recurring_logic_state(recurring_logic) icon, status = case recurring_logic.state when 'active' 'glyphicon-info-sign' when 'disabled' 'glyphicon glyphicon-pause' when 'finished' ['glyphicon-ok-sign', 'status-ok'] when 'cancelled' ['glyphicon-warning-sign', 'status-error'] else 'glyphicon-question-sign' end content_tag(:i, ' '.html_safe, :class => "glyphicon #{icon}") + content_tag(:span, recurring_logic.humanized_state, :class => status) end |
#task_breadcrumb_item(task, active = false) ⇒ Object
103 104 105 106 107 |
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 103 def (task, active = false) item = { :caption => format_task_input(task) } item[:url] = url_for(foreman_tasks_task_path(task.id)) unless active item end |
#time_f(f, attr, field_options = {}, time_options = {}, html_options = {}) ⇒ Object
59 60 61 62 63 64 65 |
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 59 def time_f(f, attr, = {}, = {}, = {}) f.fields_for attr do |fields| field(fields, attr, ) do fields.time_select attr, , end end end |
#trigger_selector(f, triggering = Triggering.new, _options = {}) ⇒ Object
99 100 101 |
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 99 def trigger_selector(f, triggering = Triggering.new, = {}) render :partial => 'common/trigger_form', :locals => { :f => f, :triggering => triggering } end |
#troubleshooting_info ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 19 def troubleshooting_info return if @task.state != 'paused' || @task.main_action.nil? helper = TroubleshootingHelpGenerator.new(@task.main_action) ret = '<p><b>Troubleshooting</b></p>' ret += '<p>%{help}</p>' % { help: helper.generate_html } ret.html_safe end |
#troubleshooting_info_text ⇒ Object
27 28 29 30 31 |
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 27 def troubleshooting_info_text return if @task.state != 'paused' || @task.main_action.nil? helper = TroubleshootingHelpGenerator.new(@task.main_action) helper.generate_html end |
#username_link_task(owner, username) ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/helpers/foreman_tasks/foreman_tasks_helper.rb', line 33 def username_link_task(owner, username) if owner.present? && username != User::ANONYMOUS_API_ADMIN && username != User::ANONYMOUS_ADMIN (username, hash_for_edit_user_path(owner)) else username end end |