Commit bc8a2881ada30a9faee136a619a140407c0cc675

Authored by Gabriela Navarro
1 parent 15e383f6

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>