diff --git a/app/controllers/admin/site_controller.rb b/app/controllers/admin/site_controller.rb index a01ce1024..7573f76c1 100644 --- a/app/controllers/admin/site_controller.rb +++ b/app/controllers/admin/site_controller.rb @@ -30,6 +30,9 @@ def index def a11; end + def a11_v2_collections + end + def heartbeat render json: { status: :success, @@ -40,7 +43,7 @@ def heartbeat def invite # /views/admin/site/invite.html.erb end - + def invite_post invitee = invite_params[:refer_user] diff --git a/app/controllers/admin/submissions_controller.rb b/app/controllers/admin/submissions_controller.rb index 343f54c9c..3cc6b4405 100644 --- a/app/controllers/admin/submissions_controller.rb +++ b/app/controllers/admin/submissions_controller.rb @@ -3,22 +3,22 @@ module Admin class SubmissionsController < AdminController before_action :ensure_admin, only: %i[ - feed + feed export_feed ] before_action :set_form, except: %i[ - feed + feed export_feed ] before_action :set_submission, except: %i[ - feed - export_feed - search - a11_chart - a11_analysis - responses_per_day - responses_by_status - performance_gov + feed + export_feed + search + a11_chart + a11_analysis + responses_per_day + responses_by_status + performance_gov submissions_table ] @@ -65,6 +65,7 @@ def unflag def add_tag @submission.tag_list.add(admin_submission_params[:tag_list].split(',')) @submission.save! + @submission.form.update_submission_tags!(@submission.tag_list) end def remove_tag @@ -98,12 +99,12 @@ def performance_gov def submissions_table @show_archived = true if params[:archived] - @all_submissions = @form.submissions - @all_submissions = @all_submissions.tagged_with(params[:tag]) if params[:tag] + all_submissions = @form.submissions + all_submissions = all_submissions.tagged_with(params[:tag]) if params[:tag] if params[:archived] - @submissions = @all_submissions.order('submissions.created_at DESC').page params[:page] + @submissions = all_submissions.order('submissions.created_at DESC').page params[:page] else - @submissions = @all_submissions.non_archived.order('submissions.created_at DESC').page params[:page] + @submissions = all_submissions.non_archived.order('submissions.created_at DESC').page params[:page] end end diff --git a/app/models/form.rb b/app/models/form.rb index a81f1e5d0..3c845c8e7 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -108,6 +108,23 @@ def short_uuid uuid[0..7] end + # used to initially set tags (or reset them, if necessary) + def set_submission_tags! + submission_tags = submissions.collect(&:tags).uniq.sort_by { |i| i.name } + self.update!(submission_tags: submission_tags) + end + + # called when a tag is added to a submission + def update_submission_tags!(tag_list) + submission_tags = (self.submission_tags + tag_list).uniq.sort + self.update!(submission_tags: submission_tags) + end + + # lazily called from a view when a tag is used to search, but returns 0 results + def remove_submission_tag!(tag) + self.update!(submission_tags: submission_tags - [tag]) + end + aasm do state :in_development, initial: true state :live # manual @@ -260,6 +277,9 @@ def to_a11_v2_csv(start_date: nil, end_date: nil) attributes = fields_for_export + answer_02_options = self.questions.where(answer_field: "answer_02").first.question_options.collect(&:value) + answer_03_options = self.questions.where(answer_field: "answer_03").first.question_options.collect(&:value) + CSV.generate(headers: true) do |csv| csv << header_attributes @@ -267,21 +287,21 @@ def to_a11_v2_csv(start_date: nil, end_date: nil) csv << [ submission.id, submission.answer_01, - submission.answer_02 && submission.answer_02.split(",").include?("effectiveness") ? 1 : 0, - submission.answer_02 && submission.answer_02.split(",").include?("ease") ? 1 : 0, - submission.answer_02 && submission.answer_02.split(",").include?("efficiency") ? 1 : 0, - submission.answer_02 && submission.answer_02.split(",").include?("transparency") ? 1 : 0, - submission.answer_02 && submission.answer_02.split(",").include?("humanity") ? 1 : 0, - submission.answer_02 && submission.answer_02.split(",").include?("employee") ? 1 : 0, - submission.answer_02 && submission.answer_02.split(",").include?("other") ? 1 : 0, - - submission.answer_03 && submission.answer_03.split(",").include?("effectiveness") ? 1 : 0, - submission.answer_03 && submission.answer_03.split(",").include?("ease") ? 1 : 0, - submission.answer_03 && submission.answer_03.split(",").include?("efficiency") ? 1 : 0, - submission.answer_03 && submission.answer_03.split(",").include?("transparency") ? 1 : 0, - submission.answer_03 && submission.answer_03.split(",").include?("humanity") ? 1 : 0, - submission.answer_03 && submission.answer_03.split(",").include?("employee") ? 1 : 0, - submission.answer_03 && submission.answer_03.split(",").include?("other") ? 1 : 0, + submission.answer_02 && submission.answer_02.split(",").include?("effectiveness") ? 1 :(answer_02_options.include?("effectiveness") ? 0 : 'null'), + submission.answer_02 && submission.answer_02.split(",").include?("ease") ? 1 : (answer_02_options.include?("ease") ? 0 : 'null'), + submission.answer_02 && submission.answer_02.split(",").include?("efficiency") ? 1 : (answer_02_options.include?("efficiency") ? 0 : 'null'), + submission.answer_02 && submission.answer_02.split(",").include?("transparency") ? 1 : (answer_02_options.include?("transparency") ? 0 : 'null'), + submission.answer_02 && submission.answer_02.split(",").include?("humanity") ? 1 : (answer_02_options.include?("humanity") ? 0 : 'null'), + submission.answer_02 && submission.answer_02.split(",").include?("employee") ? 1 : (answer_02_options.include?("employee") ? 0 : 'null'), + submission.answer_02 && submission.answer_02.split(",").include?("other") ? 1 : (answer_02_options.include?("other") ? 0 : 'null'), + + submission.answer_03 && submission.answer_03.split(",").include?("effectiveness") ? 1 : (answer_03_options.include?("effectiveness") ? 0 : 'null'), + submission.answer_03 && submission.answer_03.split(",").include?("ease") ? 1 : (answer_03_options.include?("ease") ? 0 : 'null'), + submission.answer_03 && submission.answer_03.split(",").include?("efficiency") ? 1 : (answer_03_options.include?("efficiency") ? 0 : 'null'), + submission.answer_03 && submission.answer_03.split(",").include?("transparency") ? 1 : (answer_03_options.include?("transparency") ? 0 : 'null'), + submission.answer_03 && submission.answer_03.split(",").include?("humanity") ? 1 : (answer_03_options.include?("humanity") ? 0 : 'null'), + submission.answer_03 && submission.answer_03.split(",").include?("employee") ? 1 : (answer_03_options.include?("employee") ? 0 : 'null'), + submission.answer_03 && submission.answer_03.split(",").include?("other") ? 1 : (answer_03_options.include?("other") ? 0 : 'null'), submission.answer_04 ] diff --git a/app/views/admin/question_options/update.js.erb b/app/views/admin/question_options/update.js.erb index fd000acb0..e50c721f9 100644 --- a/app/views/admin/question_options/update.js.erb +++ b/app/views/admin/question_options/update.js.erb @@ -1,7 +1,7 @@ <% if @question_option.question.question_type == "radio_buttons" %> <% @form_component_path = "components/forms/edit/question_types/radio_button_option" %> <% elsif @question_option.question.question_type == "icon_checkboxes" %> - <% @form_component_path = "components/forms/question_types/icon_radio_button_option" %> + <% @form_component_path = "components/forms/edit/question_types/checkbox_option" %> <% elsif @question_option.question.question_type == "thumbs_up_down_buttons" %> <% @form_component_path = 'components/forms/question_types/thumbs_up_down_buttons' %> <% elsif @question_option.question.question_type == "dropdown" %> diff --git a/app/views/admin/site/a11_v2_collections.html.erb b/app/views/admin/site/a11_v2_collections.html.erb new file mode 100644 index 000000000..3de67c2d2 --- /dev/null +++ b/app/views/admin/site/a11_v2_collections.html.erb @@ -0,0 +1,82 @@ + +
+ + + + +