Przeglądaj źródła

Allow multiple events to trigger layout external resizes.

Paulo Reis 8 lat temu
rodzic
commit
7e86218b21

+ 1 - 1
services/web/app/views/project/editor.pug

@@ -65,7 +65,7 @@ block content
 					ng-class="{ 'ide-history-open' : (ui.view == 'history' && history.isV2 && history.viewMode === HistoryViewModes.POINT_IN_TIME) }",
 					layout="main",
 					ng-hide="state.loading",
-					resize-on="layout:chat:resize",
+					resize-on="layout:chat:resize,history:toggle",
 					minimum-restore-size-west="130"
 					custom-toggler-pane=hasFeature('custom-togglers') ? "'west'" : "false"
 					custom-toggler-msg-when-open=hasFeature('custom-togglers') ? "'" + translate("tooltip_hide_filetree") + "'" : "false"

+ 2 - 1
services/web/public/coffee/ide/directives/layout.coffee

@@ -112,7 +112,8 @@ define [
 					element.layout().resizeAll()
 
 					if attrs.resizeOn?
-						scope.$on attrs.resizeOn, () -> onExternalResize()
+						for event in attrs.resizeOn.split ","
+							scope.$on event, () -> onExternalResize()
 
 					if hasCustomToggler
 						state = element.layout().readState()

+ 10 - 7
services/web/public/coffee/ide/history/HistoryV2Manager.coffee

@@ -27,6 +27,9 @@ define [
 					@hide()
 				else
 					@show()
+				@ide.$timeout () =>
+					@$scope.$broadcast "history:toggle"
+				, 0
 
 			@$scope.toggleHistoryViewMode = () =>
 				if @$scope.history.viewMode == HistoryViewModes.COMPARE
@@ -124,6 +127,10 @@ define [
 			return if @$scope.history.updates.length == 0
 			@selectUpdate @$scope.history.updates[0]
 
+		autoSelectLastLabel: () ->
+			return if @$scope.history.labels.length == 0
+			@selectLabel @$scope.history.labels[0]
+			
 		selectUpdate: (update) ->
 			selectedUpdateIndex = @$scope.history.updates.indexOf update
 			if selectedUpdateIndex == -1
@@ -135,10 +142,6 @@ define [
 			@$scope.history.updates[selectedUpdateIndex].selectedFrom = true
 			@loadFileTreeForUpdate @$scope.history.updates[selectedUpdateIndex]
 
-		selectLastLabel = () ->
-			return if @$scope.history.labels.length == 0
-			# TODO Select last label
-			
 		selectedLabelFromUpdatesSelection: () ->
 			nLabels = @$scope.history.selection.updates?[0]?.labels?.length
 			if nLabels == 1
@@ -184,12 +187,12 @@ define [
 			@ide.$q.all requests
 				.then (response) =>
 					updatesData = response.updates.data
+					if response.labels?
+						@$scope.history.labels = @_sortLabelsByVersionAndDate response.labels.data
 					@_loadUpdates(updatesData.updates)
 					@$scope.history.nextBeforeTimestamp = updatesData.nextBeforeTimestamp
 					if !updatesData.nextBeforeTimestamp?
 						@$scope.history.atEnd = true
-					if response.labels?
-						@$scope.history.labels = @_sortLabelsByVersionAndDate response.labels.data
 					@$scope.history.loading = false
 
 		_sortLabelsByVersionAndDate: (labels) ->
@@ -354,7 +357,7 @@ define [
 					@autoSelectRecentUpdates()
 				else 
 					if @$scope.history.showOnlyLabels
-						@selectLastLabel()
+						@autoSelectLastLabel()
 					else
 						@autoSelectLastUpdate()
 

+ 2 - 1
services/web/public/coffee/ide/services/ide.coffee

@@ -3,12 +3,13 @@ define [
 ], (App) ->
 	# We create and provide this as service so that we can access the global ide
 	# from within other parts of the angular app.
-	App.factory "ide", ["$http", "queuedHttp", "$modal", "$q", "$filter", ($http, queuedHttp, $modal, $q, $filter) ->
+	App.factory "ide", ["$http", "queuedHttp", "$modal", "$q", "$filter", "$timeout", ($http, queuedHttp, $modal, $q, $filter, $timeout) ->
 		ide = {}
 		ide.$http = $http
 		ide.queuedHttp = queuedHttp
 		ide.$q = $q
 		ide.$filter = $filter
+		ide.$timeout = $timeout
 
 		@recentEvents = []
 		ide.pushEvent = (type, meta = {}) =>