myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [2471] branches/discovery: search filters option,


From: noreply
Subject: [myexperiment-hackers] [2471] branches/discovery: search filters option, breadcrumb bar, curved borders for mozilla
Date: Tue, 13 Jul 2010 10:08:53 -0400 (EDT)

Revision
2471
Author
dgc
Date
2010-07-13 10:08:52 -0400 (Tue, 13 Jul 2010)

Log Message

search filters option, breadcrumb bar, curved borders for mozilla

Modified Paths

Added Paths

Diff

Modified: branches/discovery/app/controllers/application.rb (2470 => 2471)


--- branches/discovery/app/controllers/application.rb	2010-07-13 14:07:26 UTC (rev 2470)
+++ branches/discovery/app/controllers/application.rb	2010-07-13 14:08:52 UTC (rev 2471)
@@ -433,14 +433,15 @@
         }
       ],
 
-      :num_options => ["10", "20", "25", "50", "100"],
+      :num_options => ['10', '20', '25', '50', '100'],
 
       :filters =>
       [
         {
-          :option    => "type",
-          :column    => "contributions.contributable_type",
-          :title     => 'category',
+          :title        => 'category',
+          :query_option => 'type',
+          :id_column    => 'contributions.contributable_type',
+          :label_column => 'contributions.contributable_type',
           :select    => 'contributions.contributable_type, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
           :group     => 'contributions.contributable_type',
           :order     => 'COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) DESC',
@@ -450,10 +451,11 @@
         },
 
         {
-          :option    => "content_type",
-          :column    => "content_types.id",
-          :joins     => [ :content_types ],
-          :title     => 'type',
+          :title        => 'type',
+          :query_option => 'content_type',
+          :id_column    => 'content_types.id',
+          :label_column => 'content_types.title',
+          :joins        => [ :content_types ],
           :select    => 'content_types.id, content_types.title, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
           :condition => 'contributions.content_type_id IS NOT NULL',
           :group     => 'content_types.id',
@@ -464,10 +466,11 @@
         },
 
         {
-          :option    => "tag",
-          :column    => "tags.id",
-          :joins     => [ :taggings, :tags ],
-          :title     => 'tag',
+          :title        => 'tag',
+          :query_option => 'tag',
+          :id_column    => 'tags.id',
+          :label_column => 'tags.name',
+          :joins        => [ :taggings, :tags ],
           :select    => 'tags.id, tags.name, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
           :group     => 'tags.id',
           :order     => 'COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) DESC, tags.name',
@@ -477,10 +480,11 @@
         },
 
         {
-          :option    => "member",
-          :column    => "users.id",
-          :joins     => [ :users ],
-          :title     => 'user',
+          :title        => 'user',
+          :query_option => 'member',
+          :id_column    => 'users.id',
+          :label_column => 'users.name',
+          :joins        => [ :users ],
           :select    => 'users.id, users.name, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
           :group     => 'users.name',
           :order     => 'COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) DESC',
@@ -490,10 +494,11 @@
         },
 
         {
-          :option    => "license",
-          :column    => "licenses.id",
-          :joins     => [ :licences ],
-          :title     => 'licence',
+          :title        => 'licence',
+          :query_option => 'license',
+          :id_column    => 'licenses.id',
+          :label_column => 'licenses.unique_name',
+          :joins        => [ :licences ],
           :select    => 'licenses.id, licenses.unique_name, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
           :condition => 'contributions.license_id IS NOT NULL',
           :group     => 'licenses.id',
@@ -504,10 +509,11 @@
         },
 
         {
-          :option    => "network",
-          :column    => "networks.id",
-          :joins     => [ :networks ],
-          :title     => "group",
+          :title        => 'group',
+          :query_option => 'network',
+          :id_column    => 'networks.id',
+          :label_column => 'networks.title',
+          :joins        => [ :networks ],
           :select    => 'networks.id, networks.title, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
           :group     => 'networks.id',
           :order     => 'COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) DESC',
@@ -517,10 +523,11 @@
         },
 
         {
-          :option    => "curation_event",
-          :column    => "curation_events.category",
-          :joins     => [ :curation_events ],
-          :title     => "curation",
+          :title        => 'curation',
+          :query_option => 'curation_event',
+          :id_column    => 'curation_events.category',
+          :label_column => 'curation_events.category',
+          :joins        => [ :curation_events ],
           :select    => 'curation_events.category, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
           :group     => 'curation_events.category',
           :order     => 'COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) DESC',
@@ -528,19 +535,6 @@
           :key       => 'curation_event',
           :value     => 'x.category'
         },
-
-#       {
-#         :option    => "attribution",
-#         :column    => "attribution_targets.label",
-#         :joins     => [ :attributions, :attribution_targets ],
-#         :title     => "attribution",
-#         :select    => 'attribution_targets.label, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS count',
-#         :group     => 'attribution_targets.contributable_type, attribution_targets.contributable_id',
-#         :order     => 'COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) DESC',
-#         :label     => 'x.label',
-#         :key       => 'attribution',
-#         :value     => 'x.label'
-#       },
       ],
 
       :joins =>
