diff --git a/lib/mpog_software_plugin.rb b/lib/mpog_software_plugin.rb index 9bc57bd..6d648be 100644 --- a/lib/mpog_software_plugin.rb +++ b/lib/mpog_software_plugin.rb @@ -329,28 +329,34 @@ class MpogSoftwarePlugin < Noosfero::Plugin if context.params[:action] == "people" expanded_template('search/search_user_filter.html.erb') else context.params[:action] == "communities" + @active_type = if context.params[:type] == "Software" + "software" + elsif context.params[:type] == "Institution" + "institution" + else + "community" + end + expanded_template('search/search_community_filter.html.erb') end end - def custom_people_search params - Person.search(params[:name], - params[:state], - params[:city], - params[:email] - ) - end + def custom_search params + #:params => {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>"1", "programming_language"=>"1", "operating_system"=>"1", "controlled_vocabulary"=>"Administration", "license_info"=>{"id"=>""}, "e_ping"=>"any", "e_mag"=>"any", "icp_brasil"=>"any", "e_arq"=>"any", "internacionalizable"=>"any", "commit"=>"Search", "controller"=>"search", "action"=>"communities"} - def custom_community_search params - if params[:type] == "Community" - Community.search(params[:name]) - elsif params[:type] == "Software" - - elsif params[:type] == "Institution" + if params[:action] == "people" + Person.search(params[:name], + params[:state], + params[:city], + params[:email] + ) + elsif params[:action] == "communities" and params[:type] == "Institution" - else + elsif params[:action] == "communities" and params[:type] == "Software" - end + else + [] # An empty list will trigger noosfero's default communities search + end end def controlled_vocabulary_transaction diff --git a/public/mpog-search.js b/public/mpog-search.js index d234763..28e6b60 100644 --- a/public/mpog-search.js +++ b/public/mpog-search.js @@ -18,8 +18,20 @@ jQuery(".community_fields").show(); } + function display_search_fields_on_page_load() { + var active_search = jQuery(".search_type input[checked='checked'").val(); + + switch(active_search) { + case "Community": show_community_fields(); break; + case "Software": show_software_fields(); break; + case "Institution": show_institutions_fields(); break; + + default: show_community_fields(); + } + } + function set_events() { - show_community_fields(); + display_search_fields_on_page_load(); jQuery("#type_Community").click(show_community_fields); diff --git a/views/search/search_community_filter.html.erb b/views/search/search_community_filter.html.erb index 1d15a85..f618fa3 100644 --- a/views/search/search_community_filter.html.erb +++ b/views/search/search_community_filter.html.erb @@ -2,15 +2,15 @@