diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index c3f45c09543c7a1475f433fc887350ba8c3fbbd7..840ce0bc3a76d9fda5f49fe2a2e1251bb8390a83 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -46,15 +46,16 @@ class PeopleController < ApplicationController def refresh_search @aspect = :search @people = Person.where(:diaspora_handle => search_query.downcase) - @people = @people.paginate(:page => params[:page], :per_page => 15) - @hashes = hashes_for_people(@people, @aspects) @answer_html = "" + unless @people.empty? + @people = @people.paginate(:page => params[:page], :per_page => 15) + @hashes = hashes_for_people(@people, @aspects) - self.formats = self.formats + [:html] - @hashes.each do |hash| - @answer_html += render_to_string :partial => 'people/person', :locals => hash + self.formats = self.formats + [:html] + @hashes.each do |hash| + @answer_html += render_to_string :partial => 'people/person', :locals => hash + end end - render :json => { :search_count => @people.count, :search_html => @answer_html }.to_json end diff --git a/app/views/people/index.html.haml b/app/views/people/index.html.haml index 67e31715bb6a13995a4f50a5fe0e34214f74373f..f01484c653df72f2090afdc7f7c02527a12cddde 100644 --- a/app/views/people/index.html.haml +++ b/app/views/people/index.html.haml @@ -18,13 +18,14 @@ .span-15.append-1 #people_stream.stream - if @hashes.empty? - %p#not_found{:class => @background_query.nil? ? "" : "hidden" } - =t('.no_one_found') - %p#searching{:class => @background_query.nil? ? "hidden" : "" } - =t('.searching') - - if ! @background_query.nil? + - if @background_query.present? + %p + =t('.searching') :javascript $(document).ready(function() { setTimeout("runDelayedSearch('#{@background_query}')", 10000); }); + - else + %p + =t('.no_one_found') - else - for hash in @hashes = render :partial => 'people/person', :locals => hash diff --git a/config/locales/javascript/javascript.en.yml b/config/locales/javascript/javascript.en.yml index f0cba19132db793f76e49d8333f814ccccffeb2e..a04f3e18636376a26051df2647489fb3b65ad45b 100644 --- a/config/locales/javascript/javascript.en.yml +++ b/config/locales/javascript/javascript.en.yml @@ -29,8 +29,8 @@ en: my_stream: "Stream" videos: - watch: "Watch this video on <%= provider %>" - unknown: "Unknown video type" + watch: "Watch this video on <%= provider %>" + unknown: "Unknown video type" search_for: "Search for <%= name %>" publisher: at_least_one_aspect: "You must publish to at least one aspect" @@ -73,6 +73,8 @@ en: looking_good: "OMG, you look awesome!" tags: wasnt_that_interesting: "OK, I suppose #<%= tagName %> wasn't all that interesting..." + people: + not_found: "and no one was found..." stream: hide: "Hide" diff --git a/public/javascripts/pages/contacts-index.js b/public/javascripts/pages/contacts-index.js index 2c55b14942a50d9758aa32363168aedf25943876..d75ac9b662ff593ed5c314925c457d43655a3291 100644 --- a/public/javascripts/pages/contacts-index.js +++ b/public/javascripts/pages/contacts-index.js @@ -20,7 +20,6 @@ function handleSearchRefresh(data) { if ( data.search_count > 0 ) { $("#people_stream.stream").html( data.search_html ); } else { - $("p#not_found").removeClass( 'hidden' ); - $("p#searching").addClass( 'hidden' ); + $("#people_stream.stream").html( "<p>" + Diaspora.I18n.t("people.not_found") + "</p>" ); } } \ No newline at end of file diff --git a/spec/controllers/jasmine_fixtures/people.spec.rb b/spec/controllers/jasmine_fixtures/people.spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..70ee513d3f0651960f5d37aa7cdcc4e25eb785f3 --- /dev/null +++ b/spec/controllers/jasmine_fixtures/people.spec.rb @@ -0,0 +1,18 @@ +# Copyright (c) 2010-2011, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +require 'spec_helper' + +describe PeopleController do + describe '#index' do + before do + sign_in :user, bob + end + + it "generates a jasmine fixture", :fixture => true do + get :index + save_fixture(html_for("body"), "empty_people_search") + end + end +end diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 6a3da53b83dbfc647ed30a3a0f3c98ac7e711c90..a03b8e86a90c1c4d0cb8f0a41fcf233d1b36b8fc 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -373,7 +373,6 @@ describe PeopleController do end it 'returns with a found name' do get :refresh_search, :q => @korth.diaspora_handle - puts JSON.parse( response.body ).inspect JSON.parse( response.body )["search_count"].should == 1 end end