Commit 8f2bf86367ee365114d484c186008f67b05c04a5
1 parent
3dbe1ff5
Exists in
master
and in
5 other branches
software_search: Replacing plugin's custom searches for one more generic
Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com> Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Showing
4 changed files
with
40 additions
and
23 deletions
Show diff stats
lib/mpog_software_plugin.rb
@@ -329,28 +329,34 @@ class MpogSoftwarePlugin < Noosfero::Plugin | @@ -329,28 +329,34 @@ class MpogSoftwarePlugin < Noosfero::Plugin | ||
329 | if context.params[:action] == "people" | 329 | if context.params[:action] == "people" |
330 | expanded_template('search/search_user_filter.html.erb') | 330 | expanded_template('search/search_user_filter.html.erb') |
331 | else context.params[:action] == "communities" | 331 | else context.params[:action] == "communities" |
332 | + @active_type = if context.params[:type] == "Software" | ||
333 | + "software" | ||
334 | + elsif context.params[:type] == "Institution" | ||
335 | + "institution" | ||
336 | + else | ||
337 | + "community" | ||
338 | + end | ||
339 | + | ||
332 | expanded_template('search/search_community_filter.html.erb') | 340 | expanded_template('search/search_community_filter.html.erb') |
333 | end | 341 | end |
334 | end | 342 | end |
335 | 343 | ||
336 | - def custom_people_search params | ||
337 | - Person.search(params[:name], | ||
338 | - params[:state], | ||
339 | - params[:city], | ||
340 | - params[:email] | ||
341 | - ) | ||
342 | - end | 344 | + def custom_search params |
345 | + #: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"} | ||
343 | 346 | ||
344 | - def custom_community_search params | ||
345 | - if params[:type] == "Community" | ||
346 | - Community.search(params[:name]) | ||
347 | - elsif params[:type] == "Software" | ||
348 | - | ||
349 | - elsif params[:type] == "Institution" | 347 | + if params[:action] == "people" |
348 | + Person.search(params[:name], | ||
349 | + params[:state], | ||
350 | + params[:city], | ||
351 | + params[:email] | ||
352 | + ) | ||
353 | + elsif params[:action] == "communities" and params[:type] == "Institution" | ||
350 | 354 | ||
351 | - else | 355 | + elsif params[:action] == "communities" and params[:type] == "Software" |
352 | 356 | ||
353 | - end | 357 | + else |
358 | + [] # An empty list will trigger noosfero's default communities search | ||
359 | + end | ||
354 | end | 360 | end |
355 | 361 | ||
356 | def controlled_vocabulary_transaction | 362 | def controlled_vocabulary_transaction |
public/mpog-search.js
@@ -18,8 +18,20 @@ | @@ -18,8 +18,20 @@ | ||
18 | jQuery(".community_fields").show(); | 18 | jQuery(".community_fields").show(); |
19 | } | 19 | } |
20 | 20 | ||
21 | + function display_search_fields_on_page_load() { | ||
22 | + var active_search = jQuery(".search_type input[checked='checked'").val(); | ||
23 | + | ||
24 | + switch(active_search) { | ||
25 | + case "Community": show_community_fields(); break; | ||
26 | + case "Software": show_software_fields(); break; | ||
27 | + case "Institution": show_institutions_fields(); break; | ||
28 | + | ||
29 | + default: show_community_fields(); | ||
30 | + } | ||
31 | + } | ||
32 | + | ||
21 | function set_events() { | 33 | function set_events() { |
22 | - show_community_fields(); | 34 | + display_search_fields_on_page_load(); |
23 | 35 | ||
24 | jQuery("#type_Community").click(show_community_fields); | 36 | jQuery("#type_Community").click(show_community_fields); |
25 | 37 |
views/search/search_community_filter.html.erb
@@ -2,15 +2,15 @@ | @@ -2,15 +2,15 @@ | ||
2 | <div id="search_content"> | 2 | <div id="search_content"> |
3 | 3 | ||
4 | <div class="search_options"> | 4 | <div class="search_options"> |
5 | - <table class="mpog_search_form_table formfield type-radio"> | 5 | + <table class="mpog_search_form_table formfield type-radio search_type"> |
6 | <tr> | 6 | <tr> |
7 | <td> | 7 | <td> |
8 | <%= label_tag("type_Community", _("Community")) %> | 8 | <%= label_tag("type_Community", _("Community")) %> |
9 | - <%= radio_button_tag(:type, "Community", true) %> | 9 | + <%= radio_button_tag(:type, "Community", (true if @active_type == "community")) %> |
10 | <%= label_tag("type_Software", _("Software")) %> | 10 | <%= label_tag("type_Software", _("Software")) %> |
11 | - <%= radio_button_tag(:type, "Software") %> | 11 | + <%= radio_button_tag(:type, "Software", (true if @active_type == "software")) %> |
12 | <%= label_tag("type_Institution", _("Institution")) %> | 12 | <%= label_tag("type_Institution", _("Institution")) %> |
13 | - <%= radio_button_tag(:type, "Institution") %> | 13 | + <%= radio_button_tag(:type, "Institution", (true if @active_type == "institution")) %> |
14 | </td> | 14 | </td> |
15 | </tr> | 15 | </tr> |
16 | </table> | 16 | </table> |
views/search/search_forms/_community_fields.html.erb
1 | <table class="mpog_search_form_table"> | 1 | <table class="mpog_search_form_table"> |
2 | <tr> | 2 | <tr> |
3 | <td> | 3 | <td> |
4 | - <%= label_tag("name", _("Name"))%> | ||
5 | - <%= text_field_tag(:name) %> | 4 | + <input id="search-input" name="query" size="50" type="text" value="" title="<%= _('Type words about the community you are looking for') %>"> |
6 | </td> | 5 | </td> |
7 | </tr> | 6 | </tr> |
8 | -</table> | ||
9 | \ No newline at end of file | 7 | \ No newline at end of file |
8 | +</table> |