Просмотр исходного кода

Force reload BinaryFile view when a new object is selected.

Shane Kilkelly 10 лет назад
Родитель
Сommit
939c7a8c72

+ 9 - 1
services/web/public/coffee/ide/binary-files/BinaryFilesManager.coffee

@@ -9,4 +9,12 @@ define [
 
 		openFile: (file) ->
 			@$scope.ui.view = "file"
-			@$scope.openFile = file
+			@$scope.openFile = null
+			@$scope.$apply()
+			window.setTimeout(
+				() =>
+					@$scope.openFile = file
+					@$scope.$apply()
+				, 0
+				, this
+			)

+ 5 - 9
services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee

@@ -13,15 +13,6 @@ define [
 
 		$scope.failedLoad = false
 
-		$rootScope.$on 'entity:selected', () ->
-			$scope.failedLoad = false
-			$scope.loadBibtexIfRequired()
-
-		$scope.loadBibtexIfRequired = () ->
-			if $scope.extension($scope.openFile) == 'bib'
-				$scope.bibtexPreview.data = null
-				$scope.loadBibtexFilePreview()
-
 		window.sl_binaryFilePreviewError = () =>
 			$scope.failedLoad = true
 			$scope.$apply()
@@ -61,6 +52,11 @@ define [
 					table_wrap.style.height = desired_height + 'px'
 					table_wrap.style['max-height'] = desired_height + 'px'
 
+		$scope.loadBibtexIfRequired = () ->
+			if $scope.extension($scope.openFile) == 'bib'
+				$scope.bibtexPreview.data = null
+				$scope.loadBibtexFilePreview()
+
 		$scope.loadBibtexIfRequired()
 
 	]