From 90fef761217fbab0f2d47d1400f05bd16d211c5f Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 4 Nov 2019 16:45:19 -0600 Subject: [PATCH] artists: reorganize index page. * Make other names searchable. * Add post count and update timestamp. * Add edit / delete / undelete links. --- app/controllers/artists_controller.rb | 2 + .../src/styles/specific/artists.scss | 6 ++ .../src/styles/specific/wiki_pages.scss | 4 +- app/views/artists/index.html.erb | 58 ++++++++++++++----- 4 files changed, 54 insertions(+), 16 deletions(-) diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index 910a4bc17..0f94226f8 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -38,6 +38,8 @@ class ArtistsController < ApplicationController def index @artists = Artist.includes(:urls).paginated_search(params) + @artists = @artists.includes(:tag) if request.format.html? + @artists = @artists.includes(:urls) if !request.format.html? if params[:redirect].to_s.truthy? && @artists.one? && @artists.first.name == Artist.normalize_name(params[:search][:any_name_or_url_matches]) redirect_to @artists.first diff --git a/app/javascript/src/styles/specific/artists.scss b/app/javascript/src/styles/specific/artists.scss index 6c0902074..ce112bc04 100644 --- a/app/javascript/src/styles/specific/artists.scss +++ b/app/javascript/src/styles/specific/artists.scss @@ -7,4 +7,10 @@ div#c-artists, div#excerpt { .recent-posts h2 { margin: 1em 0 0.5em; } + + div#a-index { + td { + height: 2.25em; /* should match .artist-other-name line-height */ + } + } } diff --git a/app/javascript/src/styles/specific/wiki_pages.scss b/app/javascript/src/styles/specific/wiki_pages.scss index 4c454e678..b06d0988f 100644 --- a/app/javascript/src/styles/specific/wiki_pages.scss +++ b/app/javascript/src/styles/specific/wiki_pages.scss @@ -1,5 +1,7 @@ -.wiki-other-name { +.artist-other-name, .wiki-other-name { background-color: var(--wiki-page-other-name-background-color); padding: 3px; + margin-right: 0.25em; + line-height: 2.25em; border-radius: 3px; } diff --git a/app/views/artists/index.html.erb b/app/views/artists/index.html.erb index ff7b6b647..60141ac94 100644 --- a/app/views/artists/index.html.erb +++ b/app/views/artists/index.html.erb @@ -1,27 +1,55 @@
<%= render "search" %> - + +
- - - + + + + + <% @artists.each do |artist| %> - <% if artist.visible? %> - <%= content_tag(:tr, :id => "artist-#{artist.id}") do %> - - - - <% end %> + <%= tag.tr id: "artist-#{artist.id}" do %> + + + + + <% end %> <% end %>
Primary NameSecondary NamesStatusNameOther NamesStatusUpdated
- <%= link_to h(artist.name), artist_path(artist) %> - <% if !artist.group_name.blank? %> - (group: <%= link_to(artist.group_name, artist_path(artist)) %>) - <% end %> - <%= artist.other_names_string %><%= artist.status %> + <%= link_to artist.name, artist, class: "tag-type-#{Tag.categories.artist}" %> + <%= artist.tag.try(:post_count) || 0 %> + <% if !artist.group_name.blank? %> + (group: <%= link_to artist.group_name, artist %>) + <% end %> + + <% artist.other_names.each do |name| %> + <%= link_to name, artists_path(search: { any_name_matches: name }), class: "artist-other-name" %> + <% end %> + + <% if !artist.is_active? %> + <%= link_to "Deleted", artists_path(search: { is_active: false }) %> + <% end %> + + <% if artist.is_banned? %> + <%= link_to "Banned", artists_path(search: { is_banned: true }) %> + <% end %> + + <%= time_ago_in_words_tagged(artist.updated_at) %> + + <% if artist.editable_by?(CurrentUser.user) %> + <%= link_to "Edit", edit_artist_path(artist) %> + <% end %> + + <% if artist.is_active? && artist.deletable_by?(CurrentUser.user) %> + | <%= link_to "Delete", artist_path(artist, artist: { is_active: false }), method: :put, remote: true %> + <% elsif !artist.is_active? && artist.deletable_by?(CurrentUser.user) %> + | <%= link_to "Undelete", artist_path(artist, artist: { is_active: true }), method: :put, remote: true %> + <% end %> +