Module: Decidim::Forms::Admin::Concerns::HasQuestionnaireAnswersPaginationHelper

Defined in:
app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_pagination_helper.rb

Overview

Pagination helper for HasQuestionnaireAnswers controller concern

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



10
11
12
# File 'app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_pagination_helper.rb', line 10

def self.included(base)
  base.helper_method :prev_url, :next_url, :first?, :last?, :current_idx
end

Instance Method Details

#first?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_pagination_helper.rb', line 28

def first?
  current_idx.zero?
end

#last?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_pagination_helper.rb', line 32

def last?
  current_idx == participant_ids.count - 1
end

#next_urlObject



21
22
23
24
25
26
# File 'app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_pagination_helper.rb', line 21

def next_url
  return if last?

  token = participant_ids[current_idx + 1]
  questionnaire_participant_answers_url(token)
end

#prev_urlObject



14
15
16
17
18
19
# File 'app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_pagination_helper.rb', line 14

def prev_url
  return if first?

  token = participant_ids[current_idx - 1]
  questionnaire_participant_answers_url(token)
end