From 8d0bfa0ce23ffc60c879841d5e71ba95b49d493d Mon Sep 17 00:00:00 2001 From: Luciano Date: Tue, 3 Feb 2015 10:38:26 -0200 Subject: [PATCH] Remove filter button of software search --- features/software_catalog.feature | 7 ++++--- features/step_definitions/mpog_steps.rb | 5 +++++ public/software-catalog.js | 25 +++++++++++++++++-------- views/search/_mpog_search_form.html.erb | 2 -- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/features/software_catalog.feature b/features/software_catalog.feature index d40ac69..55010d2 100644 --- a/features/software_catalog.feature +++ b/features/software_catalog.feature @@ -34,23 +34,24 @@ Feature: Search software Then I should see "Software One" Then I should see "Software Two" + @selenium Scenario: Show software "One" when searching for "Software One" Given I go to /search/software_infos And I fill in "search-input" with "Software One" - And I press "Filter" + And I keyup on selector "#search-input" Then I should see "Software One" Then I should not see "Software Two" + @selenium Scenario: Show software ordered by name when "Name A-Z" is selected Given I go to /search/software_infos And I select "Name A-Z" from "sort" - And I press "Filter" Then I should see "Software One" before "Software Two" + @selenium Scenario: Show software in reverse order by name when "Name Z-A" is selected Given I go to /search/software_infos And I select "Name Z-A" from "sort" - And I press "Filter" Then I should see "Software Two" before "Software One" Scenario: Show softwares with selected category in filter diff --git a/features/step_definitions/mpog_steps.rb b/features/step_definitions/mpog_steps.rb index d6b4a1f..cf1002c 100644 --- a/features/step_definitions/mpog_steps.rb +++ b/features/step_definitions/mpog_steps.rb @@ -235,3 +235,8 @@ end Given /^I should see "([^"]*)" before "([^"]*)"$/ do |before, after| assert page.body.index("#{before}") < page.body.index("#{after}") end + +Given /^I keyup on selector "([^"]*)"$/ do |selector| + selector_founded = evaluate_script("jQuery('#{selector}').trigger('keyup').length != 0") + selector_founded.should be_true +end diff --git a/public/software-catalog.js b/public/software-catalog.js index bbc72f1..2a27ca8 100644 --- a/public/software-catalog.js +++ b/public/software-catalog.js @@ -43,7 +43,7 @@ $(this).prop('checked', false); }); - dispatch_search_ajax(update_search_page_on_ajax); + dispatch_search_ajax(update_search_page_on_ajax, true); } @@ -52,16 +52,16 @@ $("#filter-categories-select-catalog").show(); $("#filter-option-catalog-software").hide(); - dispatch_search_ajax(update_search_page_on_ajax); + dispatch_search_ajax(update_search_page_on_ajax, true); } - function dispatch_search_ajax(callback) { + function dispatch_search_ajax(callback, enable_load) { var search_params = get_search_params(); - console.log(search_params); - - open_loading("Loading"); + if(enable_load) { + open_loading("Loading"); + } $.ajax({ url: AJAX_URL.software_infos, @@ -117,12 +117,20 @@ $("#filter-categories-select-catalog").show(); $("#filter-option-catalog-software").hide(); - dispatch_search_ajax(update_search_page_on_ajax); + dispatch_search_ajax(update_search_page_on_ajax, true); show_head_message(); } function update_page_by_ajax_on_select_change() { - dispatch_search_ajax(update_search_page_on_ajax); + dispatch_search_ajax(update_search_page_on_ajax, true); + } + + function update_page_by_text_filter() { + var text = this.value; + + if (text.length >= 3) { + dispatch_search_ajax(update_search_page_on_ajax, false); + } } function set_events() { @@ -134,6 +142,7 @@ $(".project-software").click(selectProjectSoftwareCheckbox); $("#software_display").change(update_page_by_ajax_on_select_change); $("#sort").change(update_page_by_ajax_on_select_change); + $("#search-input").keyup(update_page_by_text_filter); } diff --git a/views/search/_mpog_search_form.html.erb b/views/search/_mpog_search_form.html.erb index 6a66dc3..18a7158 100644 --- a/views/search/_mpog_search_form.html.erb +++ b/views/search/_mpog_search_form.html.erb @@ -11,8 +11,6 @@ <%= text_field_tag 'query', @query, :id => 'search-input', :size => 50, :placeholder=>_("Type words about the software_info you're looking for") %> - - <%= submit_button(:search, _('Filter')) %> <%= render :partial => 'search_form_extra_fields' %> <%= render :partial => 'catalog_filter' %> -- libgit2 0.21.2