diff --git a/app/assets/javascripts/prevent_double_submission.js.coffee b/app/assets/javascripts/prevent_double_submission.js.coffee index 2a4ef9c5e..abb8f8314 100644 --- a/app/assets/javascripts/prevent_double_submission.js.coffee +++ b/app/assets/javascripts/prevent_double_submission.js.coffee @@ -22,11 +22,13 @@ App.PreventDoubleSubmission = initialize: -> $('form').on('submit', (event) -> - buttons = $(this).find(':button, :submit') - App.PreventDoubleSubmission.disable_buttons(buttons) + unless event.target.id == "new_officing_voter" + buttons = $(this).find(':button, :submit') + App.PreventDoubleSubmission.disable_buttons(buttons) ).on('ajax:success', -> - buttons = $(this).find(':button, :submit') - App.PreventDoubleSubmission.reset_buttons(buttons) + unless event.target.id == "new_officing_voter" + buttons = $(this).find(':button, :submit') + App.PreventDoubleSubmission.reset_buttons(buttons) ) false diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index 8f6912716..85997aecd 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -605,6 +605,7 @@ table { .callout { height: $line-height * 2; line-height: $line-height * 2; + margin: 0; padding: 0 $line-height / 2; } } diff --git a/app/views/officing/voters/_already_voted.html.erb b/app/views/officing/voters/_already_voted.html.erb index 1476913f9..1af002b3f 100644 --- a/app/views/officing/voters/_already_voted.html.erb +++ b/app/views/officing/voters/_already_voted.html.erb @@ -1,7 +1,8 @@ -
-
-
- <%= t("officing.voters.show.error_already_voted") %> -
-
-
+ +

+ <%= t("officing.voters.show.error_already_voted") %> +

+ + + <%= t("officing.voters.show.no_actions") %> + diff --git a/app/views/officing/voters/_can_vote.html.erb b/app/views/officing/voters/_can_vote.html.erb index 27c5e9dbc..0d01f97fe 100644 --- a/app/views/officing/voters/_can_vote.html.erb +++ b/app/views/officing/voters/_can_vote.html.erb @@ -1,14 +1,16 @@ -
-
-
- <%= t("officing.voters.show.can_vote") %> -
-
-
- <%= form_for @user, as: :voter, url: officing_voters_path, method: :post, remote: true do |f| %> + +

+ <%= t("officing.voters.show.can_vote") %> +

+ + + <%= form_for @user, as: :voter, url: officing_voters_path, + method: :post, remote: true, + html: { id: "new_officing_voter" } do |f| %> <%= f.hidden_field :poll_id, value: poll.id %> <%= f.hidden_field :user_id, value: @user.id %> - <%= f.submit t("officing.voters.show.submit"), class: "button success expanded" %> - <% end %> -
-
+ <%= f.submit t("officing.voters.show.submit"), + class: "button success", + data: { disable_with: t("officing.voters.can_vote.submit_disable_with") } %> + <% end %> + diff --git a/app/views/officing/voters/_voted.html.erb b/app/views/officing/voters/_voted.html.erb index edd098403..49d1523a6 100644 --- a/app/views/officing/voters/_voted.html.erb +++ b/app/views/officing/voters/_voted.html.erb @@ -1,7 +1,3 @@ -
-
-
- <%= t("officing.voters.show.success") %> -
-
-
+ + <%= t("officing.voters.show.success") %> + diff --git a/app/views/officing/voters/create.js.erb b/app/views/officing/voters/create.js.erb index ee280faa2..3837f017e 100644 --- a/app/views/officing/voters/create.js.erb +++ b/app/views/officing/voters/create.js.erb @@ -1 +1,2 @@ -$("#<%= dom_id(@poll) %> #actions").html('<%= j render("voted") %>'); \ No newline at end of file +$("#<%= dom_id(@poll) %> #actions").html('<%= j render("voted") %>'); +$("#<%= dom_id(@poll) %> #can_vote_callout").hide(); \ No newline at end of file diff --git a/app/views/officing/voters/new.html.erb b/app/views/officing/voters/new.html.erb index 0f8fa2958..a6ab32d33 100644 --- a/app/views/officing/voters/new.html.erb +++ b/app/views/officing/voters/new.html.erb @@ -7,7 +7,8 @@ <%= t("officing.voters.new.table_poll") %> - <%= t("officing.voters.new.table_actions") %> + <%= t("officing.voters.new.table_status") %> + <%= t("officing.voters.new.table_actions") %> @@ -16,15 +17,13 @@ <%= poll.name %> - - <% if poll.votable_by?(@user) %> - <%= render "can_vote", poll: poll %> - <% else %> - <%= render "already_voted" %> - <% end %> - + <% if poll.votable_by?(@user) %> + <%= render "can_vote", poll: poll %> + <% else %> + <%= render "already_voted" %> + <% end %> <% end %> -<% end %> \ No newline at end of file +<% end %> diff --git a/config/locales/en/officing.yml b/config/locales/en/officing.yml index 378b87b15..bb9ef6bd2 100644 --- a/config/locales/en/officing.yml +++ b/config/locales/en/officing.yml @@ -58,9 +58,13 @@ en: new: title: Polls table_poll: Poll - table_actions: Polls status + table_status: Polls status + table_actions: Actions show: can_vote: Can vote error_already_voted: Has already participated in this poll + no_actions: There is no available actions submit: Confirm vote success: "Vote introduced!" + can_vote: + submit_disable_with: "Wait, confirming vote..." diff --git a/config/locales/es/officing.yml b/config/locales/es/officing.yml index 354b59710..86d6982fc 100644 --- a/config/locales/es/officing.yml +++ b/config/locales/es/officing.yml @@ -58,9 +58,13 @@ es: new: title: Votaciones table_poll: Votación - table_actions: Estado de las votaciones + table_status: Estado de las votaciones + table_actions: Acciones show: can_vote: Puede votar - error_already_voted: "Ya ha participado en esta votación." + error_already_voted: "Ya ha participado en esta votación" + no_actions: No hay acciones disponibles submit: Confirmar voto success: "¡Voto introducido!" + can_vote: + submit_disable_with: "Espera, confirmando voto..." \ No newline at end of file diff --git a/spec/features/polls/voter_spec.rb b/spec/features/polls/voter_spec.rb index 256807928..334696768 100644 --- a/spec/features/polls/voter_spec.rb +++ b/spec/features/polls/voter_spec.rb @@ -51,8 +51,12 @@ feature "Voter" do expect(page).to have_content poll.name - first(:button, "Confirm vote").click - expect(page).to have_content "Vote introduced!" + within("#poll_#{poll.id}") do + click_button("Confirm vote") + expect(page).to_not have_button("Confirm vote") + expect(page).to have_button('Wait, confirming vote...', disabled: true) + expect(page).to have_content "Vote introduced!" + end expect(Poll::Voter.count).to eq(1) expect(Poll::Voter.first.origin).to eq("booth")