Mercurial > hg > soundsoftware-site
changeset 1254:a54ce736229d redmine-2.2-integration
simplifying the seach/tag filtering. Not filtering by tag name at the moment.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Fri, 05 Apr 2013 18:29:23 +0100 |
parents | 29dd06e01be3 |
children | 90d92ad3fc59 |
files | plugins/redmine_tags/app/views/projects/index.html.erb plugins/redmine_tags/assets/javascripts/projects_index.js plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb |
diffstat | 4 files changed, 71 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/redmine_tags/app/views/projects/index.html.erb Fri Apr 05 15:07:40 2013 +0100 +++ b/plugins/redmine_tags/app/views/projects/index.html.erb Fri Apr 05 18:29:23 2013 +0100 @@ -15,8 +15,8 @@ </h2> <div style="clear:both;"></div> - <%= form_tag(:controller => :projects, :action => :index, :method => :get, :html => {:id => :project_filtering_form}, :remote => true) do -%> + <%= form_tag :projects, :method => :get do -%> <fieldset id="filters_fieldset" class="collapsible"> <legend><%= l(:label_filter_plural) %></legend> @@ -26,13 +26,11 @@ </div> <p class='q'> - <%= label_tag 'q', l('project_filtering_q_label') %> - <%= text_field_tag 'q', @question, :size => 30, :id => 'search-input' %> + <%= label_tag 'search', l('project_filtering_q_label') %> + <%= text_field_tag 'search', params[:search] -%> + <%= submit_tag :search, :name => nil %> </p> - <p style="display: none;"><%= submit_tag( l('button_filter'), :id => 'submitButton') -%></p> - <%= link_to l(:button_apply), {}, :onclick => "$('submitButton').click(); return false;", :class => 'icon icon-checked' -%> - <%= link_to l(:button_clear), {}, :class => 'icon icon-reload' %> </div> </fieldset>
--- a/plugins/redmine_tags/assets/javascripts/projects_index.js Fri Apr 05 15:07:40 2013 +0100 +++ b/plugins/redmine_tags/assets/javascripts/projects_index.js Fri Apr 05 18:29:23 2013 +0100 @@ -2,6 +2,7 @@ init: function(){ var self = this; $('fieldset#filters_fieldset legend').live("click", self.toggle); + // $('fieldset #submitButton').live("click", self.submitSearch); }, expanded: false, @@ -10,9 +11,18 @@ var fieldset = $(this).parents('fieldset').first(); fieldset.toggleClass('collapsed'); fieldset.children('div').toggle(); + }, + submitSearch: function(){ + console.log("Submitting search"); + $(this).submit(); + return false; } }; + + + + /* function toggleFieldsetWithState(obj){ var fset = $(obj).parent('fieldset'); @@ -25,9 +35,6 @@ } - function submitForm(){ - $('submitButton').click(); - } function change_session(id, nstatus) {
--- a/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb Fri Apr 05 15:07:40 2013 +0100 +++ b/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb Fri Apr 05 18:29:23 2013 +0100 @@ -8,8 +8,8 @@ base.send(:include, InstanceMethods) base.class_eval do unloadable - skip_before_filter :authorize, :only => [:set_fieldset_status] - skip_before_filter :find_project, :only => [:set_fieldset_status] + # skip_before_filter :authorize, :only => [:set_fieldset_status] + # skip_before_filter :find_project, :only => [:set_fieldset_status] alias :index filtered_index end @@ -22,7 +22,7 @@ @limit = per_page_option # Only top-level visible projects are counted --lf.10Jan2013 - top_level_visible_projects = @projects.select{ |p| p.parent_id.nil? and p.visible? } + top_level_visible_projects = @projects.visible_roots @project_count = top_level_visible_projects.count # Project.visible_roots.find(@projects).count @@ -31,42 +31,42 @@ @offset ||= @project_pages.current.offset end - def set_fieldset_status - - # luisf. test for missing parameters……… - field = params[:field_id] - status = params[:status] - - session[(field + "_status").to_sym] = status - render :nothing => true - end + # def set_fieldset_status +# + # # luisf. test for missing parameters……… + # field = params[:field_id] + # status = params[:status] +# + # session[(field + "_status").to_sym] = status + # render :nothing => true + # end # gets the status of the collabsible fieldsets - def get_fieldset_statuses - if session[:my_projects_fieldset_status].nil? - @myproj_status = "true" - else - @myproj_status = session[:my_projects_fieldset_status] - end - - if session[:filters_fieldset_status].nil? - @filter_status = "false" - else - @filter_status = session[:filters_fieldset_status] - end - - if params && params[:project] && !params[:project][:tag_list].nil? - @filter_status = "true" - end - - end + # def get_fieldset_statuses + # if session[:my_projects_fieldset_status].nil? + # @myproj_status = "true" + # else + # @myproj_status = session[:my_projects_fieldset_status] + # end +# + # if session[:filters_fieldset_status].nil? + # @filter_status = "false" + # else + # @filter_status = session[:filters_fieldset_status] + # end +# + # if params && params[:project] && !params[:project][:tag_list].# nil? + # @filter_status = "true" + # end +# + # end # Lists visible projects. Paginator is for top-level projects only # (subprojects belong to them) def filtered_index @project = Project.new filter_projects - get_fieldset_statuses + # get_fieldset_statuses sort_clause = "name" @@ -101,26 +101,31 @@ private def filter_projects - @question = (params[:q] || "").strip + # find projects like question + @question = (params[:search] || "").strip +# + # if params.has_key?(:project) + # @tag_list = (params[:project][:tag_list] || "").strip.split(",") + # else + # @tag_list = [] + # end +# + # if @question == "" + # @projects = Project.visible_roots + # else + # @projects = Project.visible_roots.find(Project.visible.like(@question)) + # end +# + # unless @tag_list.empty? + # @tagged_projects_ids = Project.visible.tagged_with(@tag_list).collect{ |# project| Project.find(project.id).root } +# + # @projects = @projects & @tagged_projects_ids + # @projects = @projects.uniq + # end - if params.has_key?(:project) - @tag_list = (params[:project][:tag_list] || "").strip.split(",") - else - @tag_list = [] - end + # hack... + @projects = Project.like(@question) - if @question == "" - @projects = Project.visible_roots - else - @projects = Project.visible_roots.find(Project.visible.search_by_question(@question)) - end - - unless @tag_list.empty? - @tagged_projects_ids = Project.visible.tagged_with(@tag_list).collect{ |project| Project.find(project.id).root } - - @projects = @projects & @tagged_projects_ids - @projects = @projects.uniq - end end end end
--- a/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb Fri Apr 05 15:07:40 2013 +0100 +++ b/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb Fri Apr 05 18:29:23 2013 +0100 @@ -104,7 +104,7 @@ end end - s + s.html_safe end @@ -239,12 +239,10 @@ end - s + s.html_safe end - - private # copied from search_helper. This one doesn't escape html or limit the text length @@ -262,7 +260,7 @@ result << content_tag('span', words, :class => "highlight token-#{t}") end end - result + result.html_safe end end