From 5bdb3e72ac40f887aca8803a42b8ec785369b06a Mon Sep 17 00:00:00 2001 From: evazion Date: Tue, 28 Oct 2014 20:05:42 -0500 Subject: [PATCH] Link to artist entries for taken artist names. In artist entries, there is a Check link next to the name field that lets you check whether the name is already taken. When the name /is/ taken, you often want to check the other artist entries to see if you're creating a duplicate. This adds links to the other entries so you can check them more easily. --- app/assets/javascripts/artists.js | 15 +++++++++++---- app/assets/stylesheets/specific/artists.css.scss | 4 ++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/artists.js b/app/assets/javascripts/artists.js index 99e214461..9100ea0fd 100644 --- a/app/assets/javascripts/artists.js +++ b/app/assets/javascripts/artists.js @@ -55,11 +55,18 @@ } $.get("/artists.json?name=" + artist_name, - function(data) { - if (data.length) { - $("#check-name-result").html("Taken"); + function(artists) { + $("check-name-result").empty(); + + if (artists.length) { + $("#check-name-result").text("Taken: "); + + $.map(artists.slice(0, 5), function (artist) { + var link = $("").attr("href", "/artists/" + artist.id).text(artist.name); + $("#check-name-result").append(link); + }); } else { - $("#check-name-result").html("OK"); + $("#check-name-result").text("OK"); } } ); diff --git a/app/assets/stylesheets/specific/artists.css.scss b/app/assets/stylesheets/specific/artists.css.scss index f0d433eab..270e745f1 100644 --- a/app/assets/stylesheets/specific/artists.css.scss +++ b/app/assets/stylesheets/specific/artists.css.scss @@ -29,6 +29,10 @@ div#c-artists, div#excerpt { .hint { display: block; } + + #check-name-result a { + margin-right: 1em; + } } div.recent-posts {