From afdded702b1bd01c6477f162e3f9b31dfd3f88fe Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Tue, 6 Sep 2016 14:59:18 +0100 Subject: [PATCH] Use an object instead of a string, to avoid writing to another scope. --- services/web/app/views/project/list/project-list.jade | 4 ++-- .../public/coffee/main/project-list/project-list.coffee | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/services/web/app/views/project/list/project-list.jade b/services/web/app/views/project/list/project-list.jade index 649c860b26..01007213d0 100644 --- a/services/web/app/views/project/list/project-list.jade +++ b/services/web/app/views/project/list/project-list.jade @@ -8,7 +8,7 @@ input.form-control.col-md-7.col-xs-12( placeholder="#{translate('search_projects')}…", autofocus='autofocus', - ng-model="searchText", + ng-model="searchText.value", focus-on='search:clear', ng-keyup="searchProjects()" ) @@ -16,7 +16,7 @@ i.fa.fa-times.form-control-feedback( ng-click="clearSearchText()", style="cursor: pointer;", - ng-show="searchText.length > 0" + ng-show="searchText.value.length > 0" ) //- i.fa.fa-remove diff --git a/services/web/public/coffee/main/project-list/project-list.coffee b/services/web/public/coffee/main/project-list/project-list.coffee index 313b52ba1f..39ce68043f 100644 --- a/services/web/public/coffee/main/project-list/project-list.coffee +++ b/services/web/public/coffee/main/project-list/project-list.coffee @@ -11,6 +11,8 @@ define [ $scope.filter = "all" $scope.predicate = "lastUpdated" $scope.reverse = true + $scope.searchText = + value : "" if $scope.projects.length == 0 $timeout () -> @@ -69,7 +71,7 @@ define [ $scope.updateVisibleProjects() $scope.clearSearchText = () -> - $scope.searchText = "" + $scope.searchText.value = "" $scope.filter = "all" $scope.$emit "search:clear" $scope.updateVisibleProjects() @@ -96,8 +98,8 @@ define [ for project in $scope.projects visible = true # Only show if it matches any search text - if $scope.searchText? and $scope.searchText != "" - if !project.name.toLowerCase().match($scope.searchText.toLowerCase()) + if $scope.searchText.value? and $scope.searchText.value != "" + if !project.name.toLowerCase().match($scope.searchText.value.toLowerCase()) visible = false # Only show if it matches the selected tag if $scope.filter == "tag" and selectedTag? and project.id not in selectedTag.project_ids