myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2399] trunk/app: added sort options to group sha


From: noreply
Subject: [myexperiment-hackers] [2399] trunk/app: added sort options to group shared items tab
Date: Wed, 12 May 2010 08:38:50 -0400 (EDT)

Revision
2399
Author
dgc
Date
2010-05-12 08:38:49 -0400 (Wed, 12 May 2010)

Log Message

added sort options to group shared items tab

Modified Paths

Diff

Modified: trunk/app/controllers/networks_controller.rb (2398 => 2399)


--- trunk/app/controllers/networks_controller.rb	2010-05-05 14:35:03 UTC (rev 2398)
+++ trunk/app/controllers/networks_controller.rb	2010-05-12 12:38:49 UTC (rev 2399)
@@ -237,7 +237,51 @@
 
   # GET /networks/1
   def show
+
+    @item_sort_options = [
+      ["most_recent",   "Most recent"],
+      ["title",         "Title"],
+      ["uploader",      "Uploader"],
+      ["last_updated",  "Last updated"],
+      ["rating",        "Rating"],
+      ["license",       "License"],
+      ["workflow_type", "Workflow Type"]
+    ]
+
     @shared_items = @network.shared_contributions
+
+    case params[:item_sort]
+
+      when "title"; @shared_items.sort! do |a, b|
+        a.contributable.label <=> b.contributable.label
+      end
+
+      when "most_recent"; @shared_items.sort! do |a, b|
+        a.contributable.created_at <=> b.contributable.created_at
+      end
+
+      when "uploader"; @shared_items.sort! do |a, b|
+        a.contributor.label <=> b.contributor.label
+      end
+
+      when "last_updated"; @shared_items.sort! do |a, b|
+        a.contributable.updated_at <=> b.contributable.updated_at
+      end
+
+      when "rating"; @shared_items.sort! do |a, b|
+        b.contributable.rating <=> a.contributable.rating
+      end
+
+      when "license"; @shared_items.sort! do |a, b|
+        a.contributable.license.title <=> b.contributable.license.title
+      end
+
+      when "workflow_type"; @shared_items.sort! do |a, b|
+        a.contributable.content_type.title <=> b.contributable.content_type.title
+      end
+
+    end
+
     respond_to do |format|
       format.html # show.rhtml
     end

Modified: trunk/app/views/networks/show.rhtml (2398 => 2399)


--- trunk/app/views/networks/show.rhtml	2010-05-05 14:35:03 UTC (rev 2398)
+++ trunk/app/views/networks/show.rhtml	2010-05-12 12:38:49 UTC (rev 2399)
@@ -156,9 +156,19 @@
 <a name="shared_items"></a>
 <div class="tabContainer">
   <div class="tabTitle">Shared Items (<%= @shared_items.length -%>)</div>
-  <div class="tabContent">
+  <div class="tabContent" id="shared_items">
 		<% unless @shared_items.empty? %>
   		<%= view_privileges_notice %>
+
+      <div style="float: right; margin: 0.5em;">
+        Sort:
+        <select  = this.options[this.selectedIndex].value;">
+          <% @item_sort_options.each do |option, label| %>
+            <option value="?item_sort=<%= option -%>#shared_items" <% if params[:item_sort] == option -%> selected="selected"<% end -%>><%= label -%></option>
+          <% end %>
+        </select>
+      </div>
+
 			<%= render :partial => "contributions/table", :locals => { :collection => @shared_items } %>
 		<% else %>
 			<p class="none_text">No items have been shared with this Group yet.</p>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]