changeset 755:bde9c5bfb559 feature_14

created a new instance variable to be able to filter the projects: @filtered_projects. New projects index layout; new partials for projects index.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Fri, 11 Nov 2011 15:57:58 +0000
parents 51d6290d3027
children 18b0f6e6d7a8 687c9fbca255
files vendor/plugins/redmine_tags/app/views/projects/_filtered_projects.rhtml vendor/plugins/redmine_tags/app/views/projects/_my_projects.rhtml vendor/plugins/redmine_tags/app/views/projects/index.rhtml vendor/plugins/redmine_tags/config/locales/en.yml vendor/plugins/redmine_tags/lib/redmine_project_filtering.rb vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb
diffstat 7 files changed, 35 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_tags/app/views/projects/_filtered_projects.rhtml	Thu Nov 10 17:45:08 2011 +0000
+++ b/vendor/plugins/redmine_tags/app/views/projects/_filtered_projects.rhtml	Fri Nov 11 15:57:58 2011 +0000
@@ -1,19 +1,1 @@
-<% if @featured_projects && @featured_projects.any? %>
-
-  <div class="splitcontentleft">
-    <%= render_project_hierarchy_with_filtering(@projects, @custom_fields, @question) %>
-  </div>
-
-  <div class="splitcontentright">
-    <h3 id="featured-projects-title"><%=l(:project_filtering_featured_projects_label) %></h3>
-    <div id="featured-projects-box" class="box">
-      <%= render_project_hierarchy_with_filtering(@featured_projects, @custom_fields, @question) %>
-    </div>
-  </div>
-
-<% else %>
-
-  <%= render_project_hierarchy_with_filtering(@projects, @custom_fields, @question) %>
-
-<% end %>
-
+<%= render_project_table_with_filtering(@filtered_projects, @question) %>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_tags/app/views/projects/_my_projects.rhtml	Fri Nov 11 15:57:58 2011 +0000
@@ -0,0 +1,8 @@
+<fieldset id="filters" class="collapsible">
+    <legend onclick="toggleFieldset(this);"><%= l(:label_my_projects) %></legend>
+    <% if @user_projects %>  
+    <div>
+      <%= render_my_project_hierarchy(@user_projects)%>
+    </div>
+  <% end %>
+</fieldset>
\ No newline at end of file
--- a/vendor/plugins/redmine_tags/app/views/projects/index.rhtml	Thu Nov 10 17:45:08 2011 +0000
+++ b/vendor/plugins/redmine_tags/app/views/projects/index.rhtml	Fri Nov 11 15:57:58 2011 +0000
@@ -7,6 +7,15 @@
     <%= '| ' + link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %>
 </div>
 
+
+
+<div style="clear:both;"></div>
+<% if User.current.logged? %>
+  <%= render :partial => 'my_projects' %>
+<% end %>
+
+
+<div style="clear:both;"></div>
 <% form_tag('/projects', :method => :get, :id => :project_filtering) do %>
   <fieldset id="filters" class="collapsible">
     <legend onclick="toggleFieldset(this);"><%= l(:label_filter_plural) %></legend>
@@ -16,43 +25,23 @@
         <%= text_field_tag 'q', @question, :size => 30, :id => 'search-input' %>
       </p>
 
-      <p class='buttons'><%= submit_tag( l(:button_send), :id => 'filter_button') -%></p>
-
       <div id='filter_tags'>
         <%= render :partial => 'filter_tags' %>
       </div>
-            
-      <%= link_to_remote('Submit', :url => { :controller => :projects, :action => :index, :format => :js }, :method => :get, :class => 'buttons') %>
-      
+
+      <p class='buttons'><%= submit_tag( l('button_filter'), :id => 'filter_button') -%></p>                  
     </div>
   </fieldset>
 <% end %>
 
-<div id="projects">
-  <%= render :partial => 'filtered_projects' %>
-</div>
-
-
 <div style="clear:both;"></div>
-
-<% if User.current.logged? %>
-<p style="text-align:right;">
-<span class="my-project"><%= l(:label_my_projects) %></span>
-</p>
-<% end %>
-
-
-END
-
-<% if @user_projects %>  
-  <%= render_my_project_hierarchy(@user_projects)%>
-<% end %>
-
 <h2>
   <%= l("label_project_all") %>
 </h2>
 
-<%= render_project_table_with_filtering(@projects, @question) %>
+<div id="projects">
+  <%= render :partial => 'filtered_projects' %>
+</div>
 
 <p class="pagination"><%= pagination_links_full @project_pages, @project_count %></p>
 
--- a/vendor/plugins/redmine_tags/config/locales/en.yml	Thu Nov 10 17:45:08 2011 +0000
+++ b/vendor/plugins/redmine_tags/config/locales/en.yml	Fri Nov 11 15:57:58 2011 +0000
@@ -35,3 +35,4 @@
   auto_complete_new_tag: Add new...
   
   project_filtering_q_label: "Textual search"
+  button_filter: "Filter"
--- a/vendor/plugins/redmine_tags/lib/redmine_project_filtering.rb	Thu Nov 10 17:45:08 2011 +0000
+++ b/vendor/plugins/redmine_tags/lib/redmine_project_filtering.rb	Fri Nov 11 15:57:58 2011 +0000
@@ -3,7 +3,6 @@
   # transforms a question and a list of custom fields into something that Project.search can process
   def self.calculate_tokens(question, custom_fields=nil)
     list = []
-    list << custom_fields.values if custom_fields.present?
     list << question if question.present?
 
     tokens = list.join(' ').scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)})
--- a/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb	Thu Nov 10 17:45:08 2011 +0000
+++ b/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb	Fri Nov 11 15:57:58 2011 +0000
@@ -25,10 +25,10 @@
           end
         end
 
-        # luisf - TO BE REMOVED?
-        def calculate_project_filtering_settings
-          @project_filtering_settings = Setting[:plugin_redmine_project_filtering]
-        end
+        # # luisf - TO BE REMOVED?
+        # def calculate_project_filtering_settings
+        #   @project_filtering_settings = Setting[:plugin_redmine_project_filtering]
+        # end
 
         def filter_projects
           @project = Project.new
@@ -53,7 +53,7 @@
 
         private
 
-        def calculate_filtered_projects
+        def calculate_filtered_projects                  
           @question = (params[:q] || "").strip     
 
           if params.has_key?(:project)
@@ -70,13 +70,12 @@
           @projects = @projects.search_by_question(@question) unless @question == ""
           @tagged_projects_ids = Project.tagged_with(@tag_list).collect{ |project| Project.find(project.id) } unless @tag_list.empty?
 
+          debugger
+
           # intersection of both prject groups            
           @projects = @projects && @tagged_projects_ids unless @tag_list.empty?
-
-          # luisf: what exactly are the featured projects? could they be "my projects"?
-          #        if not should remove this code…
-          @featured_projects = @featured_projects.search_by_question(@question) if @featured_projects
-
+          
+          @filtered_projects = @projects
         end
       end
     end
--- a/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb	Thu Nov 10 17:45:08 2011 +0000
+++ b/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb	Fri Nov 11 15:57:58 2011 +0000
@@ -19,6 +19,8 @@
         # general activity level, whether there is anything actually hosted
         # here for the project, etc.
         def render_project_table_with_filtering(projects, question)
+          debugger
+          
           custom_fields = ""
           s = ""
           if projects.any?