fixes #3730
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
$("#related-tags-container").hide();
|
||||
$("#artist-tags-container").hide();
|
||||
$("#upload_tag_string,#post_tag_string").keyup(Danbooru.RelatedTag.update_selected);
|
||||
$("body").on("click", "#artist-related-tags-column a.del", Danbooru.RelatedTag.disable_artist_url)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,19 +237,26 @@
|
||||
if (desc.length > 30) {
|
||||
desc = desc.substring(0, 30) + "...";
|
||||
}
|
||||
var $del = $("<del/>").text(desc);
|
||||
$ul.append($("<li/>").html($del));
|
||||
$ul.append(
|
||||
$("<li>").append(
|
||||
$("<del>").text(desc)
|
||||
)
|
||||
);
|
||||
} else if (text.match(/^ http/)) {
|
||||
text = text.substring(1, 1000);
|
||||
var $url = $("<a/>");
|
||||
var desc = text.replace(/^https?:\/\//, "");
|
||||
if (desc.length > 30) {
|
||||
desc = desc.substring(0, 30) + "...";
|
||||
}
|
||||
$url.text(desc);
|
||||
$url.attr("href", text);
|
||||
$url.attr("target", "_blank");
|
||||
$ul.append($("<li/>").html($url));
|
||||
$ul.append(
|
||||
$("<li>").append([
|
||||
$("<a>").text(desc).attr("href", text).attr("target", "_blank"),
|
||||
" ",
|
||||
$("<a>").attr("href", text).addClass("del").append(
|
||||
$("<i>").addClass("fas fa-minus-circle")
|
||||
)
|
||||
])
|
||||
);
|
||||
} else {
|
||||
$ul.append($("<li/>").text(text));
|
||||
}
|
||||
@@ -286,7 +294,9 @@
|
||||
var url = $("#upload_source,#post_source");
|
||||
var referer_url = $("#upload_referer_url");
|
||||
$.get("/artists/finder.json", {"url": url.val(), "referer_url": referer_url.val()}, Danbooru.RelatedTag.process_artist);
|
||||
e.preventDefault();
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
Danbooru.RelatedTag.process_artist = function(data) {
|
||||
@@ -314,6 +324,28 @@
|
||||
$("#related-tags").hide();
|
||||
$("#toggle-related-tags-link").text("»");
|
||||
}
|
||||
|
||||
Danbooru.RelatedTag.disable_artist_url = function(e) {
|
||||
var url = e.currentTarget.href;
|
||||
console.log("clicked %o", url);
|
||||
$.each(Danbooru.RelatedTag.recent_artists[0].sorted_urls, function(k, v) {
|
||||
if (v["normalized_url"] === url || v["url"] === url) {
|
||||
if (!confirm("This will mark the URL as inactive. Continue?")) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax("/artist_urls/" + v["id"], {
|
||||
method: "PUT",
|
||||
data: {
|
||||
artist_url: {
|
||||
is_active: false
|
||||
}
|
||||
}
|
||||
}).done(Danbooru.RelatedTag.find_artist);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
|
||||
$(function() {
|
||||
|
||||
@@ -28,6 +28,11 @@ div.related-tags {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
svg {
|
||||
margin-top: 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
a {
|
||||
min-width: 3em;
|
||||
}
|
||||
|
||||
18
app/controllers/artist_urls_controller.rb
Normal file
18
app/controllers/artist_urls_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class ArtistUrlsController < ApplicationController
|
||||
respond_to :json
|
||||
before_action :member_only
|
||||
|
||||
def update
|
||||
@artist_url = ArtistUrl.find(params[:id])
|
||||
@artist_url.update(artist_url_params)
|
||||
respond_with(@artist_url)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def artist_url_params
|
||||
permitted_params = %i[is_active]
|
||||
|
||||
params.fetch(:artist_url, {}).permit(permitted_params)
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
class ArtistsController < ApplicationController
|
||||
respond_to :html, :xml, :json
|
||||
respond_to :html, :xml, :json, :js
|
||||
before_action :member_only, :except => [:index, :show, :show_or_new, :banned]
|
||||
before_action :builder_only, :only => [:destroy]
|
||||
before_action :admin_only, :only => [:ban, :unban]
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<% if @artist.is_active? %>
|
||||
<li id="artist-delete"><%= link_to "Delete", artist_path(@artist), method: :delete, data: {confirm: "Are you sure you want to delete this artist?"} %></li>
|
||||
<% else %>
|
||||
<li><%= link_to "Undelete", artist_path(@artist), method: :put, data: {confirm: "Are you sure you want to undelete this artist?", params: {"artist[is_active]" => true}} %></li>
|
||||
<li><%= link_to "Undelete", artist_path(@artist, format: "js"), method: :put, data: {confirm: "Are you sure you want to undelete this artist?", params: "artist[is_active]=true"}, remote: true %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if CurrentUser.is_admin? %>
|
||||
|
||||
1
app/views/artists/update.js.erb
Normal file
1
app/views/artists/update.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
location.reload();
|
||||
@@ -81,6 +81,7 @@ Rails.application.routes.draw do
|
||||
get :finder
|
||||
end
|
||||
end
|
||||
resources :artist_urls, only: [:update]
|
||||
resources :artist_versions, :only => [:index] do
|
||||
collection do
|
||||
get :search
|
||||
|
||||
Reference in New Issue
Block a user