From ad85619ccc1937dab35f299bc1022eed2f635de5 Mon Sep 17 00:00:00 2001 From: Pfingstfrosch Date: Sun, 31 May 2020 16:45:22 +0200 Subject: [PATCH] added sorting arrow for favorites view --- app/assets/stylesheets/favorites.scss | 1 + app/helpers/favorites_helper.rb | 11 +++++++++ app/views/favorites/_th.html.erb | 4 ++++ app/views/favorites/courses.html.erb | 4 ++-- app/views/favorites/people.html.erb | 32 +++++---------------------- app/views/favorites/projects.html.erb | 4 ++-- app/views/favorites/theses.html.erb | 4 ++-- 7 files changed, 27 insertions(+), 33 deletions(-) create mode 100644 app/views/favorites/_th.html.erb diff --git a/app/assets/stylesheets/favorites.scss b/app/assets/stylesheets/favorites.scss index bd69da6..75ab2c7 100644 --- a/app/assets/stylesheets/favorites.scss +++ b/app/assets/stylesheets/favorites.scss @@ -44,6 +44,7 @@ width: 100%; } + tr:nth-child(odd) { th, td { //padding: 8px; diff --git a/app/helpers/favorites_helper.rb b/app/helpers/favorites_helper.rb index d8e38d2..ec16b80 100644 --- a/app/helpers/favorites_helper.rb +++ b/app/helpers/favorites_helper.rb @@ -3,4 +3,15 @@ module FavoritesHelper direction = column == sort_column && sort_direction == 'asc' ? 'desc' : 'asc' link_to title, :sort => column, :direction => direction end + + def sorting_arrow(column) + if sort_column == column + direction = column == sort_column && sort_direction == 'asc' ? 'desc' : 'asc' + if direction == 'asc' + image_tag 'up.png' + else + image_tag 'down.png' + end + end + end end diff --git a/app/views/favorites/_th.html.erb b/app/views/favorites/_th.html.erb new file mode 100644 index 0000000..88a154c --- /dev/null +++ b/app/views/favorites/_th.html.erb @@ -0,0 +1,4 @@ + + <%= sortable display, column %> + <%= sorting_arrow column %> + \ No newline at end of file diff --git a/app/views/favorites/courses.html.erb b/app/views/favorites/courses.html.erb index 5b84196..8cd46c6 100644 --- a/app/views/favorites/courses.html.erb +++ b/app/views/favorites/courses.html.erb @@ -6,8 +6,8 @@
- - + <%= render :partial => "favorites/th", :locals => {:display => "Title", :column => "title"} %> + <%= render :partial => "favorites/th", :locals => {:display => "Registration Date", :column => "created_at"} %> <% for course in @favorite_courses %> diff --git a/app/views/favorites/people.html.erb b/app/views/favorites/people.html.erb index fd0b596..8cc6b07 100644 --- a/app/views/favorites/people.html.erb +++ b/app/views/favorites/people.html.erb @@ -2,36 +2,14 @@

Favorite People

- - <%# @favorite_people.each do |person| %> - - <%#= link_to crawlers_people_crawler_show_detail_url(:tiss_id => person['tiss_id']) do %> - - - <%# if person['picture_uri'] != nil %> - <%#= image_tag @host + person['picture_uri'] %> - <%# else %> - <%#= show_svg('account_circle-black-48dp.svg') %> - <%# end %> - - - <%#= person['first_name'] %> - <%#= person['last_name'] %> - - - <%# end %> - - <%# end %> - - <% if !@favorite_people[0].blank? %>
<%= sortable "Title", "title" %><%= sortable "Registration Date", "created_at" %>
- - - + <%= render :partial => "favorites/th", :locals => {:display => "First Name", :column => "first_name"} %> + <%= render :partial => "favorites/th", :locals => {:display => "Last Name", :column => "last_name"} %> + <%= render :partial => "favorites/th", :locals => {:display => "Registration Date", :column => "created_at"} %> <% for person in @favorite_people %> @@ -39,9 +17,9 @@ <%= link_to crawlers_people_crawler_show_detail_url(:tiss_id => person['tiss_id']) do %> <% if person['picture_uri'] != nil %> - <%= image_tag @host + person['picture_uri'], class: 'thumb'%> + <%= image_tag @host + person['picture_uri'], class: 'thumb' %> <% else %> - <%= show_svg('account_circle-black-48dp.svg')%> + <%= show_svg('account_circle-black-48dp.svg') %> <% end %> <% end %> diff --git a/app/views/favorites/projects.html.erb b/app/views/favorites/projects.html.erb index 8d85a90..99e3a97 100644 --- a/app/views/favorites/projects.html.erb +++ b/app/views/favorites/projects.html.erb @@ -6,8 +6,8 @@
<%= sortable "First Name", "first_name" %><%= sortable "Last Name", "last_name" %><%= sortable "Registration Date", "created_at" %>
- - + <%= render :partial => "favorites/th", :locals => {:display => "Title", :column => "title"} %> + <%= render :partial => "favorites/th", :locals => {:display => "Registration Date", :column => "created_at"} %> <% for project in @favorite_projects %> diff --git a/app/views/favorites/theses.html.erb b/app/views/favorites/theses.html.erb index 4bf8327..4383348 100644 --- a/app/views/favorites/theses.html.erb +++ b/app/views/favorites/theses.html.erb @@ -6,8 +6,8 @@
<%= sortable "Title", "title" %><%= sortable "Registration Date", "created_at" %>
- - + <%= render :partial => "favorites/th", :locals => {:display => "Title", :column => "title"} %> + <%= render :partial => "favorites/th", :locals => {:display => "Registration Date", :column => "created_at"} %> <% for thesis in @favorite_theses %>
<%= sortable "Title", "title" %><%= sortable "Registration Date", "created_at" %>