From 44b1eb929a490ed0c3e031ffb04b14a3c8efdc74 Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Fri, 18 May 2018 09:19:20 -0400 Subject: [PATCH 1/6] Move 'Show stats and results' form to Admin::Poll#results tab --- app/views/admin/poll/polls/_form.html.erb | 11 ---- .../admin/poll/results/_show_results.html.erb | 17 ++++++ app/views/admin/poll/results/index.html.erb | 2 + spec/features/admin/poll/polls_spec.rb | 58 ++++++++++++++++--- 4 files changed, 69 insertions(+), 19 deletions(-) create mode 100644 app/views/admin/poll/results/_show_results.html.erb diff --git a/app/views/admin/poll/polls/_form.html.erb b/app/views/admin/poll/polls/_form.html.erb index e802d1217..1a45b8097 100644 --- a/app/views/admin/poll/polls/_form.html.erb +++ b/app/views/admin/poll/polls/_form.html.erb @@ -55,17 +55,6 @@ - <% if controller_name == "polls" && action_name == "edit" %> -
-
- <%= t('admin.polls.new.show_results_and_stats') %> - <%= f.check_box :results_enabled, checked: @poll.results_enabled?, label: t('admin.polls.new.show_results') %> - <%= f.check_box :stats_enabled, checked: @poll.stats_enabled?, label: t('admin.polls.new.show_stats') %> -

<%= t('admin.polls.new.results_and_stats_reminder') %>

-
-
- <% end %> -
<%= f.submit t("admin.polls.#{admin_submit_action(@poll)}.submit_button"), diff --git a/app/views/admin/poll/results/_show_results.html.erb b/app/views/admin/poll/results/_show_results.html.erb new file mode 100644 index 000000000..30222a2bf --- /dev/null +++ b/app/views/admin/poll/results/_show_results.html.erb @@ -0,0 +1,17 @@ +<%= form_for [:admin, @poll], action: "update" do |f| %> +
+
+ <%= t("admin.polls.new.show_results_and_stats") %> + <%= f.check_box :results_enabled, checked: @poll.results_enabled?, label: t("admin.polls.new.show_results") %> + <%= f.check_box :stats_enabled, checked: @poll.stats_enabled?, label: t("admin.polls.new.show_stats") %> +

<%= t("admin.polls.new.results_and_stats_reminder") %>

+
+
+ +
+
+ <%= f.submit t("admin.polls.#{admin_submit_action(@poll)}.submit_button"), + class: "button success expanded" %> +
+
+<% end %> diff --git a/app/views/admin/poll/results/index.html.erb b/app/views/admin/poll/results/index.html.erb index 7f21e5452..6f1fbbe74 100644 --- a/app/views/admin/poll/results/index.html.erb +++ b/app/views/admin/poll/results/index.html.erb @@ -1,4 +1,5 @@ <%= render "/admin/poll/polls/poll_header" %> +
<%= render "/admin/poll/polls/subnav" %> @@ -12,5 +13,6 @@ <%= render "recount", resource: @poll %> <%= render "result" %> <%= render "results_by_booth" %> + <%= render "show_results", resource: @poll %> <% end %>
diff --git a/spec/features/admin/poll/polls_spec.rb b/spec/features/admin/poll/polls_spec.rb index 482d461cc..e7e4d6bba 100644 --- a/spec/features/admin/poll/polls_spec.rb +++ b/spec/features/admin/poll/polls_spec.rb @@ -83,25 +83,67 @@ feature 'Admin polls' do expect(page).to have_css("img[alt='#{poll.image.title}']") - expect(page).to have_css("#poll_results_enabled") - expect(page).to have_css("#poll_stats_enabled") - fill_in "poll_name", with: "Next Poll" fill_in 'poll_ends_at', with: end_date.strftime("%d/%m/%Y") - check 'poll_results_enabled' - check 'poll_stats_enabled' click_button "Update poll" expect(page).to have_content "Poll updated successfully" expect(page).to have_content "Next Poll" expect(page).to have_content I18n.l(end_date.to_date) + end - click_link "Edit poll" + scenario 'Enable stats and results' do + poll = create(:poll) + + booth_assignment_1 = create(:poll_booth_assignment, poll: poll) + booth_assignment_2 = create(:poll_booth_assignment, poll: poll) + booth_assignment_3 = create(:poll_booth_assignment, poll: poll) + + question_1 = create(:poll_question, poll: poll) + create(:poll_question_answer, title: 'Oui', question: question_1) + create(:poll_question_answer, title: 'Non', question: question_1) + + question_2 = create(:poll_question, poll: poll) + create(:poll_question_answer, title: "Aujourd'hui", question: question_2) + create(:poll_question_answer, title: 'Demain', question: question_2) + + [booth_assignment_1, booth_assignment_2, booth_assignment_3].each do |ba| + create(:poll_partial_result, + booth_assignment: ba, + question: question_1, + answer: 'Oui', + amount: 11) + + create(:poll_partial_result, + booth_assignment: ba, + question: question_2, + answer: 'Demain', + amount: 5) + end + + create(:poll_recount, + booth_assignment: booth_assignment_1, + white_amount: 21, + null_amount: 44, + total_amount: 66) + + visit admin_poll_results_path(poll) + + expect(page).to have_field('poll_stats_enabled', checked: false) + expect(page).to have_field('poll_results_enabled', checked: false) + + check 'poll_stats_enabled' + check 'poll_results_enabled' + + click_button 'Update poll' + + expect(page).to have_content('Poll updated successfully') + + click_link 'Results' - expect(page).to have_field('poll_results_enabled', checked: true) expect(page).to have_field('poll_stats_enabled', checked: true) - + expect(page).to have_field('poll_results_enabled', checked: true) end scenario 'Edit from index' do From 4c0deb0eca89a95bc4cd79f07785b24d5ce962f9 Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Fri, 18 May 2018 09:43:43 -0400 Subject: [PATCH 2/6] Remove `video_url` attr from Admin::Poll::Question form --- app/controllers/admin/poll/questions_controller.rb | 2 +- app/views/admin/poll/questions/_form.html.erb | 13 ------------- spec/features/admin/poll/questions_spec.rb | 3 --- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/app/controllers/admin/poll/questions_controller.rb b/app/controllers/admin/poll/questions_controller.rb index 64ecf4009..399c72788 100644 --- a/app/controllers/admin/poll/questions_controller.rb +++ b/app/controllers/admin/poll/questions_controller.rb @@ -55,7 +55,7 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController private def question_params - params.require(:poll_question).permit(:poll_id, :title, :question, :proposal_id, :video_url) + params.require(:poll_question).permit(:poll_id, :title, :question, :proposal_id) end def search_params diff --git a/app/views/admin/poll/questions/_form.html.erb b/app/views/admin/poll/questions/_form.html.erb index 17ebde59d..eeb38a405 100644 --- a/app/views/admin/poll/questions/_form.html.erb +++ b/app/views/admin/poll/questions/_form.html.erb @@ -14,19 +14,6 @@ <%= f.text_field :title %> -
- <%= f.label :video_url, t("proposals.form.proposal_video_url") %> - -

