Improving surveys system: showing surveys in admin UI as they will be for the user
This commit is contained in:
parent
335608e6c4
commit
03168b4efe
15 changed files with 213 additions and 46 deletions
|
|
@ -17,8 +17,13 @@
|
|||
.col-md-12
|
||||
= f.input :title
|
||||
= f.input :mandatory
|
||||
%div.survey-possible-answers.hidden
|
||||
%div.survey-possible-answers{ class: @survey_question.choice? ? '' : 'hidden'}
|
||||
= f.input :possible_answers, hint: 'Comma separated', input_html: { rows: 3 }
|
||||
.row
|
||||
.col-md-6
|
||||
= f.input :min_choices
|
||||
.col-md-6
|
||||
= f.input :max_choices
|
||||
%hr
|
||||
.row
|
||||
.col-md-6
|
||||
|
|
@ -26,38 +31,62 @@
|
|||
Type of Question:
|
||||
.form-group
|
||||
%select.selectpicker.form-control{ id: 'survey_question_kind', name: 'survey_question[kind]' }
|
||||
- SurveyQuestion.types.each do |type|
|
||||
%option{ id: "#{type.second}", 'data-icon' => "fa fa-#{SurveyQuestion::ICONS[type.first.to_sym]}" }
|
||||
= type.first
|
||||
- SurveyQuestion.kinds.each do |kind|
|
||||
%option{ id: "#{kind.second}", 'data-icon' => "fa fa-#{SurveyQuestion::ICONS[kind.first.to_sym]}", selected: @survey_question.kind == kind.first }
|
||||
= kind.first
|
||||
.col-md-6
|
||||
%label
|
||||
Preview:
|
||||
.panel.panel-default
|
||||
.panel-body
|
||||
%p
|
||||
What is your answer?
|
||||
.panel-body{id: 'survey_question_preview'}
|
||||
%p{id: 'title', style: 'word-wrap: break-word'}
|
||||
= @survey_question.title.blank? ? 'What is your answer?' : @survey_question.title
|
||||
|
||||
%div.kinds.boolean
|
||||
%div.kinds.boolean{ class: @survey_question.boolean? ? '' : 'hidden'}
|
||||
%input{type: 'radio', name: 'radio'} Yes
|
||||
%br
|
||||
%input{type: 'radio', name: 'radio'} No
|
||||
|
||||
%div.kinds.choice.hidden
|
||||
%input{ type: 'checkbox', name: 'checkbox' } Choice 1
|
||||
%br
|
||||
%input{ type: 'checkbox', name: 'checkbox' } Choice 2
|
||||
%br
|
||||
%input{ type: 'checkbox', name: 'checkbox' } Choice 3
|
||||
%div.kinds.choice{ id: '', class: @survey_question.choice? ? '' : 'hidden'}
|
||||
- if @survey_question.possible_answers.blank?
|
||||
- if @survey_question.single_choice?
|
||||
%input{ type: 'radio', name: 'radio' } Choice 1
|
||||
%br
|
||||
%input{ type: 'radio', name: 'radio' } Choice 2
|
||||
%br
|
||||
%input{ type: 'radio', name: 'radio' } Choice 3
|
||||
- else
|
||||
%input{ type: 'checkbox', name: 'checkbox' } Choice 1
|
||||
%br
|
||||
%input{ type: 'checkbox', name: 'checkbox' } Choice 2
|
||||
%br
|
||||
%input{ type: 'checkbox', name: 'checkbox' } Choice 3
|
||||
- else
|
||||
- @survey_question.possible_answers.split(',').map(&:strip).each do |option|
|
||||
- if @survey_question.single_choice?
|
||||
%input{ type: 'radio', name: 'radio' }
|
||||
= option
|
||||
%br
|
||||
- else
|
||||
%input{ type: 'checkbox', name: 'checkbox' }
|
||||
= option
|
||||
%br
|
||||
|
||||
%div.kinds.string.hidden
|
||||
%div.kinds.string{ class: @survey_question.string? ? '' : 'hidden'}
|
||||
%input.form-control
|
||||
|
||||
%div.kinds.text.hidden
|
||||
%div.kinds.text{ class: @survey_question.text? ? '' : 'hidden'}
|
||||
%textarea.form-control{ rows: 4 }
|
||||
|
||||
|
||||
%div.kinds.datetime.hidden
|
||||
%input.form-control{id: 'registration-arrival-datepicker', readonly: 'readonly'}
|
||||
%div.kinds.datetime{ class: @survey_question.datetime? ? '' : 'hidden'}
|
||||
.form-group{class: 'datetimepicker'}
|
||||
.input-group
|
||||
.input-group-addon
|
||||
%span.fa.fa-calendar
|
||||
%input.form-control{readonly: 'readonly'}
|
||||
|
||||
%div.kinds.numeric.hidden
|
||||
%div.kinds.numeric{ class: @survey_question.numeric? ? '' : 'hidden'}
|
||||
%input.form-control{ type: 'number' }
|
||||
|
||||
= f.submit 'Save', class: 'btn btn-primary'
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
.col-md-12
|
||||
.page-header
|
||||
%h1
|
||||
Survey Questions
|
||||
Questions for survey
|
||||
= link_to @survey.title, admin_conference_survey_path(@conference.short_title, @survey)
|
||||
= "(#{@survey_questions.length})"
|
||||
|
||||
- if @survey_questions.any?
|
||||
|
|
|
|||
50
app/views/admin/surveys/_survey_question.html.haml
Normal file
50
app/views/admin/surveys/_survey_question.html.haml
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
.panel.panel-default
|
||||
.panel-heading
|
||||
%span.badge
|
||||
= index
|
||||
= survey_question.title
|
||||
- if survey_question.multiple_choice?
|
||||
( Select
|
||||
- if survey_question.min_choices != survey_question.max_choices
|
||||
a minimum of
|
||||
= survey_question.min_choices
|
||||
- if survey_question.min_choices != survey_question.max_choices
|
||||
and a maximum of
|
||||
= survey_question.max_choices
|
||||
choices )
|
||||
- if survey_question.mandatory
|
||||
%span.fa.fa-asterisk.text-danger
|
||||
%p.pull-right
|
||||
= link_to edit_admin_conference_survey_survey_question_path(@conference.short_title, @survey, survey_question) do
|
||||
%span.fa.fa-edit
|
||||
= link_to admin_conference_survey_survey_question_path(@conference.short_title, @survey, survey_question), method: :delete, data: { confirm: 'Are you sure you want to delete this question?' } do
|
||||
%span.fa.fa-times
|
||||
.panel-body
|
||||
- if survey_question.boolean?
|
||||
%input{type: 'radio', name: 'radio'}
|
||||
Yes
|
||||
%br
|
||||
%input{type: 'radio', name: 'radio'}
|
||||
No
|
||||
- elsif survey_question.choice?
|
||||
- survey_question.possible_answers.split(',').map(&:strip).each do |option|
|
||||
- if survey_question.single_choice?
|
||||
%input{ type: 'radio', name: 'radio' }
|
||||
= option
|
||||
%br
|
||||
- else
|
||||
%input{ type: 'checkbox', name: 'checkbox' }
|
||||
= option
|
||||
%br
|
||||
- elsif survey_question.string?
|
||||
%input.form-control
|
||||
- elsif survey_question.text?
|
||||
%textarea.form-control{ rows: 4 }
|
||||
- elsif survey_question.datetime?
|
||||
.form-group{class: 'datetimepicker'}
|
||||
.input-group
|
||||
.input-group-addon
|
||||
%span.fa.fa-calendar
|
||||
%input.form-control{readonly: 'readonly'}
|
||||
- elsif survey_question.numeric?
|
||||
%input.form-control{ type: 'number' }
|
||||
|
|
@ -21,14 +21,15 @@
|
|||
- @surveys.each_with_index do |survey, index|
|
||||
%tr
|
||||
%td
|
||||
= survey.title
|
||||
= link_to survey.title, admin_conference_survey_path(@conference.short_title, survey)
|
||||
%td
|
||||
= survey.start_date
|
||||
%td
|
||||
= survey.end_date
|
||||
%td
|
||||
= link_to 'Edit', edit_admin_conference_survey_path(@conference.short_title, survey.id),
|
||||
method: :get, class: 'btn btn-primary'
|
||||
= link_to 'Delete', admin_conference_survey_path(@conference.short_title, survey.id),
|
||||
method: :delete, class: 'btn btn-danger',
|
||||
data: { confirm: "Do you really want to delete #{survey.title}?"}
|
||||
.btn-group
|
||||
= link_to 'Edit', edit_admin_conference_survey_path(@conference.short_title, survey),
|
||||
class: 'btn btn-primary'
|
||||
= link_to 'Delete', admin_conference_survey_path(@conference.short_title, survey),
|
||||
method: :delete, class: 'btn btn-danger',
|
||||
data: { confirm: "Do you really want to delete #{survey.title}?"}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,18 @@
|
|||
%p#notice= notice
|
||||
|
||||
|
||||
= link_to 'Edit', edit_admin_survey_path(@admin_survey)
|
||||
\|
|
||||
= link_to 'Back', admin_surveys_path
|
||||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1
|
||||
Survey #{@survey.title}
|
||||
= link_to 'Edit Survey', edit_admin_conference_survey_path(@conference.short_title, @survey), class: 'btn btn-primary pull-right'
|
||||
%p.text-muted
|
||||
From:
|
||||
= @survey.start_date
|
||||
to
|
||||
= @survey.end_date
|
||||
.row
|
||||
.col-md-12
|
||||
- @survey.survey_questions.each.with_index(1) do |survey_question, index|
|
||||
.row
|
||||
.col-md-12
|
||||
= render partial: 'survey_question', locals: { survey_question: survey_question, index: index }
|
||||
= link_to 'Add Question', new_admin_conference_survey_survey_question_path(@conference.short_title, @survey), class: 'btn btn-success pull-right'
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
- if @conference.questions.any?
|
||||
= render partial: 'conference_registrations/questions', locals: { f: f }
|
||||
- if @conference.surveys.for_registration.any?
|
||||
Something
|
||||
- if @conference.program.events.with_registration_open.any? || @registration.events.any?
|
||||
= f.inputs 'Pre-registration required for the following:' do
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@
|
|||
E-Mails
|
||||
%li{ class: active_nav_li(admin_conference_surveys_path(@conference.short_title)) }
|
||||
= link_to(admin_conference_surveys_path(@conference.short_title)) do
|
||||
%span.fa.fa-group
|
||||
%span.fa.fa-list-alt
|
||||
Surveys
|
||||
- if can? :index, Role.new(resource: @conference)
|
||||
%li{:class=> active_nav_li(admin_conference_roles_path(@conference.short_title))}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue