ChangeScreen: Hide assignee link on edit

When editing the assignee an input box was shown below the current
assignee. This gave the impression like another assignee is added
(similar to how more reviewers can be added), but not that the current
assignee is edited. Instead hide the assignee link when the assignee
is edited and populate the input box with the current assignee. This
is similar to how editing the topic works. The text with current
assignee in the input box is selected so that it can be easily erased
by typing a new assignee.

Change-Id: I3d2533c018ddd4018199e68c0b7e5c3205f35856
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-09-30 10:01:14 +02:00
parent a8dc0c074b
commit cbda5bae31
3 changed files with 20 additions and 10 deletions

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.client.change;
import com.google.gerrit.client.FormatUtil;
import com.google.gerrit.client.NotSignedInDialog;
import com.google.gerrit.client.changes.ChangeApi;
import com.google.gerrit.client.changes.Util;
@@ -50,20 +51,18 @@ public class Assignee extends Composite {
private static final Binder uiBinder = GWT.create(Binder.class);
@UiField
InlineHyperlink assigneeLink;
@UiField
Image editAssigneeIcon;
@UiField
Element form;
@UiField
Element error;
@UiField Element show;
@UiField InlineHyperlink assigneeLink;
@UiField Image editAssigneeIcon;
@UiField Element form;
@UiField Element error;
@UiField(provided = true)
RemoteSuggestBox suggestBox;
private AssigneeSuggestOracle assigneeSuggestOracle;
private Change.Id changeId;
private boolean canEdit;
private AccountInfo currentAssignee;
Assignee() {
assigneeSuggestOracle = new AssigneeSuggestOracle();
@@ -98,18 +97,24 @@ public class Assignee extends Composite {
setAssignee(info.assignee());
assigneeSuggestOracle.setChange(changeId);
editAssigneeIcon.setVisible(canEdit);
if (!canEdit) {
show.setTitle(null);
}
}
void onOpenForm() {
UIObject.setVisible(form, true);
UIObject.setVisible(show, false);
UIObject.setVisible(error, false);
editAssigneeIcon.setVisible(false);
suggestBox.setFocus(true);
suggestBox.setText("");
suggestBox.setText(FormatUtil.nameEmail(currentAssignee));
suggestBox.selectAll();
}
void onCloseForm() {
UIObject.setVisible(form, false);
UIObject.setVisible(show, true);
UIObject.setVisible(error, false);
editAssigneeIcon.setVisible(true);
suggestBox.setFocus(false);
@@ -174,6 +179,7 @@ public class Assignee extends Composite {
}
private void setAssignee(AccountInfo assignee) {
currentAssignee = assignee;
assigneeLink.setText(assignee != null ? assignee.name() : null);
assigneeLink.setTargetHistoryToken(assignee != null
? PageLinks.toAssigneeQuery(assignee.name() != null

View File

@@ -38,7 +38,7 @@ limitations under the License.
}
</ui:style>
<g:HTMLPanel>
<div>
<div ui:field='show'>
<u:InlineHyperlink ui:field='assigneeLink'
title='Search for changes assigned to this user'/>
<g:Image ui:field='editAssigneeIcon'

View File

@@ -134,4 +134,8 @@ public class RemoteSuggestBox extends Composite implements Focusable, HasText,
public HandlerRegistration addCloseHandler(CloseHandler<RemoteSuggestBox> h) {
return addHandler(h, CloseEvent.getType());
}
public void selectAll() {
suggestBox.getValueBox().selectAll();
}
}