Class: Decidim::Forms::StepNavigationCell

Inherits:
ViewModel
  • Object
show all
Defined in:
app/cells/decidim/forms/step_navigation_cell.rb

Overview

This cell renders the navigation of a questionnaire step.

Instance Method Summary collapse

Instance Method Details

#allow_editing_responses?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'app/cells/decidim/forms/step_navigation_cell.rb', line 43

def allow_editing_responses?
  options[:allow_editing_responses]
end

#button_disabled?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/cells/decidim/forms/step_navigation_cell.rb', line 27

def button_disabled?
  options[:button_disabled]
end

#confirmObject



59
60
61
62
63
# File 'app/cells/decidim/forms/step_navigation_cell.rb', line 59

def confirm
  return t("decidim.forms.step_navigation.show.are_you_sure_edit_guest") unless current_user

  t("decidim.forms.step_navigation.show.are_you_sure_no_edit")
end

#confirm_dataObject



47
48
49
50
51
52
53
54
55
56
57
# File 'app/cells/decidim/forms/step_navigation_cell.rb', line 47

def confirm_data
  return {} if allow_editing_responses? && current_user

  {
    data: {
      confirm:,
      disable: true,
      data: "survey-buttons"
    }
  }
end

#current_step_dom_idObject



39
40
41
# File 'app/cells/decidim/forms/step_navigation_cell.rb', line 39

def current_step_dom_id
  "step-#{current_step_index}"
end

#current_step_indexObject



7
8
9
# File 'app/cells/decidim/forms/step_navigation_cell.rb', line 7

def current_step_index
  model
end

#first_step?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'app/cells/decidim/forms/step_navigation_cell.rb', line 11

def first_step?
  current_step_index.zero?
end

#formObject



23
24
25
# File 'app/cells/decidim/forms/step_navigation_cell.rb', line 23

def form
  options[:form]
end

#last_step?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/cells/decidim/forms/step_navigation_cell.rb', line 15

def last_step?
  current_step_index + 1 == total_steps
end

#next_step_dom_idObject



35
36
37
# File 'app/cells/decidim/forms/step_navigation_cell.rb', line 35

def next_step_dom_id
  "step-#{current_step_index + 1}"
end

#previous_step_dom_idObject



31
32
33
# File 'app/cells/decidim/forms/step_navigation_cell.rb', line 31

def previous_step_dom_id
  "step-#{current_step_index - 1}"
end

#total_stepsObject



19
20
21
# File 'app/cells/decidim/forms/step_navigation_cell.rb', line 19

def total_steps
  options[:total_steps]
end