helena 0.3.3 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -4
  3. data/Gemfile +1 -2
  4. data/Gemfile.lock +88 -95
  5. data/README.md +10 -25
  6. data/app/controllers/helena/application_controller.rb +0 -10
  7. data/app/controllers/helena/sessions_controller.rb +17 -6
  8. data/app/models/helena/answer.rb +1 -2
  9. data/app/models/helena/concerns/application_model.rb +0 -9
  10. data/app/models/helena/concerns/questions/validates_one_label.rb +1 -1
  11. data/app/models/helena/question.rb +5 -5
  12. data/app/models/helena/question_group.rb +4 -3
  13. data/app/models/helena/session.rb +27 -0
  14. data/app/models/helena/survey.rb +2 -7
  15. data/app/models/helena/version.rb +6 -4
  16. data/app/views/helena/questions/_static_text.html.slim +1 -0
  17. data/app/views/helena/sessions/_progressbar.html.slim +9 -0
  18. data/app/views/helena/sessions/edit.html.slim +18 -0
  19. data/app/views/helena/sessions/{end_message.html.haml → end_message.html.slim} +1 -1
  20. data/config/locales/models/question_group/en.yml +1 -0
  21. data/config/locales/models/session/en.yml +4 -0
  22. data/config/locales/models/survey/en.yml +3 -0
  23. data/config/locales/views/sessions/en.yml +4 -0
  24. data/config/routes.rb +1 -25
  25. data/db/seeds.rb +12 -140
  26. data/db/swls_survey.en.yml +67 -0
  27. data/helena.gemspec +1 -0
  28. data/lib/helena/engine.rb +11 -0
  29. data/lib/helena/survey_importer.rb +52 -0
  30. data/lib/helena/version.rb +1 -1
  31. data/lib/helena/version_publisher.rb +34 -2
  32. data/lib/helena.rb +3 -0
  33. data/spec/controllers/helena/sessions_controller_spec.rb +8 -3
  34. data/spec/dummy/app/controllers/application_controller.rb +0 -4
  35. data/spec/factories/helena/labels.rb +0 -1
  36. data/spec/factories/helena/question_groups.rb +0 -1
  37. data/spec/factories/helena/questions.rb +0 -1
  38. data/spec/factories/helena/sub_questions.rb +0 -1
  39. data/spec/factories/helena/surveys.rb +0 -1
  40. data/spec/features/helena/manage_session_spec.rb +76 -16
  41. data/spec/lib/survey_importer_spec.rb +14 -0
  42. data/spec/lib/version_publisher_spec.rb +5 -4
  43. data/spec/models/helena/answer_spec.rb +0 -1
  44. data/spec/models/helena/question_group_spec.rb +2 -1
  45. data/spec/models/helena/question_spec.rb +12 -4
  46. data/spec/models/helena/questions/checkbox_group_spec.rb +17 -0
  47. data/spec/models/helena/questions/radio_group_spec.rb +6 -0
  48. data/spec/models/helena/questions/radio_matrix_spec.rb +7 -0
  49. data/spec/models/helena/session_spec.rb +50 -0
  50. data/spec/models/helena/survey_spec.rb +12 -1
  51. data/spec/models/helena/version_spec.rb +11 -2
  52. metadata +26 -73
  53. data/app/assets/images/helena/icons/export.svg +0 -29
  54. data/app/assets/stylesheets/helena/admin/labels.css.sass +0 -7
  55. data/app/assets/stylesheets/helena/admin/layout.css.sass +0 -6
  56. data/app/assets/stylesheets/helena/admin/question_groups.css.sass +0 -7
  57. data/app/assets/stylesheets/helena/admin/questions.css.sass +0 -9
  58. data/app/assets/stylesheets/helena/admin/sessions.css.sass +0 -5
  59. data/app/assets/stylesheets/helena/admin/subquestions.css.sass +0 -7
  60. data/app/assets/stylesheets/helena/admin/versions.css.sass +0 -9
  61. data/app/controllers/helena/admin/application_controller.rb +0 -31
  62. data/app/controllers/helena/admin/question_groups_controller.rb +0 -78
  63. data/app/controllers/helena/admin/questions/checkbox_groups_controller.rb +0 -17
  64. data/app/controllers/helena/admin/questions/checkbox_matrix_controller.rb +0 -9
  65. data/app/controllers/helena/admin/questions/long_texts_controller.rb +0 -13
  66. data/app/controllers/helena/admin/questions/radio_groups_controller.rb +0 -17
  67. data/app/controllers/helena/admin/questions/radio_matrix_controller.rb +0 -9
  68. data/app/controllers/helena/admin/questions/short_texts_controller.rb +0 -13
  69. data/app/controllers/helena/admin/questions/static_texts_controller.rb +0 -13
  70. data/app/controllers/helena/admin/questions_controller.rb +0 -105
  71. data/app/controllers/helena/admin/sessions_controller.rb +0 -35
  72. data/app/controllers/helena/admin/surveys_controller.rb +0 -78
  73. data/app/controllers/helena/admin/versions_controller.rb +0 -71
  74. data/app/controllers/helena/surveys_controller.rb +0 -11
  75. data/app/views/helena/admin/question_groups/_form.html.haml +0 -3
  76. data/app/views/helena/admin/question_groups/edit.html.haml +0 -3
  77. data/app/views/helena/admin/question_groups/index.html.haml +0 -41
  78. data/app/views/helena/admin/question_groups/new.html.haml +0 -3
  79. data/app/views/helena/admin/questions/_form.html.haml +0 -15
  80. data/app/views/helena/admin/questions/_labels.html.haml +0 -24
  81. data/app/views/helena/admin/questions/_sub_questions.html.haml +0 -32
  82. data/app/views/helena/admin/questions/edit.html.haml +0 -3
  83. data/app/views/helena/admin/questions/index.html.haml +0 -49
  84. data/app/views/helena/admin/questions/new.html.haml +0 -3
  85. data/app/views/helena/admin/sessions/index.html.haml +0 -46
  86. data/app/views/helena/admin/surveys/_form.html.haml +0 -10
  87. data/app/views/helena/admin/surveys/edit.html.haml +0 -5
  88. data/app/views/helena/admin/surveys/index.html.haml +0 -35
  89. data/app/views/helena/admin/surveys/new.html.haml +0 -3
  90. data/app/views/helena/admin/versions/_form.html.haml +0 -5
  91. data/app/views/helena/admin/versions/default_session_report.html.haml +0 -17
  92. data/app/views/helena/admin/versions/edit.html.haml +0 -3
  93. data/app/views/helena/admin/versions/index.html.haml +0 -35
  94. data/app/views/helena/admin/versions/new.html.haml +0 -3
  95. data/app/views/helena/sessions/edit.html.haml +0 -16
  96. data/app/views/helena/surveys/_survey.html.haml +0 -3
  97. data/app/views/helena/surveys/index.html.haml +0 -2
  98. data/config/locales/views/admin/question_groups/en.yml +0 -12
  99. data/config/locales/views/admin/questions/en.yml +0 -16
  100. data/config/locales/views/admin/sessions/en.yml +0 -11
  101. data/config/locales/views/admin/surveys/en.yml +0 -10
  102. data/config/locales/views/admin/versions/en.yml +0 -8
  103. data/spec/controllers/helena/admin/question_group_controller_spec.rb +0 -59
  104. data/spec/controllers/helena/admin/questions_controller_spec.rb +0 -60
  105. data/spec/controllers/helena/admin/sessions_controller_spec.rb +0 -84
  106. data/spec/controllers/helena/admin/survey_controller_spec.rb +0 -89
  107. data/spec/controllers/helena/admin/versions_controller_spec.rb +0 -19
  108. data/spec/controllers/helena/application_controller_spec.rb +0 -15
  109. data/spec/features/helena/admin/manage_question_group_spec.rb +0 -101
  110. data/spec/features/helena/admin/manage_question_spec.rb +0 -105
  111. data/spec/features/helena/admin/manage_session_spec.rb +0 -40
  112. data/spec/features/helena/admin/manage_survey_spec.rb +0 -141
  113. data/spec/features/helena/admin/manage_version_spec.rb +0 -74
  114. data/spec/features/helena/admin/question_types/manage_checkbox_group_question_spec.rb +0 -55
  115. data/spec/features/helena/admin/question_types/manage_long_text_question_spec.rb +0 -21
  116. data/spec/features/helena/admin/question_types/manage_radio_group_question_spec.rb +0 -59
  117. data/spec/features/helena/admin/question_types/manage_radio_matrix_question_spec.rb +0 -80
  118. data/spec/features/helena/admin/question_types/manage_short_text_question_spec.rb +0 -19
  119. data/spec/features/helena/admin/question_types/manage_static_text_question_spec.rb +0 -17
  120. data/spec/features/helena/manage_survey_spec.rb +0 -24
