first attempt of making favorite people view sortable

This commit is contained in:
Pfingstfrosch 2020-05-16 13:30:00 +02:00
parent dd7ac8e64f
commit 83d4368af7
3 changed files with 54 additions and 18 deletions

View File

@ -23,3 +23,7 @@
background-color: #009688; background-color: #009688;
} }
} }
.thumb {
width: 3em;
}

View File

@ -1,7 +1,8 @@
class FavoritesController < ApplicationController class FavoritesController < ApplicationController
def people def people
@favoritePeople = FavoritePerson.where('user_id': current_user.id) @favorite_people = FavoritePerson.where('user_id': current_user.id)
.order(params[:sort])
@host = 'https://tiss.tuwien.ac.at' @host = 'https://tiss.tuwien.ac.at'
end end

View File

@ -1,25 +1,56 @@
<%= render(:partial => "nav")%> <%= render(:partial => "nav") %>
<h1>Favorite People</h1> <h1>Favorite People</h1>
<ul class="people-list"> <!--<ul class="people-list">-->
<% @favoritePeople.each do |person| %> <%# @favorite_people.each do |person| %>
<li class="person"> <!-- <li class="person">-->
<%= link_to crawlers_people_crawler_show_detail_url(:tiss_id => person['tiss_id']) do %> <%#= link_to crawlers_people_crawler_show_detail_url(:tiss_id => person['tiss_id']) do %>
<span class="list-link"> <!-- <span class="list-link">-->
<span class="person-icon"> <!-- <span class="person-icon">-->
<%# if person['picture_uri'] != nil %>
<%#= image_tag @host + person['picture_uri'] %>
<%# else %>
<%#= show_svg('account_circle-black-48dp.svg') %>
<%# end %>
<!-- </span>-->
<!-- <span class="person-name">-->
<%#= person['first_name'] %>
<%#= person['last_name'] %>
<!-- </span>-->
<!-- </span>-->
<%# end %>
<!-- </li>-->
<%# end %>
<!--</ul>-->
<table>
<tr>
<th>Thumb</th>
<th><%= link_to "First Name", :sort => "first_name" %></th>
<th><%= link_to "Last Name", :sort => "last_name" %></th>
<th><%= link_to "Registration Date", :sort => "created_at" %></th>
</tr>
<% for person in @favorite_people %>
<tr>
<td>
<span>
<% if person['picture_uri'] != nil %> <% if person['picture_uri'] != nil %>
<%= image_tag @host + person['picture_uri'] %> <%= image_tag @host + person['picture_uri'], class: 'thumb'%>
<% else %> <% else %>
<%= show_svg('account_circle-black-48dp.svg') %> <%= show_svg('account_circle-black-48dp.svg')%>
<% end %> <% end %>
</span> </span>
<span class="person-name"> </td>
<td>
<%= person['first_name'] %> <%= person['first_name'] %>
</td>
<td>
<%= person['last_name'] %> <%= person['last_name'] %>
</span> </td>
</span> <td>
<%= person['created_at'] %>
</td>
</tr>
<% end %> <% end %>
</li> </table>
<% end %>
</ul>