- <%= t("proposals.form.proposal_video_url_note") %> -

- - <%= f.text_field :video_url, - placeholder: t("proposals.form.proposal_video_url"), - label: false, - aria: {describedby: "video-url-help-text"} %> -
-
<%= f.submit(class: "button expanded", value: t("shared.save")) %>
diff --git a/spec/features/admin/poll/questions_spec.rb b/spec/features/admin/poll/questions_spec.rb index 4399e3e64..d499869b9 100644 --- a/spec/features/admin/poll/questions_spec.rb +++ b/spec/features/admin/poll/questions_spec.rb @@ -36,19 +36,16 @@ feature 'Admin poll questions' do Pursued by the Empire's sinister agents, Princess Leia races home aboard her starship, custodian of the stolen plans that can save her people and restore freedom to the galaxy.... } - video_url = "https://puppyvideos.com" visit admin_questions_path click_link "Create question" select 'Movies', from: 'poll_question_poll_id' fill_in 'poll_question_title', with: title - fill_in 'poll_question_video_url', with: video_url click_button 'Save' expect(page).to have_content(title) - expect(page).to have_content(video_url) end scenario 'Create from successful proposal index' do From 9a326d4987e68f804f8e5a4554233c5f21eee1b9 Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Fri, 18 May 2018 11:02:06 -0400 Subject: [PATCH 3/6] Use 'drafting' as default value when creating a new budget --- app/views/admin/budgets/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/budgets/_form.html.erb b/app/views/admin/budgets/_form.html.erb index f5ce6b027..c2aaced9b 100644 --- a/app/views/admin/budgets/_form.html.erb +++ b/app/views/admin/budgets/_form.html.erb @@ -4,7 +4,7 @@
- <%= f.select :phase, budget_phases_select_options %> + <%= f.select :phase, budget_phases_select_options, selected: "drafting" %>
<%= f.select :currency_symbol, budget_currency_symbol_select_options %> From f220c477c17743381987d77a38785ae6311de555 Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Fri, 18 May 2018 14:04:59 -0400 Subject: [PATCH 4/6] Remove `proposals_description` attr from Admin::Legislation::Processes module --- .../admin/legislation/processes_controller.rb | 1 - .../admin/legislation/proposals/_form.html.erb | 13 ------------- config/locales/en/admin.yml | 3 --- config/locales/es/admin.yml | 3 --- 4 files changed, 20 deletions(-) diff --git a/app/controllers/admin/legislation/processes_controller.rb b/app/controllers/admin/legislation/processes_controller.rb index 47c7c34c0..976318958 100644 --- a/app/controllers/admin/legislation/processes_controller.rb +++ b/app/controllers/admin/legislation/processes_controller.rb @@ -60,7 +60,6 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll :draft_publication_enabled, :result_publication_enabled, :published, - :proposals_description, :custom_list, documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] ) diff --git a/app/views/admin/legislation/proposals/_form.html.erb b/app/views/admin/legislation/proposals/_form.html.erb index dd12f9492..cca190440 100644 --- a/app/views/admin/legislation/proposals/_form.html.erb +++ b/app/views/admin/legislation/proposals/_form.html.erb @@ -15,19 +15,6 @@ <% end %> -
-
- <%= label_tag t('admin.legislation.proposals.form.header_information') %> - <%= t('admin.legislation.proposals.form.header_information_description') %> -
-
- <%= f.text_area :proposals_description, - label: false, - rows: 5, - placeholder: t('admin.legislation.proposals.form.header_information_placeholder') %> -
-
-
<%= label_tag t('admin.legislation.proposals.form.custom_categories') %> diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 0292df944..3f7c22af5 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -369,9 +369,6 @@ en: title: Proposals back: Back form: - header_information: Information header - header_information_description: Provide information about the proposals. This text will be displayed as an alert in the Proposals section inside this Process. Use Markdown to format the text. - header_information_placeholder: Add information for the proposals' header custom_categories: Categories custom_categories_description: Categories that users can select creating the proposal. draft_versions: diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 5d44c9a17..441bb23e6 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -369,9 +369,6 @@ es: title: Propuestas back: Volver form: - header_information: Encabezado de información - header_information_description: Proporciona información sobre el recorrido de las propuestas. Este texto se mostrará como una alerta en el encabezado de la sección de Propuestas dentro de este proceso. Usa Markdown para formatear el texto. - header_information_placeholder: Añade información para el encabezado de las las propuestas custom_categories: Categorías custom_categories_description: Categorías que el usuario puede seleccionar al crear la propuesta. draft_versions: From 2c3770229852cf0b8c1ff7b0c64ffa68e2f268a2 Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Fri, 18 May 2018 14:44:16 -0400 Subject: [PATCH 5/6] Sort booths by name and enable pagination --- app/controllers/admin/poll/booth_assignments_controller.rb | 2 +- app/views/admin/poll/booth_assignments/manage.html.erb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/poll/booth_assignments_controller.rb b/app/controllers/admin/poll/booth_assignments_controller.rb index c90eb9cac..ea1f2f28f 100644 --- a/app/controllers/admin/poll/booth_assignments_controller.rb +++ b/app/controllers/admin/poll/booth_assignments_controller.rb @@ -55,7 +55,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController end def manage - @booths = ::Poll::Booth.all + @booths = ::Poll::Booth.all.order(name: :asc).page(params[:page]).per(300) @poll = Poll.find(params[:poll_id]) end diff --git a/app/views/admin/poll/booth_assignments/manage.html.erb b/app/views/admin/poll/booth_assignments/manage.html.erb index a24fac478..b7d619c71 100644 --- a/app/views/admin/poll/booth_assignments/manage.html.erb +++ b/app/views/admin/poll/booth_assignments/manage.html.erb @@ -25,4 +25,6 @@ <% end %> + + <%= paginate @booths %> <% end %> From 608f1996ce9eaa397ee32592bc84967795985cf5 Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 23 May 2018 12:00:07 +0200 Subject: [PATCH 6/6] Fixes admin layout --- app/assets/stylesheets/admin.scss | 9 -------- .../admin/poll/results/_show_results.html.erb | 23 ++++++++----------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index 5538a2c59..00b05706d 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -698,15 +698,6 @@ table { } } -.legislation-process-index { - - .legislation-process-new { - @include breakpoint(medium) { - text-align: right; - } - } -} - // 08. CMS // -------------- .cms-page-list { diff --git a/app/views/admin/poll/results/_show_results.html.erb b/app/views/admin/poll/results/_show_results.html.erb index 30222a2bf..e607f4779 100644 --- a/app/views/admin/poll/results/_show_results.html.erb +++ b/app/views/admin/poll/results/_show_results.html.erb @@ -1,17 +1,14 @@ <%= form_for [:admin, @poll], action: "update" do |f| %> -
-
- <%= t("admin.polls.new.show_results_and_stats") %> - <%= f.check_box :results_enabled, checked: @poll.results_enabled?, label: t("admin.polls.new.show_results") %> - <%= f.check_box :stats_enabled, checked: @poll.stats_enabled?, label: t("admin.polls.new.show_stats") %> -

<%= t("admin.polls.new.results_and_stats_reminder") %>

-
-
+
+ <%= t("admin.polls.new.show_results_and_stats") %> + <%= f.check_box :results_enabled, checked: @poll.results_enabled?, label: t("admin.polls.new.show_results") %> + <%= f.check_box :stats_enabled, checked: @poll.stats_enabled?, label: t("admin.polls.new.show_stats") %> +

<%= t("admin.polls.new.results_and_stats_reminder") %>

+
-
-
- <%= f.submit t("admin.polls.#{admin_submit_action(@poll)}.submit_button"), - class: "button success expanded" %> -
+ +
+ <%= f.submit t("admin.polls.#{admin_submit_action(@poll)}.submit_button"), + class: "button success expanded" %>
<% end %>