From 7e86218b212f4ca06f1793c5e0c0573a35636166 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Fri, 10 Aug 2018 11:28:17 +0100 Subject: [PATCH] Allow multiple events to trigger layout external resizes. --- services/web/app/views/project/editor.pug | 2 +- .../public/coffee/ide/directives/layout.coffee | 3 ++- .../coffee/ide/history/HistoryV2Manager.coffee | 17 ++++++++++------- .../web/public/coffee/ide/services/ide.coffee | 3 ++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/services/web/app/views/project/editor.pug b/services/web/app/views/project/editor.pug index 6d7d18687d..08124c334c 100644 --- a/services/web/app/views/project/editor.pug +++ b/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" diff --git a/services/web/public/coffee/ide/directives/layout.coffee b/services/web/public/coffee/ide/directives/layout.coffee index b4e2e7f83d..8c30943f39 100644 --- a/services/web/public/coffee/ide/directives/layout.coffee +++ b/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() diff --git a/services/web/public/coffee/ide/history/HistoryV2Manager.coffee b/services/web/public/coffee/ide/history/HistoryV2Manager.coffee index 2e56d955ce..e7a2c071e3 100644 --- a/services/web/public/coffee/ide/history/HistoryV2Manager.coffee +++ b/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() diff --git a/services/web/public/coffee/ide/services/ide.coffee b/services/web/public/coffee/ide/services/ide.coffee index f9c61b4114..24805b6270 100644 --- a/services/web/public/coffee/ide/services/ide.coffee +++ b/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 = {}) =>