This commit is contained in:
Toks
2014-11-26 19:04:35 -05:00
parent 60e1d1379d
commit 4d2898e545
2 changed files with 27 additions and 22 deletions

View File

@@ -2,7 +2,9 @@ class SavedSearchesController < ApplicationController
respond_to :html, :js
def index
@saved_searches = saved_searches.order("name")
@saved_searches = saved_searches.order("tag_query")
@categories = @saved_searches.group_by{|saved_search| saved_search.category.to_s}
@categories = @categories.sort_by{|category, saved_searches| category.to_s}
end
def create

View File

@@ -2,28 +2,31 @@
<div id="a-index">
<h1>Saved Searches</h1>
<table class="striped" width="100%">
<thead>
<tr>
<th width="80%">Tags</th>
<th width="10%">Category</th>
<th width="10%"></th>
</tr>
</thead>
<tbody>
<% @saved_searches.each do |saved_search| %>
<tr id="saved-search-<%= saved_search.id %>">
<td><%= link_to saved_search.tag_query, posts_path(:tags => saved_search.tag_query) %></td>
<td><%= saved_search.category %></td>
<td>
<%= link_to "edit", edit_saved_search_path(saved_search) %> |
<%= link_to "delete", saved_search_path(saved_search), :method => :delete, :remote => true %>
</td>
<% @categories.each do |category, saved_searches| %>
<h2><%= category.present? ? category : "Uncategorized" %></h2>
<table class="striped" width="100%">
<thead>
<tr>
<th width="80%">Tags</th>
<th width="10%">Category</th>
<th width="10%"></th>
</tr>
<% end %>
</tbody>
</table>
</thead>
<tbody>
<% saved_searches.each do |saved_search| %>
<tr id="saved-search-<%= saved_search.id %>">
<td><%= link_to saved_search.tag_query, posts_path(:tags => saved_search.tag_query) %></td>
<td><%= saved_search.category %></td>
<td>
<%= link_to "edit", edit_saved_search_path(saved_search) %> |
<%= link_to "delete", saved_search_path(saved_search), :method => :delete, :remote => true %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</div>
</div>