Focus the proposal selection switch after pressing it
Since this button is replaced by a new element in an AJAX call, nothing was focused after pressing it. So we're reusing the code we used to enable/disable budget phases, which already dealt with this issue.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
var replacement = $("<%= j render Admin::BudgetPhases::ToggleEnabledComponent.new(@phase) %>");
|
||||
var form = $("#<%= dom_id(@phase) %> .toggle-switch");
|
||||
|
||||
form.replaceWith(replacement);
|
||||
replacement.find("[type='submit']").focus();
|
||||
<%= render "admin/shared/toggle_switch",
|
||||
record: @phase,
|
||||
new_content: render(Admin::BudgetPhases::ToggleEnabledComponent.new(@phase)) %>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<td class="text-center"><%= proposal.id %></td>
|
||||
<td><%= proposal.title %></td>
|
||||
<td class="text-center"><%= proposal.votes_score %></td>
|
||||
<td class="select"><%= render Admin::Proposals::ToggleSelectionComponent.new(proposal) %></td>
|
||||
<td><%= render Admin::Proposals::ToggleSelectionComponent.new(proposal) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
$("#<%= dom_id(@proposal) %> .select").html(
|
||||
"<%= j render(Admin::Proposals::ToggleSelectionComponent.new(@proposal)) %>"
|
||||
);
|
||||
<%= render "admin/shared/toggle_switch",
|
||||
record: @proposal,
|
||||
new_content: render(Admin::Proposals::ToggleSelectionComponent.new(@proposal)) %>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<td><%= link_to proposal.title, admin_proposal_path(proposal) %></td>
|
||||
<td><%= proposal.author.username %></td>
|
||||
<td><%= proposal.milestones.count %></td>
|
||||
<td class="js-select"><%= render Admin::Proposals::ToggleSelectionComponent.new(proposal) %></td>
|
||||
<td><%= render Admin::Proposals::ToggleSelectionComponent.new(proposal) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
$("#<%= dom_id(@proposal) %> .js-select").html(
|
||||
"<%= j render(Admin::Proposals::ToggleSelectionComponent.new(@proposal)) %>"
|
||||
);
|
||||
<%= render "admin/shared/toggle_switch",
|
||||
record: @proposal,
|
||||
new_content: render(Admin::Proposals::ToggleSelectionComponent.new(@proposal)) %>
|
||||
|
||||
5
app/views/admin/shared/_toggle_switch.js.erb
Normal file
5
app/views/admin/shared/_toggle_switch.js.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
var new_toggle_switch = $("<%= j new_content %>");
|
||||
var current_toggle_switch = $("#<%= dom_id(record) %> .toggle-switch");
|
||||
|
||||
current_toggle_switch.replaceWith(new_toggle_switch);
|
||||
new_toggle_switch.find("[type='submit']").focus();
|
||||
Reference in New Issue
Block a user