Просмотр исходного кода

Create history labels list component.

Paulo Reis 8 лет назад
Родитель
Сommit
7e8e2a89ae

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

@@ -3,6 +3,7 @@ aside.change-list(
 	ng-controller="HistoryV2ListController"
 	ng-controller="HistoryV2ListController"
 )
 )
 	history-entries-list(
 	history-entries-list(
+		ng-if="!history.showOnlyLabels"
 		entries="history.updates"
 		entries="history.updates"
 		current-user="user"
 		current-user="user"
 		users="projectUsers"
 		users="projectUsers"
@@ -13,6 +14,10 @@ aside.change-list(
 		on-entry-select="handleEntrySelect(selectedEntry)"
 		on-entry-select="handleEntrySelect(selectedEntry)"
 		on-label-delete="handleLabelDelete(label)"
 		on-label-delete="handleLabelDelete(label)"
 	)
 	)
+	history-labels-list(
+		ng-if="history.showOnlyLabels"
+		labels="history.labels"
+	)
 
 
 aside.change-list(
 aside.change-list(
 	ng-if="history.isV2 && history.viewMode === HistoryViewModes.COMPARE"
 	ng-if="history.isV2 && history.viewMode === HistoryViewModes.COMPARE"
@@ -193,4 +198,15 @@ script(type="text/ng-template", id="historyEntryTpl")
 					li.history-entry-metadata-user(ng-if="::$ctrl.entry.meta.users.length == 0")
 					li.history-entry-metadata-user(ng-if="::$ctrl.entry.meta.users.length == 0")
 						span.name(
 						span.name(
 							ng-style="$ctrl.getUserCSSStyle();"
 							ng-style="$ctrl.getUserCSSStyle();"
-						) #{translate("anonymous")}
+						) #{translate("anonymous")}
+
+script(type="text/ng-template", id="historyLabelsListTpl")
+	history-label(
+		ng-repeat="label in $ctrl.labels"
+		show-tooltip="false"
+		label-text="label.comment"
+		label-owner-name="$ctrl.displayNameById(label.user_id)"
+		label-creation-date-time="label.created_at"
+		is-owned-by-current-user="label.user_id === $ctrl.currentUser.id"
+		on-label-delete="$ctrl.onLabelDelete({ label: label })"
+	)

+ 29 - 0
services/web/public/coffee/ide/history/components/historyLabelsList.coffee

@@ -0,0 +1,29 @@
+define [
+	"base"
+	"ide/history/util/displayNameForUser"
+], (App, displayNameForUser) ->
+	historyLabelsListController = ($scope, $element, $attrs) ->
+		ctrl = @ 
+		# This method (and maybe the one below) will be removed soon. User details data will be 
+		# injected into the history API responses, so we won't need to fetch user data from other
+		# local data structures.
+		_getUserById = (id) ->
+			_.find ctrl.users, (user) ->
+				curUserId = user?._id or user?.id
+				curUserId == id
+		ctrl.displayName = displayNameForUser
+		ctrl.displayNameById = (id) ->
+			displayNameForUser(_getUserById(id))
+		return
+
+	App.component "historyLabelsList", {
+		bindings:
+			labels: "<"
+			users: "<"
+			isLoading: "<"
+			currentUser: "<"
+			onLabelSelect: "&"
+			onLabelDelete: "&"
+		controller: historyLabelsListController
+		templateUrl: "historyLabelsListTpl"
+	}

+ 8 - 0
services/web/public/stylesheets/app/editor/history-v2.less

@@ -27,6 +27,14 @@
 		margin-left: (@line-height-computed / 2);
 		margin-left: (@line-height-computed / 2);
 	}
 	}
 
 
+	.history-toolbar-entries-list {
+		position: absolute; 
+		right: 0;
+		width: @changesListWidth;
+		padding: 0 10px;
+		border-left: 1px solid @editor-border-color;
+	}
+
 .history-entries {
 .history-entries {
 	font-size: @history-base-font-size;
 	font-size: @history-base-font-size;
 	color: @history-base-color;
 	color: @history-base-color;