diff options
author | Shawn O. Pearce <sop@google.com> | 2009-03-26 18:00:33 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2009-03-26 18:00:33 -0700 |
commit | 47fcf3ee67595edcd4248f503c0deb16a2e417a0 (patch) | |
tree | dfd44445764a2dadddd01a5163659836e172e2f7 | |
parent | 65f147d95df961c2ea0b47efd32581ea18a3d94c (diff) |
Don't permit project rights to be created backwards (part II)
If the min value is larger than the max value, flip the order
around the other way. Its likely the user mixed up the fields
in the UI.
Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r-- | src/main/java/com/google/gerrit/client/admin/ProjectRightsPanel.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/java/com/google/gerrit/client/admin/ProjectRightsPanel.java b/src/main/java/com/google/gerrit/client/admin/ProjectRightsPanel.java index 477f3bd2e8..84c037e0ce 100644 --- a/src/main/java/com/google/gerrit/client/admin/ProjectRightsPanel.java +++ b/src/main/java/com/google/gerrit/client/admin/ProjectRightsPanel.java @@ -189,7 +189,7 @@ public class ProjectRightsPanel extends Composite { private void doAddNewRight() { int idx = catBox.getSelectedIndex(); final ApprovalType at; - final ApprovalCategoryValue min, max; + ApprovalCategoryValue min, max; if (idx < 0) { return; } @@ -224,6 +224,16 @@ public class ProjectRightsPanel extends Composite { return; } + if (min.getValue() > max.getValue()) { + // If the user selects it backwards in the web UI, help them out + // by reversing the order to what we would expect. + // + final ApprovalCategoryValue newMin = max; + final ApprovalCategoryValue newMax = min; + min = newMin; + max = newMax; + } + addRight.setEnabled(false); Util.PROJECT_SVC.addRight(projectId, at.getCategory().getId(), groupName, min.getValue(), max.getValue(), new GerritCallback<ProjectDetail>() { |