Use an object instead of a string, to avoid writing to another scope.

This commit is contained in:
Paulo Reis 2016-09-06 14:59:18 +01:00
parent e412e662ee
commit afdded702b
2 changed files with 7 additions and 5 deletions

View file

@ -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

View file

@ -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