Переглянути джерело

Merge pull request #310 from sharelatex/pr-fix-search-projects

Use an object instead of a string, to avoid writing to another scope.
Paulo Jorge Reis 10 роки тому
батько
коміт
1739842402

+ 2 - 2
services/web/app/views/project/list/project-list.jade

@@ -8,7 +8,7 @@
 				input.form-control.col-md-7.col-xs-12(
 				input.form-control.col-md-7.col-xs-12(
 					placeholder="#{translate('search_projects')}…",
 					placeholder="#{translate('search_projects')}…",
 					autofocus='autofocus',
 					autofocus='autofocus',
-					ng-model="searchText",
+					ng-model="searchText.value",
 					focus-on='search:clear',
 					focus-on='search:clear',
 					ng-keyup="searchProjects()"
 					ng-keyup="searchProjects()"
 				)
 				)
@@ -16,7 +16,7 @@
 				i.fa.fa-times.form-control-feedback(
 				i.fa.fa-times.form-control-feedback(
 					ng-click="clearSearchText()",
 					ng-click="clearSearchText()",
 					style="cursor: pointer;",
 					style="cursor: pointer;",
-					ng-show="searchText.length > 0"
+					ng-show="searchText.value.length > 0"
 				)
 				)
 			//- i.fa.fa-remove
 			//- i.fa.fa-remove
 
 

+ 5 - 3
services/web/public/coffee/main/project-list/project-list.coffee

@@ -11,6 +11,8 @@ define [
 		$scope.filter = "all"
 		$scope.filter = "all"
 		$scope.predicate = "lastUpdated"
 		$scope.predicate = "lastUpdated"
 		$scope.reverse = true
 		$scope.reverse = true
+		$scope.searchText = 
+			value : ""
 
 
 		if $scope.projects.length == 0
 		if $scope.projects.length == 0
 			$timeout () ->
 			$timeout () ->
@@ -69,7 +71,7 @@ define [
 			$scope.updateVisibleProjects()
 			$scope.updateVisibleProjects()
 
 
 		$scope.clearSearchText = () ->
 		$scope.clearSearchText = () ->
-			$scope.searchText = ""
+			$scope.searchText.value = ""
 			$scope.filter = "all"
 			$scope.filter = "all"
 			$scope.$emit "search:clear"
 			$scope.$emit "search:clear"
 			$scope.updateVisibleProjects()
 			$scope.updateVisibleProjects()
@@ -96,8 +98,8 @@ define [
 			for project in $scope.projects
 			for project in $scope.projects
 				visible = true
 				visible = true
 				# Only show if it matches any search text
 				# 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
 						visible = false
 				# Only show if it matches the selected tag
 				# Only show if it matches the selected tag
 				if $scope.filter == "tag" and selectedTag? and project.id not in selectedTag.project_ids
 				if $scope.filter == "tag" and selectedTag? and project.id not in selectedTag.project_ids