Merge pull request #2645 from wairbut-m2c/admin-form-improvements-backport

Admin form improvements
This commit is contained in:
Alberto
2018-06-07 17:44:38 +02:00
committed by GitHub
15 changed files with 71 additions and 67 deletions

View File

@@ -711,15 +711,6 @@ table {
} }
} }
.legislation-process-index {
.legislation-process-new {
@include breakpoint(medium) {
text-align: right;
}
}
}
// 08. CMS // 08. CMS
// -------------- // --------------
.cms-page-list { .cms-page-list {

View File

@@ -60,7 +60,6 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
:draft_publication_enabled, :draft_publication_enabled,
:result_publication_enabled, :result_publication_enabled,
:published, :published,
:proposals_description,
:custom_list, :custom_list,
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
) )

View File

@@ -55,7 +55,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
end end
def manage def manage
@booths = ::Poll::Booth.all @booths = ::Poll::Booth.all.order(name: :asc).page(params[:page]).per(300)
@poll = Poll.find(params[:poll_id]) @poll = Poll.find(params[:poll_id])
end end

View File

@@ -55,7 +55,7 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController
private private
def question_params 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 end
def search_params def search_params

View File

@@ -4,7 +4,7 @@
<div class="row margin-top"> <div class="row margin-top">
<div class="small-12 medium-9 column"> <div class="small-12 medium-9 column">
<%= f.select :phase, budget_phases_select_options %> <%= f.select :phase, budget_phases_select_options, selected: "drafting" %>
</div> </div>
<div class="small-12 medium-3 column"> <div class="small-12 medium-3 column">
<%= f.select :currency_symbol, budget_currency_symbol_select_options %> <%= f.select :currency_symbol, budget_currency_symbol_select_options %>

View File

@@ -15,19 +15,6 @@
<% end %> <% end %>
<div class="row">
<div class="small-12 medium-4 column">
<%= label_tag t('admin.legislation.proposals.form.header_information') %>
<small><%= t('admin.legislation.proposals.form.header_information_description') %></small>
</div>
<div class="small-12 medium-8 column">
<%= f.text_area :proposals_description,
label: false,
rows: 5,
placeholder: t('admin.legislation.proposals.form.header_information_placeholder') %>
</div>
</div>
<div class="row"> <div class="row">
<div class="small-12 medium-4 column"> <div class="small-12 medium-4 column">
<%= label_tag t('admin.legislation.proposals.form.custom_categories') %> <%= label_tag t('admin.legislation.proposals.form.custom_categories') %>

View File

@@ -25,4 +25,6 @@
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
<%= paginate @booths %>
<% end %> <% end %>

View File

@@ -55,17 +55,6 @@
</div> </div>
</div> </div>
<% if controller_name == "polls" && action_name == "edit" %>
<div class="row">
<fieldset class="fieldset">
<legend><%= t('admin.polls.new.show_results_and_stats') %></legend>
<%= 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') %>
<p class="small"><%= t('admin.polls.new.results_and_stats_reminder') %></p>
</fieldset>
</div>
<% end %>
<div class="row"> <div class="row">
<div class="small-12 medium-4 column"> <div class="small-12 medium-4 column">
<%= f.submit t("admin.polls.#{admin_submit_action(@poll)}.submit_button"), <%= f.submit t("admin.polls.#{admin_submit_action(@poll)}.submit_button"),

View File

@@ -14,19 +14,6 @@
<%= f.text_field :title %> <%= f.text_field :title %>
<div class="small-12">
<%= f.label :video_url, t("proposals.form.proposal_video_url") %>
<p class="help-text" id="video-url-help-text">
<%= t("proposals.form.proposal_video_url_note") %>
</p>
<%= f.text_field :video_url,
placeholder: t("proposals.form.proposal_video_url"),
label: false,
aria: {describedby: "video-url-help-text"} %>
</div>
<div class="small-12 medium-6 large-4 margin-top"> <div class="small-12 medium-6 large-4 margin-top">
<%= f.submit(class: "button expanded", value: t("shared.save")) %> <%= f.submit(class: "button expanded", value: t("shared.save")) %>
</div> </div>

View File

@@ -0,0 +1,14 @@
<%= form_for [:admin, @poll], action: "update" do |f| %>
<fieldset class="fieldset">
<legend><%= t("admin.polls.new.show_results_and_stats") %></legend>
<%= 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") %>
<p class="small"><%= t("admin.polls.new.results_and_stats_reminder") %></p>
</fieldset>
<div class="small-12 medium-4 large-2">
<%= f.submit t("admin.polls.#{admin_submit_action(@poll)}.submit_button"),
class: "button success expanded" %>
</div>
<% end %>

View File

@@ -1,4 +1,5 @@
<%= render "/admin/poll/polls/poll_header" %> <%= render "/admin/poll/polls/poll_header" %>
<div id="poll-resources"> <div id="poll-resources">
<%= render "/admin/poll/polls/subnav" %> <%= render "/admin/poll/polls/subnav" %>
@@ -12,5 +13,6 @@
<%= render "recount", resource: @poll %> <%= render "recount", resource: @poll %>
<%= render "result" %> <%= render "result" %>
<%= render "results_by_booth" %> <%= render "results_by_booth" %>
<%= render "show_results", resource: @poll %>
<% end %> <% end %>
</div> </div>

View File

@@ -372,9 +372,6 @@ en:
title: Proposals title: Proposals
back: Back back: Back
form: 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: Categories
custom_categories_description: Categories that users can select creating the proposal. custom_categories_description: Categories that users can select creating the proposal.
draft_versions: draft_versions:

View File

@@ -372,9 +372,6 @@ es:
title: Propuestas title: Propuestas
back: Volver back: Volver
form: 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: Categorías
custom_categories_description: Categorías que el usuario puede seleccionar al crear la propuesta. custom_categories_description: Categorías que el usuario puede seleccionar al crear la propuesta.
draft_versions: draft_versions:

View File

@@ -83,25 +83,67 @@ feature 'Admin polls' do
expect(page).to have_css("img[alt='#{poll.image.title}']") 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_name", with: "Next Poll"
fill_in 'poll_ends_at', with: end_date.strftime("%d/%m/%Y") fill_in 'poll_ends_at', with: end_date.strftime("%d/%m/%Y")
check 'poll_results_enabled'
check 'poll_stats_enabled'
click_button "Update poll" click_button "Update poll"
expect(page).to have_content "Poll updated successfully" expect(page).to have_content "Poll updated successfully"
expect(page).to have_content "Next Poll" expect(page).to have_content "Next Poll"
expect(page).to have_content I18n.l(end_date.to_date) 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_stats_enabled', checked: true)
expect(page).to have_field('poll_results_enabled', checked: true)
end end
scenario 'Edit from index' do scenario 'Edit from index' do

View File

@@ -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 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.... people and restore freedom to the galaxy....
} }
video_url = "https://puppyvideos.com"
visit admin_questions_path visit admin_questions_path
click_link "Create question" click_link "Create question"
select 'Movies', from: 'poll_question_poll_id' select 'Movies', from: 'poll_question_poll_id'
fill_in 'poll_question_title', with: title fill_in 'poll_question_title', with: title
fill_in 'poll_question_video_url', with: video_url
click_button 'Save' click_button 'Save'
expect(page).to have_content(title) expect(page).to have_content(title)
expect(page).to have_content(video_url)
end end
scenario 'Create from successful proposal index' do scenario 'Create from successful proposal index' do