@@ -582,8 +576,8 @@
     conditions = []
 
     pivot_options[:filters].each do |filter|
-      if filter_list = params[filter[:option]]
-        conditions << comparison(filter[:column], filter_list)
+      if filter_list = params[filter[:query_option]]
+        conditions << comparison(filter[:id_column], filter_list)
         joins += filter[:joins] if filter[:joins]
       end
     end
@@ -610,18 +604,30 @@
 
     # produce a query hash to match the current filters
 
-    query_hash = {}
+    filter_params       = {}
+    filter_query_params = {}
+    order_params        = {}
 
     pivot_options[:filters].each do |filter|
-      if params[filter[:option]]
-        query_hash[filter[:option]] = params[filter[:option]]
+      if params[filter[:query_option]]
+        filter_params[filter[:query_option]] = params[filter[:query_option]]
       end
     end
 
+    order_params[:order] = params[:order] if params[:order]
+    
+    filter_query_params[:filter_query] = params[:filter_query] if params[:filter_query]
+
     # produce the filter list
 
     filters = pivot_options[:filters].clone
+    cancel_filter_query_url = nil
+    reset_filters_url = nil
 
+    if filter_params.length > 0
+      reset_filters_url = order_params
+    end
+
     filters.each do |filter|
 
       # apply all the joins and conditions except for the current filter
@@ -630,8 +636,8 @@
       conditions = []
 
       pivot_options[:filters].each do |other_filter|
-        if filter_list = params[other_filter[:option]]
-          conditions << comparison(other_filter[:column], filter_list) unless other_filter == filter
+        if filter_list = params[other_filter[:query_option]]
+          conditions << comparison(other_filter[:id_column], filter_list) unless other_filter == filter
           joins += other_filter[:joins] if other_filter[:joins]
         end
       end
@@ -639,6 +645,12 @@
       joins += filter[:joins] if filter[:joins]
       conditions << filter[:condition] if filter[:condition]
 
