Explorar o código

Label handling in compare mode.

Paulo Reis %!s(int64=8) %!d(string=hai) anos
pai
achega
d21f6ef624

+ 14 - 1
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

+ 13 - 5
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

+ 9 - 1
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()
 

+ 1 - 0
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;