From bc8a2881ada30a9faee136a619a140407c0cc675 Mon Sep 17 00:00:00 2001 From: Gabriela Navarro Date: Tue, 3 Mar 2015 19:57:13 +0000 Subject: [PATCH] Change the messages of the catalog when any software is found. --- public/software-catalog.js | 24 +++++++++++++++++++++++- views/search/_catalog_filter.html.erb | 4 ++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/public/software-catalog.js b/public/software-catalog.js index ce41301..0cc9bd7 100644 --- a/public/software-catalog.js +++ b/public/software-catalog.js @@ -93,6 +93,23 @@ return params; } + function get_result_div_core(message){ + var div_result = $(".search-results-type-empty"); + var html = '
'+message+'
' + + div_result.replaceWith('
Nenhum software encontrado
'+message+'
') + } + + function catalog_message(){ + var result_list = $("#search-results").find('.search-results-empty').html(); + var selected_categories_field = $("#filter-categories-select-catalog"); + + if(result_list.length > 1 && selected_categories_field.html().length < 1){ + get_result_div_core("Tente filtros mais abrangentes"); + }else if (result_list.length > 1 && selected_categories_field.html().length >= 1) { + get_result_div_core("Tente filtros mais abrangentes ou confira os softwares das categorias individualmente"); + } + } function update_search_page_on_ajax(response) { response = $(response); @@ -106,6 +123,8 @@ var result_pagination = response.find("#software-pagination").html(); var result_software_count = response.find("#software-count").html(); + catalog_message() + search_list.html(result_list); selected_categories_field.html(result_categories); pagination.html(result_pagination); @@ -188,10 +207,13 @@ search_input_keyup(); } - $(document).ready(function(){ set_events(); + catalog_message(); show_head_message(); + + + $("#filter-categories-option").hide(); }); })(jQuery); diff --git a/views/search/_catalog_filter.html.erb b/views/search/_catalog_filter.html.erb index 3989699..7c6975f 100644 --- a/views/search/_catalog_filter.html.erb +++ b/views/search/_catalog_filter.html.erb @@ -5,7 +5,7 @@
<%= _("More options") %>
-
<%= @message_selected_options %>
+
<%= @message_selected_options %>
@@ -42,4 +42,4 @@ <%= button_tag _("Close"), :id => "close-filter-catalog", :type => "button" %>
- \ No newline at end of file + -- libgit2 0.21.2