@@ -1,7 +0,0 @@
1
- .helena-admin
2
- table.question_groups
3
-
4
- td:last-child
5
- min-width: 200px
6
- text-align: right
7
-
@@ -1,9 +0,0 @@
1
- .helena-admin
2
- table.questions
3
-
4
- td.type
5
- min-width: 150px
6
-
7
- td:last-child
8
- min-width: 200px
9
- text-align: right
@@ -1,5 +0,0 @@
1
- .helena-admin
2
- table.sessions
3
-
4
- td:last-child
5
- text-align: right
@@ -1,7 +0,0 @@
1
- .helena-admin
2
- table.sub_questions
3
-
4
- td.position
5
- input
6
- max-width: 80px
7
-
@@ -1,9 +0,0 @@
1
- .helena-admin
2
- table.versions
3
-
4
- td.created_at
5
- min-width: 150px
6
-
7
- td:last-child
8
- min-width: 150px
9
- text-align: right
@@ -1,31 +0,0 @@
1
- module Helena
2
- module Admin
3
- class ApplicationController < Helena::ApplicationController
4
- before_filter :authenticate_administrator
5
-
6
- def notify_successful_create_for(resource_name)
7
- flash[:notice] = t('actions.created', resource: resource_name)
8
- end
9
-
10
- def notify_successful_update_for(resource_name)
11
- flash[:notice] = t('actions.updated', resource: resource_name)
12
- end
13
-
14
- def notify_successful_delete_for(resource_name)
15
- flash[:notice] = t('actions.deleted', resource: resource_name)
16
- end
17
-
18
- def notify_error(resource = nil)
19
- flash[:error] = []
20
- if resource
21
-
22
- resource.errors.full_messages.each do |message|
23
- flash[:error] << message
24
- end
25
- else
26
- flash[:error] << t('actions.error')
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,78 +0,0 @@
1
- module Helena
2
- module Admin
3
- class QuestionGroupsController < Admin::ApplicationController
4
- respond_to :html
5
-
6
- before_filter :load_resources, :add_breadcrumbs
7
- before_filter :find_question_group, only: [:edit, :destroy, :move_up, :move_down]
8
-
9
- def index
10
- @question_groups = @version.question_groups.asc(:position)
11
- end
12
-
13
- def new
14
- add_breadcrumb t('helena.admin.question_groups.new.new')
15
- @question_group = @version.question_groups.new
16
- end
17
-
18
- def create
19
- add_breadcrumb t('helena.admin.question_groups.create.new')
20
-
21
- @question_group = @version.question_groups.new question_group_params
22
-
23
- if @question_group.save
24
- notify_successful_create_for(@question_group.title)
25
- end
26
- respond_with @question_group, location: admin_survey_question_groups_path(@survey)
27
- end
28
-
29
- def edit
30
- add_breadcrumb @question_group.title
31
- end
32
-
33
- def update
34
- @question_group = @version.question_groups.find(params[:id])
35
-
36
- if @question_group.update_attributes question_group_params
37
- notify_successful_update_for(@question_group.title)
38
- end
39
- respond_with @question_group, location: admin_survey_question_groups_path(@survey)
40
- end
41
-
42
- def destroy
43
- notify_successful_delete_for(@question_group.title) if @question_group.destroy
44
- respond_with @question_group, location: admin_survey_question_groups_path(@survey)
45
- end
46
-
47
- def move_up
48
- @question_group.move_to! :higher
49
- respond_with @survey, location: admin_survey_question_groups_path(@survey)
50
- end
51
-
52
- def move_down
53
- @question_group.move_to! :lower
54
- respond_with @survey, location: admin_survey_question_groups_path(@survey)
55
- end
56
-
57
- private
58
-
59
- def load_resources
60
- @survey = Helena::Survey.find params['survey_id']
61
- @version = @survey.versions.find_by(version: 0)
62
- end
63
-
64
- def find_question_group
65
- @question_group = @version.question_groups.find(params[:id])
66
- end
67
-
68
- def add_breadcrumbs
69
- add_breadcrumb Helena::Survey.model_name.human(count: 2), :admin_surveys_path
70
- add_breadcrumb @survey.name, admin_survey_question_groups_path(@survey)
71
- end
72
-
73
- def question_group_params
74
- params.require(:question_group).permit(:title)
75
- end
76
- end
77
- end
78
- end
@@ -1,17 +0,0 @@
1
- module Helena
2
- module Admin
3
- module Questions
4
- class CheckboxGroupsController < Admin::QuestionsController
5
- private
6
-
7
- def add_ressources
8
- @question.sub_questions.build
9
- end
10
-
11
- def permited_params
12
- [:required, sub_questions_attributes: sub_questions_attributes]
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,9 +0,0 @@
1
- module Helena
2
- module Admin
3
- module Questions
4
- class CheckboxMatrixController < Admin::QuestionsController
5
- include Helena::Concerns::Questions::MatrixQuestions
6
- end
7
- end
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- module Helena
2
- module Admin
3
- module Questions
4
- class LongTextsController < Admin::QuestionsController
5
- private
6
-
7
- def permited_params
8
- [:default_value, :required]
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,17 +0,0 @@
1
- module Helena
2
- module Admin
3
- module Questions
4
- class RadioGroupsController < Admin::QuestionsController
5
- private
6
-
7
- def add_ressources
8
- @question.labels.build
9
- end
10
-
11
- def permited_params
12
- [:required, labels_attributes: labels_attributes]
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,9 +0,0 @@
1
- module Helena
2
- module Admin
3
- module Questions
4
- class RadioMatrixController < Admin::QuestionsController
5
- include Helena::Concerns::Questions::MatrixQuestions
6
- end
7
- end
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- module Helena
2
- module Admin
3
- module Questions
4
- class ShortTextsController < Admin::QuestionsController
5
- private
6
-
7
- def permited_params
8
- [:default_value, :required]
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- module Helena
2
- module Admin
3
- module Questions
4
- class StaticTextsController < Admin::QuestionsController
5
- private
6
-
7
- def permited_params
8
- [:default_value, :required]
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,105 +0,0 @@
1
- module Helena
2
- module Admin
3
- class QuestionsController < Admin::ApplicationController
4
- respond_to :html
5
-
6
- before_filter :load_resources, :add_breadcrumbs
7
- before_filter :load_question, only: [:edit, :update, :destroy, :move_up, :move_down]
8
-
9
- def index
10
- @questions = @question_group.questions.asc :position
11
- end
12
-
13
- def new
14
- @question = @question_group.questions.new
15
- end
16
-
17
- def create
18
- @question = @question_group.questions.new question_params
19
-
20
- if @question.save
21
- notify_successful_create_for(@question.code)
22
- location = [:admin, @survey, @question_group, :questions]
23
- else
24
- notify_error(@question)
25
- location = [:new, :admin, @survey, @question_group, @question]
26
- end
27
- respond_with @question, location: location
28
- end
29
-
30
- def edit
31
- add_ressources
32
- end
33
-
34
- def update
35
- if @question.update_attributes question_params
36
- notify_successful_update_for(@question.code)
37
- else
38
- notify_error @question
39
- add_breadcrumb @question.code_was
40
- end
41
- add_ressources
42
- respond_with @question, location: [:edit, :admin, @survey, @question_group, @question]
43
- end
44
-
45
- def destroy
46
- notify_successful_delete_for(@question.code) if @question.destroy
47
- respond_with @question, location: admin_survey_question_group_questions_path(@survey, @question_group)
48
- end
49
-
50
- def move_up
51
- @question.move_to! :higher
52
- respond_with @question, location: admin_survey_question_group_questions_path(@survey, @question_group)
53
- end
54
-
55
- def move_down
56
- @question.move_to! :lower
57
- respond_with @question, location: admin_survey_question_group_questions_path(@survey, @question_group)
58
- end
59
-
60
- private
61
-
62
- def load_resources
63
- @survey = Helena::Survey.find params['survey_id']
64
- @version = @survey.versions.find_by(version: 0)
65
- @question_group = @version.question_groups.find params[:question_group_id]
66
- end
67
-
68
- def add_breadcrumbs
69
- add_breadcrumb Helena::Survey.model_name.human(count: 2), :admin_surveys_path
70
- add_breadcrumb @survey.name, admin_survey_question_groups_path(@survey)
71
- add_breadcrumb @question_group.title, admin_survey_question_group_questions_path(@survey, @question_group)
72
- add_breadcrumb t('helena.admin.questions.new') if action_name == 'new' || action_name == 'create'
73
- end
74
-
75
- def question_params
76
- required_param.permit(permited_params + [:question_text, :code, :_type])
77
- end
78
-
79
- def required_param
80
- param_name = self.class == Helena::Admin::QuestionsController ? :question : "questions_#{controller_name.singularize}"
81
- params.require(param_name)
82
- end
83
-
84
- def permited_params
85
- []
86
- end
87
-
88
- def load_question
89
- @question = @question_group.questions.find(params[:id])
90
- add_breadcrumb @question.code
91
- end
92
-
93
- def add_ressources
94
- end
95
-
96
- def labels_attributes
97
- [:id, :position, :text, :value, :preselected, :_destroy]
98
- end
99
-
100
- def sub_questions_attributes
101
- [:id, :position, :code, :text, :value, :preselected, :_destroy]
102
- end
103
- end
104
- end
105
- end
@@ -1,35 +0,0 @@
1
- module Helena
2
- module Admin
3
- class SessionsController < Admin::ApplicationController
4
- respond_to :html
5
-
6
- before_filter :load_survey, :add_breadcrumbs
7
-
8
- def index
9
- respond_to do |format|
10
- @sessions = @survey.sessions.desc(:created_at)
11
- format.html
12
- format.json { render json: @sessions }
13
- format.csv { render text: @sessions.to_csv }
14
- end
15
- end
16
-
17
- def destroy
18
- @session = @survey.sessions.find_by id: params[:id]
19
- notify_successful_delete_for(@session.token) if @session.destroy
20
- respond_with @session, location: admin_survey_sessions_path(@survey)
21
- end
22
-
23
- private
24
-
25
- def load_survey
26
- @survey = Helena::Survey.find params['survey_id']
27
- end
28
-
29
- def add_breadcrumbs
30
- add_breadcrumb Helena::Survey.model_name.human(count: 2), :admin_surveys_path
31
- add_breadcrumb @survey.name, admin_survey_sessions_path(@survey)
32
- end
33
- end
34
- end
35
- end
@@ -1,78 +0,0 @@
1
- require_dependency 'helena/application_controller'
2
-
3
- module Helena
4
- module Admin
5
- class SurveysController < Admin::ApplicationController
6
- respond_to :html
7
-
8
- before_filter :add_breadcrumbs
9
- before_filter :load_survey, only: [:edit, :update, :move_up, :move_down, :destroy]
10
-
11
- def index
12
- @surveys = Helena::Survey.asc :position
13
- end
14
-
15
- def new
16
- add_breadcrumb t('helena.admin.surveys.new')
17
- @survey = Helena::Survey.new
18
- @survey.versions.build version: 0, survey_detail: Helena::SurveyDetail.new
19
- end
20
-
21
- def create
22
- add_breadcrumb t('helena.admin.surveys.new')
23
-
24
- @survey = Helena::Survey.new survey_params
25
-
26
- if @survey.save
27
- notify_successful_create_for(@survey.name)
28
- else
29
- notify_error
30
- end
31
- respond_with @survey, location: admin_surveys_path
32
- end
33
-
34
- def edit
35
- add_breadcrumb @survey.name
36
- end
37
-
38
- def update
39
- if @survey.update_attributes survey_params
40
- notify_successful_update_for(@survey.name)
41
- else
42
- notify_error @survey
43
- add_breadcrumb @survey.name_was
44
- end
45
- respond_with @survey, location: admin_surveys_path
46
- end
47
-
48
- def move_up
49
- @survey.move_to! :higher
50
- respond_with @survey, location: admin_surveys_path
51
- end
52
-
53
- def move_down
54
- @survey.move_to! :lower
55
- respond_with @survey, location: admin_surveys_path
56
- end
57
-
58
- def destroy
59
- notify_successful_delete_for(@survey.name) if @survey.destroy
60
- respond_with @survey, location: admin_surveys_path
61
- end
62
-
63
- private
64
-
65
- def add_breadcrumbs
66
- add_breadcrumb Helena::Survey.model_name.human(count: 2), :admin_surveys_path
67
- end
68
-
69
- def survey_params
70
- params.require(:survey).permit(:name, :tag_list, :language, versions_attributes: [:version, :id, survey_detail_attributes: [:title, :description]])
71
- end
72
-
73
- def load_survey
74
- @survey = Helena::Survey.find params[:id]
75
- end
76
- end
77
- end
78
- end
@@ -1,71 +0,0 @@
1
- require_dependency 'helena/application_controller'
2
-
3
- module Helena
4
- module Admin
5
- class VersionsController < Admin::ApplicationController
6
- respond_to :html
7
-
8
- before_filter :load_survey, :add_breadcrumbs
9
- before_filter :build_version, only: [:new, :create]
10
- before_filter :load_version, only: [:edit, :update]
11
-
12
- def index
13
- @versions = @survey.versions.without_base
14
- end
15
-
16
- def new
17
- end
18
-
19
- def create
20
- @version.update_attributes(version_params)
21
- @version.save
22
- notify_successful_create_for(@version.version)
23
- respond_with @version, location: admin_survey_versions_path(@survey)
24
- end
25
-
26
- def edit
27
- end
28
-
29
- def update
30
- @version.update_attributes version_params
31
- notify_successful_update_for(@version.version)
32
- respond_with @version, location: admin_survey_versions_path(@survey)
33
- end
34
-
35
- def destroy
36
- @version = @survey.versions.find_by id: params[:id]
37
- notify_successful_delete_for(@version.version) if @version.destroy && Helena::Session.where(version: @version).destroy
38
- respond_with @version, location: admin_survey_versions_path(@survey)
39
- end
40
-
41
- private
42
-
43
- def load_survey
44
- @survey = Helena::Survey.find(params[:survey_id])
45
- end
46
-
47
- def load_version
48
- @version = @survey.versions.find(params[:id])
49
- end
50
-
51
- def add_breadcrumbs
52
- add_breadcrumb Helena::Survey.model_name.human(count: 2), :admin_surveys_path
53
- add_breadcrumb @survey.name, admin_survey_versions_path(@survey)
54
- end
55
-
56
- def version_params
57
- params.require(:version).permit(:notes, :session_report)
58
- end
59
-
60
- def default_session_report
61
- render_to_string 'default_session_report', layout: false
62
- end
63
-
64
- def build_version
65
- base_version = @survey.versions.find_by(version: 0)
66
- @version = Helena::VersionPublisher.publish(base_version)
67
- @version.session_report = @survey.reload.versions.last.session_report || default_session_report
68
- end
69
- end
70
- end
71
- end
@@ -1,11 +0,0 @@
1
- require_dependency 'helena/application_controller'
2
-
3
- module Helena
4
- class SurveysController < ApplicationController
5
- respond_to :html, :json
6
-
7
- def index
8
- @surveys = Helena::Survey.all
9
- end
10
- end
11
- end
@@ -1,3 +0,0 @@
1
- = simple_form_for [:admin, @survey, @question_group] do |f|
2
- = f.input :title
3
- = f.submit t('shared.save'), class: 'btn btn-success'
@@ -1,3 +0,0 @@
1
- .helena-admin
2
- %h2= t 'shared.edit'
3
- = render 'form'
@@ -1,41 +0,0 @@
1
- .helena-admin
2
- %h2
3
- = Helena::QuestionGroup.model_name.human(count: 2)
4
- = "(#{@question_groups.count})"
5
- - if @question_groups.empty?
6
- .alert.alert-warning
7
- = t '.empty'
8
- - else
9
- .table-responsive
10
- %table.table.question_groups
11
- %thead
12
- %tr
13
- %th.position= Helena::QuestionGroup.human_attribute_name(:position)
14
- %th= Helena::QuestionGroup.human_attribute_name(:title)
15
- %th
16
- %tbody
17
- - @question_groups.each do |question_group|
18
- %tr[question_group]
19
- %td.position
20
- = question_group.position
21
- %td.title
22
- = question_group.title
23
- %td
24
- .btn-group.btn-group-sm
25
- - unless question_group.last?
26
- = link_to move_down_admin_survey_question_group_path(@survey, question_group), class: 'btn btn-primary',
27
- method: :patch,
28
- title: t('shared.move_down') do
29
- %i.glyphicon.glyphicon-chevron-down
30
- - unless question_group.first?
31
- = link_to move_up_admin_survey_question_group_path(@survey, question_group), class: 'btn btn-primary',
32
- method: :patch,
33
- title: t('shared.move_up') do
34
- %i.glyphicon.glyphicon-chevron-up
35
-
36
- = link_to t('shared.edit'), edit_admin_survey_question_group_path(@survey, question_group), class: 'btn btn-primary'
37
- = link_to Helena::Question.model_name.human(count: 2), admin_survey_question_group_questions_path(@survey, question_group), class: 'btn btn-primary'
38
- = link_to t('shared.delete'), admin_survey_question_group_path(@survey, question_group), method: :delete, class: 'btn btn-danger', data: { confirm: t('shared.delete_question') }
39
-
40
- %a.btn.btn-success{ href: new_admin_survey_question_group_path}
41
- = t '.add'
@@ -1,3 +0,0 @@
1
- .helena-admin
2
- %h2= t '.new'
3
- = render 'form'
@@ -1,15 +0,0 @@
1
- = simple_form_for [:admin, @survey, @question_group, @question] do |f|
2
- = f.input :question_text
3
- = f.input :code, hint: t('shared.code_hint')
4
- = f.input :_type, collection: Helena::Question::TYPES.map { |type| [type.model_name.human, type] }
5
- - if @question.respond_to? :required
6
- = f.input :required, as: :boolean
7
- - if @question.is_a?(Helena::Questions::LongText) || @question.is_a?(Helena::Questions::StaticText)
8
- = f.input :default_value
9
- - if @question.is_a?(Helena::Questions::ShortText)
10
- = f.input :default_value, as: :string
11
- - if @question.includes_labels?
12
- = render 'labels', form: f
13
- - if @question.includes_subquestions?
14
- = render 'sub_questions', form: f
15
- = f.submit t('shared.save'), class: 'btn btn-success'
@@ -1,24 +0,0 @@
1
- %h3= t '.labels'
2
- .table-responsive
3
- %table.table.labels
4
- %thead
5
- %tr
6
- %th.position= Helena::Label.human_attribute_name :position
7
- %th.preselected
8
- %th.text= Helena::Label.human_attribute_name :text
9
- %th.value= Helena::Label.human_attribute_name :value
10
- %th.delete
11
- %tbody
12
- = form.simple_fields_for :labels do |label|
13
- %tr[label.object]
14
- %td.position
15
- = label.input :position, as: :integer, label: false
16
- %td.preselected
17
- = label.input :preselected, as: :boolean, label: Helena::Label.human_attribute_name(:preselected)
18
- %td.text
19
- = label.input :text, label: false
20
- %td.value
21
- = label.input :value, label: false
22
- %td.delete
23
- - unless label.object.new_record?
24
- = label.input :_destroy, as: :boolean, label: Helena::Label.human_attribute_name(:_destroy)