Add support for open-ended questions in admin section
Introduce a new "open" votation type for poll questions in the admin interface. This type allows open answers provided by the user.
This commit is contained in:
@@ -10,7 +10,8 @@ class Admin::VotationTypes::FieldsComponent < ApplicationComponent
|
||||
def descriptions
|
||||
{
|
||||
unique: t("admin.polls.votation_type.unique_description"),
|
||||
multiple: t("admin.polls.votation_type.multiple_description")
|
||||
multiple: t("admin.polls.votation_type.multiple_description"),
|
||||
open: t("admin.polls.votation_type.open_description")
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class Poll::Question < ApplicationRecord
|
||||
accepts_nested_attributes_for :question_options, reject_if: :all_blank, allow_destroy: true
|
||||
accepts_nested_attributes_for :votation_type
|
||||
|
||||
delegate :multiple?, :vote_type, to: :votation_type, allow_nil: true
|
||||
delegate :multiple?, :open?, :vote_type, to: :votation_type, allow_nil: true
|
||||
|
||||
scope :sort_for_list, -> { order(Arel.sql("poll_questions.proposal_id IS NULL"), :created_at) }
|
||||
scope :for_render, -> { includes(:author, :proposal) }
|
||||
|
||||
@@ -3,7 +3,7 @@ class VotationType < ApplicationRecord
|
||||
|
||||
QUESTIONABLE_TYPES = %w[Poll::Question].freeze
|
||||
|
||||
enum :vote_type, { unique: 0, multiple: 1 }
|
||||
enum :vote_type, { unique: 0, multiple: 1, open: 2 }
|
||||
|
||||
validates :questionable, presence: true
|
||||
validates :questionable_type, inclusion: { in: ->(*) { QUESTIONABLE_TYPES }}
|
||||
|
||||
Reference in New Issue
Block a user