+      if params[:filter_query]
+        conditions << "(#{filter[:label_column]} LIKE '%#{escape_sql(params[:filter_query])}%')"
+
+        cancel_filter_query_url = request.query_parameters.merge( { "filter_query" => nil } )
+      end
+
       filter[:current] = params[filter[:key]] ? params[filter[:key]].split(',') : []
 
       filter[:objects] = Authorization.authorised_index(Contribution,
@@ -664,7 +676,7 @@
 
             new_selection = nil if new_selection.empty?
 
-            target_uri = content_path(query_hash.merge(filter[:key] => new_selection, "page" => nil))
+            target_uri = content_path(filter_params.merge(order_params).merge(filter_query_params).merge(filter[:key] => new_selection, "page" => nil))
 
             {
               :object => object,
@@ -688,7 +700,27 @@
       end
     end
 
-    [results, filters, nil]
+    # produce the summary
+
+    summary = ""
+
+    filters.select do |filter|
+      if params[filter[:query_option]]
+        summary << '<span class="filter-in-use"><a href="" +
+        url_for(filter_params.merge(filter_query_params).merge(order_params).merge( { filter[:query_option] => nil } )) +
+        '">' + filter[:title].capitalize + ": " + params[filter[:query_option]] +
+        " <img src='' /></a></span> "
+      end
+    end
+
+    {
+      :results                 => results,
+      :filters                 => filters,
+      :reset_filters_url       => reset_filters_url,
+      :cancel_filter_query_url => cancel_filter_query_url,
+      :filter_query_url        => filter_params,
+      :summary                 => summary
+    }
   end
+end
 
-end

Modified: branches/discovery/app/controllers/content_controller.rb (2470 => 2471)


--- branches/discovery/app/controllers/content_controller.rb	2010-07-13 14:07:26 UTC (rev 2470)
+++ branches/discovery/app/controllers/content_controller.rb	2010-07-13 14:08:52 UTC (rev 2471)
@@ -11,7 +11,7 @@
     respond_to do |format|
       format.html do
         @pivot_options = pivot_options
-        @contributions, @filters, @summary = contributions_list(Contribution, params, current_user)
+        @pivot = contributions_list(Contribution, params, current_user)
         # index.rhtml
       end
 #     format.rss do

Modified: branches/discovery/app/controllers/workflows_controller.rb (2470 => 2471)


--- branches/discovery/app/controllers/workflows_controller.rb	2010-07-13 14:07:26 UTC (rev 2470)
+++ branches/discovery/app/controllers/workflows_controller.rb	2010-07-13 14:08:52 UTC (rev 2471)
@@ -167,8 +167,7 @@
     respond_to do |format|
       format.html do
         @pivot_options = pivot_options
-        @contributions, @filters, @summary = contributions_list(Contribution, { "type" => "Workflow" }, current_user)
-        render 'content/index'
+        @pivot = contributions_list(Contribution, params.merge({ "type" => "Workflow" }), current_user)
       end
       format.rss do
         address@hidden = Workflow.find(:all, :order => "updated_at DESC") # list all (if required)

Modified: branches/discovery/app/views/content/_index.rhtml (2470 => 2471)


--- branches/discovery/app/views/content/_index.rhtml	2010-07-13 14:07:26 UTC (rev 2470)
+++ branches/discovery/app/views/content/_index.rhtml	2010-07-13 14:08:52 UTC (rev 2471)
@@ -1,10 +1,29 @@
-<%= render :partial => "layouts/paginate", :locals => { :collection => @contributions, :sort_by => @pivot_options[:order] } %>
+<%= render :partial => "layouts/paginate", :locals => { :collection => @pivot[:results], :sort_by => @pivot_options[:order] } %>
 
+<% if @pivot[:reset_filters_url] %>
+  <div style="float: left; padding: 1em"><%= link_to("Reset filters", @pivot[:reset_filters_url]) -%></div>
+<% end %>
+
 <div style="clear: both"></div>
 
 <div>
+
+  <form action="" url_for(request.query_parameters) -%>" method="GET">
+    <input name="filter_query" value="<%= params[:filter_query] -%>" style="width: 100px" />
+    <% @pivot[:filter_query_url].each do |key, value| %>
+      <input name="<%= key -%>" type="hidden" value="<%= value.sub('"', '\\"') -%>" />
+    <% end %>
+      
+  </form>
+
+  <div>
+    <% if @pivot[:cancel_filter_query_url] %>
+      <%= link_to("Cancel filter query", @pivot[:cancel_filter_query_url]) -%>
+    <% end %>
+  </div>
+
   <div class="pivot">
-    <% @filters.each do |filter| %>
+    <% @pivot[:filters].each do |filter| %>
       <div class="category">Filter by <%= filter[:title] -%></div>
 
       <div class="filter">
@@ -20,8 +39,13 @@
     <% end %>
   </div>
 
-  <%= render :partial => "contributions/list", :locals => { :collection => @contributions, :table => true } %>
+  <div class="pivot-summary">
+    <div>Showing <%= @pivot[:results].size -%> results</div>
+    <div class="pivot-filters-in-use"><%= @pivot[:summary] -%></div>
+  </div>
 
+  <%= render :partial => "contributions/list", :locals => { :collection => @pivot[:results], :table => true } %>
+
 </div>
 
 <div style="clear: left"></div>
@@ -29,5 +53,5 @@
 <%= _javascript__include_tag "ellipsis.js" %>
 <script>truncate_spans()</script>
 
-<%= render :partial => "layouts/paginate", :locals => { :collection => @contributions, :sort_by => @pivot_options[:order], :num_options => @pivot_options[:num_options] } %>
+<%= render :partial => "layouts/paginate", :locals => { :collection => @pivot[:results], :sort_by => @pivot_options[:order], :num_options => @pivot_options[:num_options] } %>
 

Modified: branches/discovery/app/views/content/index.rhtml (2470 => 2471)


--- branches/discovery/app/views/content/index.rhtml	2010-07-13 14:07:26 UTC (rev 2470)
+++ branches/discovery/app/views/content/index.rhtml	2010-07-13 14:08:52 UTC (rev 2471)
@@ -1,2 +1,4 @@
+<h1>All content</h1>
+
 <%= render :partial => "content/index" -%>
 

Added: branches/discovery/app/views/workflows/index.rhtml (0 => 2471)


--- branches/discovery/app/views/workflows/index.rhtml	                        (rev 0)
+++ branches/discovery/app/views/workflows/index.rhtml	2010-07-13 14:08:52 UTC (rev 2471)
@@ -0,0 +1,4 @@
+<h1>Workflows</h1>
+
+<%= render :partial => "content/index" -%>
+

Modified: branches/discovery/public/stylesheets/styles.css (2470 => 2471)


--- branches/discovery/public/stylesheets/styles.css	2010-07-13 14:07:26 UTC (rev 2470)
+++ branches/discovery/public/stylesheets/styles.css	2010-07-13 14:08:52 UTC (rev 2471)
@@ -2046,6 +2046,7 @@
   padding: 2px;
   background: #f0f0f0;
   border-radius: 6px;
+  -moz-border-radius: 6px;
 }
 
 DIV.pivot DIV.category {
@@ -2064,11 +2065,15 @@
 DIV.pivot DIV.options > DIV:first-child {
   border-top-left-radius: 6px;
   border-top-right-radius: 6px;
+  -moz-border-radius-topleft: 6px;
+  -moz-border-radius-topright: 6px;
 }
 
 DIV.pivot DIV.options > DIV:last-child {
   border-bottom-left-radius: 6px;
   border-bottom-right-radius: 6px;
+  -moz-border-radius-bottomleft: 6px;
+  -moz-border-radius-bottomright: 6px;
 }
 
 DIV.pivot DIV.options > DIV:hover {
@@ -2083,6 +2088,14 @@
   background: #dfc0a0;
 }
  
+DIV.pivot-summary {
+  margin-left: 160px;
+  background: #f0f0f0;
+  border: 1px solid #d8d8d8;
+  margin-bottom: 0.5em;
+  padding: 0.2em;
+}
+
 .pivot-title {
   font-size: 120%;
   text-align: center;
@@ -2098,6 +2111,32 @@
   float: right;
 }
 
+DIV.pivot-filters-in-use {
+  margin-top: 0.5em;
+  width: 577px;
+}
+
+SPAN.filter-in-use {
+  background: #e0e0e0;
+  border: 1px solid #d0d0d0;
+  padding: 2px;
+	line-height: 180%;
+}
+
+SPAN.filter-in-use A {
+  text-decoration: none; /* no underline */
+}
+
+SPAN.filter-in-use A IMG {
+  vertical-align: middle;
+}
+
+SPAN.filter-in-use:hover {
+  border: 1px solid #d0a0a0;
+  padding: 2px;
+  background: #f0d0d0;
+}
+
 .truncate {
   white-space: nowrap;
 }

reply via email to

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