From df9a42c3974a94294c6c7b17bb0981d16fa1877b Mon Sep 17 00:00:00 2001 From: mokus Date: Wed, 31 Jul 2013 10:24:38 +0200 Subject: [PATCH] update search controller + serch.js so that autocomplete works Added search_controller_spec, moved some tests from people_controller_spec to search_controller_spec Fixed merged conflict in Changelog update routes and search controller remove useless except from search controller Fix indentation in search_controller --- Changelog.md | 2 ++ app/assets/javascripts/widgets/search.js | 8 +++-- app/assets/templates/header_tpl.jst.hbs | 2 +- app/controllers/people_controller.rb | 13 -------- app/controllers/search_controller.rb | 26 +++++++++++++++ config/routes.rb | 3 ++ spec/controllers/people_controller_spec.rb | 17 ---------- spec/controllers/search_controller_spec.rb | 39 ++++++++++++++++++++++ 8 files changed, 77 insertions(+), 33 deletions(-) create mode 100644 app/controllers/search_controller.rb create mode 100644 spec/controllers/search_controller_spec.rb diff --git a/Changelog.md b/Changelog.md index 9e7e4cb9e..8c7cc3d52 100644 --- a/Changelog.md +++ b/Changelog.md @@ -33,6 +33,8 @@ * Deleting a post deletes it from Tumblr too [#4331](https://github.com/diaspora/diaspora/pull/4331) * OpenGraph support [#4215](https://github.com/diaspora/diaspora/pull/4215) * Added Wordpress service ability for posts. [#4321](https://github.com/diaspora/diaspora/pull/4321) +* Implement tag search autocomplete in header search box [#4169](https://github.com/diaspora/diaspora/issues/4169) + # 0.1.1.0 diff --git a/app/assets/javascripts/widgets/search.js b/app/assets/javascripts/widgets/search.js index 675b6f8b8..ebe1009fe 100644 --- a/app/assets/javascripts/widgets/search.js +++ b/app/assets/javascripts/widgets/search.js @@ -31,7 +31,11 @@ if (typeof row.search !== "undefined") { return Diaspora.I18n.t("search_for", row); } else { - return "" + row.name; + if (row.avatar) { + return "" + row.name; + } else { + return row.name; + } } }; @@ -62,7 +66,7 @@ window.location = self.searchFormAction + '?' + self.searchInputName + '=' + data['name']; } else { // The actual result self.options.element.val(formatted); - window.location = data['url']; + window.location = data['url'] ? data['url'] : "/tags/" + searchForm.attr('name'); } }; }; diff --git a/app/assets/templates/header_tpl.jst.hbs b/app/assets/templates/header_tpl.jst.hbs index 9733982ed..948617e69 100644 --- a/app/assets/templates/header_tpl.jst.hbs +++ b/app/assets/templates/header_tpl.jst.hbs @@ -103,7 +103,7 @@