diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index b6165763..a978156d 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -98,7 +98,8 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven { templateUrl: "search/search.html", reloadOnSearch: false, - section: "search" + section: "search", + loader: true } ) diff --git a/app/coffee/modules/common/loading.coffee b/app/coffee/modules/common/loading.coffee index 916fa044..bb92f178 100644 --- a/app/coffee/modules/common/loading.coffee +++ b/app/coffee/modules/common/loading.coffee @@ -36,3 +36,17 @@ class TgLoadingService extends taiga.Service target.removeClass('loading') module.service("$tgLoading", TgLoadingService) + +LoadingDirective = ($loading) -> + link = ($scope, $el, attr) -> + $scope.$watch attr.tgLoading, (showLoading) => + if showLoading + $loading.start($el) + else + $loading.finish($el) + + return { + link:link + } + +module.directive("tgLoading", ["$tgLoading", LoadingDirective]) diff --git a/app/coffee/modules/search.coffee b/app/coffee/modules/search.coffee index 71f2f311..661dedfd 100644 --- a/app/coffee/modules/search.coffee +++ b/app/coffee/modules/search.coffee @@ -69,7 +69,10 @@ class SearchController extends mixOf(taiga.Controller, taiga.PageMixin) @scope.$watch "searchTerm", (term) => if term - loadSearchData(term) + @scope.loading = true + + @.loadSearchData(term).then () => + @scope.loading = false loadFilters: -> defered = @q.defer() diff --git a/app/partials/includes/modules/search-in.jade b/app/partials/includes/modules/search-in.jade index f121ff1e..e13718a3 100644 --- a/app/partials/includes/modules/search-in.jade +++ b/app/partials/includes/modules/search-in.jade @@ -2,4 +2,5 @@ section.search-in header fieldset input(type="text", placeholder="{{'SEARCH.PLACEHOLDER_SEARCH' | translate}}", ng-model="searchTerm") - a.icon.icon-search(href="", title="{{'SEARCH.TITLE_ACTION_SEARCH' | translate}}") + .icon-search-wrapper(tg-loading="loading") + a.icon.icon-search(href="", title="{{'SEARCH.TITLE_ACTION_SEARCH' | translate}}") diff --git a/app/styles/modules/search/search-in.scss b/app/styles/modules/search/search-in.scss index d66fdcf3..19eecf56 100644 --- a/app/styles/modules/search/search-in.scss +++ b/app/styles/modules/search/search-in.scss @@ -6,10 +6,15 @@ color: $gray-light; } } - .icon-search { - color: $gray-light; + .icon-search-wrapper { position: absolute; right: .7rem; top: .7rem; } + .icon-search { + color: $gray-light; + } + .loading-spinner { + margin-top: .1rem; + } }