Files
danbooru/app/views/moderator/bulk_reverts/new.html.erb
evazion 4631262374 Fix broken tag autocomplete on multiple pages.
Mark all tag <input>s with a `data-autocomplete` attribute, instead of
hardcoding a list of html IDs to autocomplete in javascript.

This way should be less error prone. It fixes autocomplete in several places:

* Autocomplete for the search box on /posts didn't work in the
  responsive layout. This was because /posts has two search boxes that
  both have the id `tags`: one in the normal sidebar, and one in the
  responsive tag list. $("#tags") only initialized autocomplete on the
  first one.

* Autocomplete didn't work on the aliases or implications pages. This
  was due to selecting the wrong html ids.
2017-04-22 15:24:03 -05:00

100 lines
3.2 KiB
Plaintext

<div id="c-moderator-bulk-reverts">
<div id="a-new">
<h1>New Bulk Revert</h1>
<p>You must preview a bulk revert before processing it. Previews may take several minutes to generate.</p>
<%= form_tag(moderator_bulk_revert_path, :class => "simple_form") do %>
<div class="input">
<label>User Name</label>
<%= text_field :constraints, :user_name, :value => @constraints[:user_name] %>
</div>
<div class="input">
<label>Min Version Id</label>
<%= text_field :constraints, :min_version_id, :value => @constraints[:min_version_id] %>
</div>
<div class="input">
<label>Max Version Id</label>
<%= text_field :constraints, :max_version_id, :value => @constraints[:max_version_id] %>
</div>
<div class="input" id="added-tags-input">
<label>Added Tags</label>
<%= text_field :constraints, :added_tags, :value => @constraints[:added_tags], :data => { :autocomplete => "tag" } %>
<p class="hint">You must specify a user to add tags</p>
</div>
<div class="input" id="removed-tags-input">
<label>Removed Tags</label>
<%= text_field :constraints, :removed_tags, :value => @constraints[:removed_tags], :data => { :autocomplete => "tag" } %>
<p class="hint">You must specify a user to add tags</p>
</div>
<%= submit_tag "Test" %>
<% if params[:commit] == "Test" %>
<%= submit_tag %>
<% end %>
<% end %>
<% if @bulk_revert %>
<div>
<p>Preview limited to 200 changes</p>
<table class="striped" width="100%">
<thead>
<tr>
<th>Post</th>
<th>Date</th>
<th>User</th>
<th>Changes</th>
</tr>
</thead>
<tbody>
<% @bulk_revert.preview.limit(200).each do |post_version| %>
<tr>
<td><%= link_to("#{post_version.post_id}.#{post_version.id}", post_path(post_version.post_id)) %></td>
<td><%= compact_time(post_version.updated_at) %></td>
<td>
<% if post_version.updater %>
<%= link_to_user(post_version.updater) %>
<% end %>
</td>
<td><%= post_version_diff(post_version) %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
</div>
</div>
<% content_for(:page_title) do %>
New Bulk Revert - <%= Danbooru.config.app_name %>
<% end %>
<% content_for(:html_header) do %>
<%= javascript_tag do %>
$(function() {
if (!$("#constraints_user_name").val().length) {
$("#added-tags-input input").prop("disabled", true);
$("#removed-tags-input input").prop("disabled", true);
}
$("#constraints_user_name").keyup(function() {
if ($("#constraints_user_name").val().length) {
$("#added-tags-input input").prop("disabled", false);
$("#removed-tags-input input").prop("disabled", false);
} else {
$("#added-tags-input input").prop("disabled", true);
$("#removed-tags-input input").prop("disabled", true);
}
});
});
<% end %>
<% end %>