From d21f6ef62452ce560758834d4818774c091d129d Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 1 Aug 2018 16:03:45 +0100 Subject: [PATCH] Label handling in compare mode. --- .../project/editor/history/entriesListV2.pug | 15 ++++++++++++++- .../coffee/ide/history/HistoryV2Manager.coffee | 18 +++++++++++++----- .../controllers/HistoryListController.coffee | 10 +++++++++- .../stylesheets/app/editor/history-v2.less | 1 + 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/services/web/app/views/project/editor/history/entriesListV2.pug b/services/web/app/views/project/editor/history/entriesListV2.pug index ba7492663c..4cbed71fda 100644 --- a/services/web/app/views/project/editor/history/entriesListV2.pug +++ b/services/web/app/views/project/editor/history/entriesListV2.pug @@ -66,6 +66,18 @@ aside.change-list( ) div.description(ng-click="select()") + div + .history-entry-label( + ng-if="update.labels.length > 0" + ng-repeat="label in update.labels" + ) + span.history-entry-label-comment + i.fa.fa-tag + |  {{ label.comment }} + button.history-entry-label-delete-btn( + stop-propagation="click" + ng-click="deleteLabel(label)" + ) × div.time {{ update.meta.end_ts | formatDate:'h:mm a' }} div.action.action-edited(ng-if="history.isV2 && update.pathnames.length > 0") | #{translate("file_action_edited")} @@ -133,7 +145,7 @@ script(type="text/ng-template", id="historyEntryTpl") .history-entry-details(ng-click="$ctrl.onSelect({ selectedEntry: $ctrl.entry })") .history-entry-label( ng-if="$ctrl.entry.labels.length > 0" - ng-repeat="label in ::$ctrl.entry.labels" + ng-repeat="label in $ctrl.entry.labels" ) span.history-entry-label-comment i.fa.fa-tag @@ -162,6 +174,7 @@ script(type="text/ng-template", id="historyEntryTpl") ng-if="::project_op.remove" ) #{translate("file_action_deleted")} span.history-entry-change-doc {{ ::$ctrl.getProjectOpDoc(project_op) }} + .history-entry-metadata time.history-entry-metadata-time {{ ::$ctrl.entry.meta.end_ts | formatDate:'h:mm a' }} span diff --git a/services/web/public/coffee/ide/history/HistoryV2Manager.coffee b/services/web/public/coffee/ide/history/HistoryV2Manager.coffee index 3a8640ac9a..a921cacb08 100644 --- a/services/web/public/coffee/ide/history/HistoryV2Manager.coffee +++ b/services/web/public/coffee/ide/history/HistoryV2Manager.coffee @@ -306,11 +306,19 @@ define [ _labelVersion: (comment, version) -> url = "/project/#{@$scope.project_id}/labels" - @ide.$http.post url, { - comment, - version, - _csrf: window.csrfToken - } + @ide.$http + .post url, { + comment, + version, + _csrf: window.csrfToken + } + .then (response) => + @_addLabelToLocalUpdate response.data + + _addLabelToLocalUpdate: (label) -> + localUpdate = _.find @$scope.history.updates, (update) -> update.toV == label.version + if localUpdate? + localUpdate.labels.push label _perDocSummaryOfUpdates: (updates) -> # Track current_pathname -> original_pathname diff --git a/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee b/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee index 4b0786d259..e4bc2b541d 100644 --- a/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee +++ b/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee @@ -3,9 +3,17 @@ define [ "ide/history/util/displayNameForUser" ], (App, displayNameForUser) -> - App.controller "HistoryListController", ["$scope", "ide", ($scope, ide) -> + App.controller "HistoryListController", ["$scope", "$modal", "ide", ($scope, $modal, ide) -> $scope.hoveringOverListSelectors = false + $scope.deleteLabel = (labelDetails) -> + $modal.open( + templateUrl: "historyV2DeleteLabelModalTemplate" + controller: "HistoryV2DeleteLabelModalController" + resolve: + labelDetails: () -> labelDetails + ) + $scope.loadMore = () => ide.historyManager.fetchNextBatchOfUpdates() diff --git a/services/web/public/stylesheets/app/editor/history-v2.less b/services/web/public/stylesheets/app/editor/history-v2.less index 9e099422c5..7ed37d49b1 100644 --- a/services/web/public/stylesheets/app/editor/history-v2.less +++ b/services/web/public/stylesheets/app/editor/history-v2.less @@ -55,6 +55,7 @@ } .history-entry-label { + display: inline-block; color: @history-entry-label-color; font-size: @font-size-small; margin-bottom: 3px;