# HG changeset patch # User luisf # Date 1321027078 0 # Node ID bde9c5bfb5592ee7a02c049eb7d54b64a873a65f # Parent 51d6290d30275013e37b7d6659e76c9ec6420195 created a new instance variable to be able to filter the projects: @filtered_projects. New projects index layout; new partials for projects index. diff -r 51d6290d3027 -r bde9c5bfb559 vendor/plugins/redmine_tags/app/views/projects/_filtered_projects.rhtml --- 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? %> - -
- <%= render_project_hierarchy_with_filtering(@projects, @custom_fields, @question) %> -
- -
- - -
- -<% 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 diff -r 51d6290d3027 -r bde9c5bfb559 vendor/plugins/redmine_tags/app/views/projects/_my_projects.rhtml --- /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 @@ +
+ <%= l(:label_my_projects) %> + <% if @user_projects %> +
+ <%= render_my_project_hierarchy(@user_projects)%> +
+ <% end %> +
\ No newline at end of file diff -r 51d6290d3027 -r bde9c5bfb559 vendor/plugins/redmine_tags/app/views/projects/index.rhtml --- 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) %> + + +
+<% if User.current.logged? %> + <%= render :partial => 'my_projects' %> +<% end %> + + +
<% form_tag('/projects', :method => :get, :id => :project_filtering) do %>
<%= l(:label_filter_plural) %> @@ -16,43 +25,23 @@ <%= text_field_tag 'q', @question, :size => 30, :id => 'search-input' %>

-

<%= submit_tag( l(:button_send), :id => 'filter_button') -%>

-
<%= render :partial => 'filter_tags' %>
- - <%= link_to_remote('Submit', :url => { :controller => :projects, :action => :index, :format => :js }, :method => :get, :class => 'buttons') %> - + +

<%= submit_tag( l('button_filter'), :id => 'filter_button') -%>

<% end %> -
- <%= render :partial => 'filtered_projects' %> -
- -
- -<% if User.current.logged? %> -

-<%= l(:label_my_projects) %> -

-<% end %> - - -END - -<% if @user_projects %> - <%= render_my_project_hierarchy(@user_projects)%> -<% end %> -

<%= l("label_project_all") %>

-<%= render_project_table_with_filtering(@projects, @question) %> +
+ <%= render :partial => 'filtered_projects' %> +

<%= pagination_links_full @project_pages, @project_count %>

diff -r 51d6290d3027 -r bde9c5bfb559 vendor/plugins/redmine_tags/config/locales/en.yml --- 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" diff -r 51d6290d3027 -r bde9c5bfb559 vendor/plugins/redmine_tags/lib/redmine_project_filtering.rb --- 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+)}) diff -r 51d6290d3027 -r bde9c5bfb559 vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb --- 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 diff -r 51d6290d3027 -r bde9c5bfb559 vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb --- 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?