Commit bc8a2881ada30a9faee136a619a140407c0cc675

Authored by Gabriela Navarro
1 parent 15e383f6
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Change the messages of the catalog when any software is found.

TODO: Add link to the categories that the user already selected.

Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
public/software-catalog.js
@@ -93,6 +93,23 @@ @@ -93,6 +93,23 @@
93 return params; 93 return params;
94 } 94 }
95 95
  96 + function get_result_div_core(message){
  97 + var div_result = $(".search-results-type-empty");
  98 + var html = '<div class="search-results-innerbox search-results-type-empty"> <div>'+message+' </div></div>'
  99 +
  100 + div_result.replaceWith('<div class="search-results-innerbox search-results-type-empty"> <div>Nenhum software encontrado</div> '+message+'</div>')
  101 + }
  102 +
  103 + function catalog_message(){
  104 + var result_list = $("#search-results").find('.search-results-empty').html();
  105 + var selected_categories_field = $("#filter-categories-select-catalog");
  106 +
  107 + if(result_list.length > 1 && selected_categories_field.html().length < 1){
  108 + get_result_div_core("Tente filtros mais abrangentes");
  109 + }else if (result_list.length > 1 && selected_categories_field.html().length >= 1) {
  110 + get_result_div_core("Tente filtros mais abrangentes ou confira os <mudar>softwares das categorias individualmente</mudar>");
  111 + }
  112 + }
96 113
97 function update_search_page_on_ajax(response) { 114 function update_search_page_on_ajax(response) {
98 response = $(response); 115 response = $(response);
@@ -106,6 +123,8 @@ @@ -106,6 +123,8 @@
106 var result_pagination = response.find("#software-pagination").html(); 123 var result_pagination = response.find("#software-pagination").html();
107 var result_software_count = response.find("#software-count").html(); 124 var result_software_count = response.find("#software-count").html();
108 125
  126 + catalog_message()
  127 +
109 search_list.html(result_list); 128 search_list.html(result_list);
110 selected_categories_field.html(result_categories); 129 selected_categories_field.html(result_categories);
111 pagination.html(result_pagination); 130 pagination.html(result_pagination);
@@ -188,10 +207,13 @@ @@ -188,10 +207,13 @@
188 search_input_keyup(); 207 search_input_keyup();
189 } 208 }
190 209
191 -  
192 $(document).ready(function(){ 210 $(document).ready(function(){
193 set_events(); 211 set_events();
  212 + catalog_message();
194 show_head_message(); 213 show_head_message();
  214 +
  215 +
  216 +
195 $("#filter-categories-option").hide(); 217 $("#filter-categories-option").hide();
196 }); 218 });
197 })(jQuery); 219 })(jQuery);
views/search/_catalog_filter.html.erb
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <div id="filter-option-catalog-software"><%= _("More options") %></div> 5 <div id="filter-option-catalog-software"><%= _("More options") %></div>
6 <!--Quando tiver filtros(categorias)selecionados mostrar esta opção: Opções selecionadas--> 6 <!--Quando tiver filtros(categorias)selecionados mostrar esta opção: Opções selecionadas-->
7 7
8 - <div id="filter-categories-select-catalog"> <%= @message_selected_options %> </div> 8 + <div id="filter-categories-select-catalog"><%= @message_selected_options %></div>
9 9
10 <div id="filter-categories-option"> 10 <div id="filter-categories-option">
11 11
@@ -42,4 +42,4 @@ @@ -42,4 +42,4 @@
42 <%= button_tag _("Close"), :id => "close-filter-catalog", :type => "button" %> 42 <%= button_tag _("Close"), :id => "close-filter-catalog", :type => "button" %>
43 </div> 43 </div>
44 </div> 44 </div>
45 -</div>  
46 \ No newline at end of file 45 \ No newline at end of file
  46 +</div>