Merge pull request #2053 from consul/officing-voter-message

Officing voter message
This commit is contained in:
Raimond Garcia
2017-10-13 15:30:49 +02:00
committed by GitHub
10 changed files with 59 additions and 45 deletions

View File

@@ -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

View File

@@ -605,6 +605,7 @@ table {
.callout {
height: $line-height * 2;
line-height: $line-height * 2;
margin: 0;
padding: 0 $line-height / 2;
}
}

View File

@@ -1,7 +1,8 @@
<div class="row">
<div class="small-12 medium-8 column">
<div class="callout alert text-center">
<strong><%= t("officing.voters.show.error_already_voted") %></strong>
</div>
</div>
</div>
<td>
<p class="callout alert text-center">
<strong><%= t("officing.voters.show.error_already_voted") %></strong>
</p>
</td>
<td class="text-center">
<small><%= t("officing.voters.show.no_actions") %></small>
</td>

View File

@@ -1,14 +1,16 @@
<div class="row">
<div class="small-12 medium-6 large-4 column">
<div class="callout success text-center">
<strong><%= t("officing.voters.show.can_vote") %></strong>
</div>
</div>
<div class="small-12 medium-6 large-4 column end">
<%= form_for @user, as: :voter, url: officing_voters_path, method: :post, remote: true do |f| %>
<td class="text-center">
<p id="can_vote_callout" class="callout success">
<strong><%= t("officing.voters.show.can_vote") %></strong>
</p>
</td>
<td id="actions" class="text-center">
<%= 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 %>
</div>
</div>
<%= f.submit t("officing.voters.show.submit"),
class: "button success",
data: { disable_with: t("officing.voters.can_vote.submit_disable_with") } %>
<% end %>
</td>

View File

@@ -1,7 +1,3 @@
<div class="row">
<div class="small-12 medium-8 column">
<div class="callout primary text-center">
<strong><%= t("officing.voters.show.success") %></strong>
</div>
</div>
</div>
<span class="lead text-center">
<strong><%= t("officing.voters.show.success") %></strong>
</span>

View File

@@ -1 +1,2 @@
$("#<%= dom_id(@poll) %> #actions").html('<%= j render("voted") %>');
$("#<%= dom_id(@poll) %> #actions").html('<%= j render("voted") %>');
$("#<%= dom_id(@poll) %> #can_vote_callout").hide();

View File

@@ -7,7 +7,8 @@
<thead>
<tr>
<th><%= t("officing.voters.new.table_poll") %></th>
<th><%= t("officing.voters.new.table_actions") %></th>
<th><%= t("officing.voters.new.table_status") %></th>
<th class="text-center"><%= t("officing.voters.new.table_actions") %></th>
</tr>
</thead>
<tbody>
@@ -16,15 +17,13 @@
<td>
<%= poll.name %>
</td>
<td id="actions">
<% if poll.votable_by?(@user) %>
<%= render "can_vote", poll: poll %>
<% else %>
<%= render "already_voted" %>
<% end %>
</td>
<% if poll.votable_by?(@user) %>
<%= render "can_vote", poll: poll %>
<% else %>
<%= render "already_voted" %>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% end %>

View File

@@ -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..."

View File

@@ -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..."

View File

@@ -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")