ChangeScreen2: Show on which categories a reviewer can vote
Old change screen had grey styled cells in approval table for labels a reviewer hadn't right to vote on. The new change screen uses chips to present the reviewers name and therefore this valuable information is lost. Add it back in form of tooltip with the list of votable labels for each reviewer. Bug: issue 2078 Change-Id: I0f101e43c625bfe1f181b46574c6677d930a5c19
This commit is contained in:
@@ -205,6 +205,8 @@ group names.
|
||||
|
||||
To remove reviewers click on the 'x' icon in the reviewer's "chip".
|
||||
|
||||
Votable categories are shown as a tooltip for each reviewer.
|
||||
|
||||
Key bindings: "c" to add a reviewer. "ESC" to close the drop down.
|
||||
|
||||
[[auto-refresh]]
|
||||
|
@@ -176,7 +176,7 @@ class Labels extends Grid {
|
||||
}
|
||||
html.append(val).append(" ");
|
||||
html.append(formatUserList(style, m.get(v),
|
||||
Collections.<Integer> emptySet()));
|
||||
Collections.<Integer> emptySet(), null));
|
||||
html.closeSpan();
|
||||
}
|
||||
return html.toBlockWidget();
|
||||
@@ -222,7 +222,8 @@ class Labels extends Grid {
|
||||
|
||||
static SafeHtml formatUserList(ChangeScreen2.Style style,
|
||||
Collection<? extends AccountInfo> in,
|
||||
Set<Integer> removable) {
|
||||
Set<Integer> removable,
|
||||
Map<Integer, VotableInfo> votable) {
|
||||
List<AccountInfo> users = new ArrayList<>(in);
|
||||
Collections.sort(users, new Comparator<AccountInfo>() {
|
||||
@Override
|
||||
@@ -261,13 +262,26 @@ class Labels extends Grid {
|
||||
name = Integer.toString(ai._account_id());
|
||||
}
|
||||
|
||||
String votableCategories = "";
|
||||
if (votable != null) {
|
||||
Set<String> s = votable.get(ai._account_id()).votableLabels();
|
||||
if (!s.isEmpty()) {
|
||||
StringBuilder sb = new StringBuilder(Util.C.votable());
|
||||
sb.append(" ");
|
||||
for (Iterator<String> it = s.iterator(); it.hasNext();) {
|
||||
sb.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
votableCategories = sb.toString();
|
||||
}
|
||||
}
|
||||
html.openSpan()
|
||||
.setAttribute("role", "listitem")
|
||||
.setAttribute(DATA_ID, ai._account_id())
|
||||
.setAttribute("title", getTitle(ai, votableCategories))
|
||||
.setStyleName(style.label_user());
|
||||
if (ai.email() != null) {
|
||||
html.setAttribute("title", ai.email());
|
||||
}
|
||||
if (img != null) {
|
||||
html.openElement("img")
|
||||
.setStyleName(style.avatar())
|
||||
@@ -295,4 +309,15 @@ class Labels extends Grid {
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
private static String getTitle(AccountInfo ai, String votableCategories) {
|
||||
String title = ai.email() != null ? ai.email() : "";
|
||||
if (!votableCategories.isEmpty()) {
|
||||
if (!title.isEmpty()) {
|
||||
title += " ";
|
||||
}
|
||||
title += votableCategories;
|
||||
}
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
@@ -231,10 +231,35 @@ class Reviewers extends Composite {
|
||||
}
|
||||
}
|
||||
|
||||
SafeHtml rHtml = Labels.formatUserList(style, r.values(), removable);
|
||||
SafeHtml ccHtml = Labels.formatUserList(style, cc.values(), removable);
|
||||
Map<Integer, VotableInfo> votable = votable(info);
|
||||
|
||||
SafeHtml rHtml = Labels.formatUserList(style,
|
||||
r.values(), removable, votable);
|
||||
SafeHtml ccHtml = Labels.formatUserList(style,
|
||||
cc.values(), removable, votable);
|
||||
|
||||
reviewersText.setInnerSafeHtml(rHtml);
|
||||
ccText.setInnerSafeHtml(ccHtml);
|
||||
}
|
||||
|
||||
private static Map<Integer, VotableInfo> votable(ChangeInfo change) {
|
||||
Map<Integer, VotableInfo> d = new HashMap<>();
|
||||
for (String name : change.labels()) {
|
||||
LabelInfo label = change.label(name);
|
||||
if (label.all() != null) {
|
||||
for (ApprovalInfo ai : Natives.asList(label.all())) {
|
||||
int id = ai._account_id();
|
||||
VotableInfo ad = d.get(id);
|
||||
if (ad == null) {
|
||||
ad = new VotableInfo();
|
||||
d.put(id, ad);
|
||||
}
|
||||
if (ai.has_value()) {
|
||||
ad.votable(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.change;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
class VotableInfo {
|
||||
private Set<String> votable;
|
||||
|
||||
void votable(String label) {
|
||||
if (votable == null) {
|
||||
votable = new HashSet<>();
|
||||
}
|
||||
votable.add(label);
|
||||
}
|
||||
|
||||
Set<String> votableLabels() {
|
||||
Set<String> s = new HashSet<>();
|
||||
if (votable != null) {
|
||||
s.addAll(votable);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
@@ -211,4 +211,6 @@ public interface ChangeConstants extends Constants {
|
||||
String oneWeekAgo();
|
||||
String oneMonthAgo();
|
||||
String oneYearAgo();
|
||||
|
||||
String votable();
|
||||
}
|
||||
|
@@ -193,3 +193,5 @@ oneDayAgo = 1 day ago
|
||||
oneWeekAgo = 1 week ago
|
||||
oneMonthAgo = 1 month ago
|
||||
oneYearAgo = 1 year ago
|
||||
|
||||
votable = Votable:
|
||||
|
Reference in New Issue
Block a user