Module: ForemanPatch::PlansHelper
- Defined in:
- app/helpers/foreman_patch/plans_helper.rb
Instance Method Summary collapse
- #plan_actions(plan) ⇒ Object
- #plan_last_window_day(plan) ⇒ Object
- #plan_window_actions(window) ⇒ Object
- #plan_windows(plan, day) ⇒ Object
Instance Method Details
#plan_actions(plan) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/foreman_patch/plans_helper.rb', line 4 def plan_actions(plan) links = [] links << link_to(_('Create Window'), new_plan_window_plan_path(plan_id: @plan.id), class: 'btn btn-default', title: _('Create a new window for this plan')) links << link_to(_('Edit'), edit_plan_path(@plan), class: 'btn btn-default', title: _('Edit this plan')) links << link_to(_('Run'), iterate_plan_path(@plan), class: 'btn btn-primary', title: _('Manually Iterate Plan'), method: :post) links end |
#plan_last_window_day(plan) ⇒ Object
40 41 42 |
# File 'app/helpers/foreman_patch/plans_helper.rb', line 40 def plan_last_window_day(plan) (plan.frequency.to_i / ActiveSupport::Duration::SECONDS_PER_DAY) - 1 end |
#plan_window_actions(window) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/helpers/foreman_patch/plans_helper.rb', line 31 def plan_window_actions(window) actions = [] actions << link_to(_('Edit'), edit_window_plan_path(window)) actions << link_to(_('Delete'), hash_for_window_plan_path(id: window), data: { confirm: _('Are you sure?') }, action: :destroy) actions end |
#plan_windows(plan, day) ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/helpers/foreman_patch/plans_helper.rb', line 23 def plan_windows(plan, day) day = (day - plan.start_date).to_i plan.window_plans.select do |window| window.start_day == day end end |