From cd853abb3c039a9ee0fa912e34502fb90ea30c43 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 8 Aug 2018 11:02:14 +0100 Subject: [PATCH] Load labels list from the backend. --- .../views/project/editor/history/toolbarV2.pug | 8 ++++++++ .../coffee/ide/history/HistoryV2Manager.coffee | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/services/web/app/views/project/editor/history/toolbarV2.pug b/services/web/app/views/project/editor/history/toolbarV2.pug index 2a4c222bad..8774754de2 100644 --- a/services/web/app/views/project/editor/history/toolbarV2.pug +++ b/services/web/app/views/project/editor/history/toolbarV2.pug @@ -20,6 +20,14 @@ i.fa.fa-exchange |  #{translate("compare_to_another_version")} + .history-toolbar-entries-list + toggle-switch( + ng-model="history.showOnlyLabels" + label-true="Labels" + label-false="All history" + description="Show all of the project history or only labelled versions." + ) + script(type="text/ng-template", id="historyV2AddLabelModalTemplate") form( name="addLabelModalForm" diff --git a/services/web/public/coffee/ide/history/HistoryV2Manager.coffee b/services/web/public/coffee/ide/history/HistoryV2Manager.coffee index 7ff41985f4..519a94a54a 100644 --- a/services/web/public/coffee/ide/history/HistoryV2Manager.coffee +++ b/services/web/public/coffee/ide/history/HistoryV2Manager.coffee @@ -12,6 +12,7 @@ define [ "ide/history/directives/infiniteScroll" "ide/history/components/historyEntriesList" "ide/history/components/historyEntry" + "ide/history/components/historyLabelsList" "ide/history/components/historyLabel" "ide/history/components/historyFileTree" "ide/history/components/historyFileEntity" @@ -72,6 +73,7 @@ define [ toV: null } } + showOnlyLabels: false labels: null files: [] diff: null # When history.viewMode == HistoryViewModes.COMPARE @@ -134,17 +136,26 @@ define [ updatesURL = "/project/#{@ide.project_id}/updates?min_count=#{@BATCH_SIZE}" if @$scope.history.nextBeforeTimestamp? updatesURL += "&before=#{@$scope.history.nextBeforeTimestamp}" - + labelsURL = "/project/#{@ide.project_id}/labels" + @$scope.history.loading = true @$scope.history.loadingFileTree = true - @ide.$http.get updatesURL + requests = + updates: @ide.$http.get updatesURL + + if !@$scope.history.labels? + requests.labels = @ide.$http.get labelsURL + + @ide.$q.all requests .then (response) => - updatesData = response.data + updatesData = response.updates.data @_loadUpdates(updatesData.updates) @$scope.history.nextBeforeTimestamp = updatesData.nextBeforeTimestamp if !updatesData.nextBeforeTimestamp? @$scope.history.atEnd = true + if response.labels? + @$scope.history.labels = response.labels.data @$scope.history.loading = false loadFileAtPointInTime: () ->