From 1c90b535e4b0336534bec7a5493739638eabbec5 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Wed, 13 Aug 2014 12:30:34 +0200 Subject: [PATCH] Loading correct location when searching --- app/coffee/modules/search.coffee | 25 +++++++++++++------ .../views/modules/lightbox-search.jade | 1 + 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/coffee/modules/search.coffee b/app/coffee/modules/search.coffee index 52b893ba..dc89caed 100644 --- a/app/coffee/modules/search.coffee +++ b/app/coffee/modules/search.coffee @@ -105,12 +105,8 @@ module.controller("SearchController", SearchController) SearchBoxDirective = ($lightboxService, $navurls, $location)-> link = ($scope, $el, $attrs) -> project = null - $scope.$on "search-box:show", (ctx, newProject)-> - project = newProject - $lightboxService.open($el) - $el.on "click", ".button-green", (event) -> - event.preventDefault() + submit = -> form = $el.find("form").checksley() if not form.validate() return @@ -125,6 +121,17 @@ SearchBoxDirective = ($lightboxService, $navurls, $location)-> $location.path(url) $location.search("text",text).path(url) + $scope.$on "search-box:show", (ctx, newProject)-> + project = newProject + $lightboxService.open($el) + + $el.on "submit", (event) -> + submit() + + $el.on "click", ".button-green", (event) -> + event.preventDefault() + submit() + return {link:link} @@ -135,7 +142,7 @@ module.directive("tgSearchBox", ["lightboxService", "$tgNavUrls", "$tgLocation", ## Search Directive ############################################################################# -SearchDirective = ($log, $compile, $templatecache) -> +SearchDirective = ($log, $compile, $templatecache, $routeparams) -> # linkFilters = ($scope, $el, $attrs, $ctrl) -> linkTable = ($scope, $el, $attrs, $ctrl) -> tabsDom = $el.find("section.search-filter") @@ -215,13 +222,15 @@ SearchDirective = ($log, $compile, $templatecache) -> renderTableContent(section) markSectionTabActive(section) - link = ($scope, $el, $attrs) -> $ctrl = $el.controller() # linkFilters($scope, $el, $attrs, $ctrl) linkTable($scope, $el, $attrs, $ctrl) + $scope.$watch "projectId", (projectId) -> + $scope.searchTerm = $routeparams.text + return {link:link} -module.directive("tgSearch", ["$log", "$compile", "$templateCache", SearchDirective]) +module.directive("tgSearch", ["$log", "$compile", "$templateCache", "$routeParams", SearchDirective]) diff --git a/app/partials/views/modules/lightbox-search.jade b/app/partials/views/modules/lightbox-search.jade index 8dac3825..a8886cc0 100644 --- a/app/partials/views/modules/lightbox-search.jade +++ b/app/partials/views/modules/lightbox-search.jade @@ -3,5 +3,6 @@ a.close(href="", title="close") form h2.title Search input(type="text", name="text", id="search-text", placeholder="What are you looking for?", data-required="true") + input.hidden(type="submit") a.button.button-green(href="", title="Accept") span Search