Hide approval category range for action types

Actions like Push Branch, Submit and Read don't really make sense as
a range of permissible values.  The code checks only that the user's
effective maximum is greater than or equal to the necessary level.
Hide one of the selection boxes when an action is being used.

Change-Id: I023becdee29fc977801b3ec07f502adf4cd961fb
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-05-10 09:14:34 -07:00
parent 6064fbe02a
commit 2f1f80687e
2 changed files with 29 additions and 10 deletions

View File

@@ -279,13 +279,27 @@ public class ProjectRightsPanel extends Composite {
return;
}
idx = rangeMaxBox.getSelectedIndex();
if (idx < 0) {
return;
}
max = at.getValue(Short.parseShort(rangeMaxBox.getValue(idx)));
if (max == null) {
return;
if (at.getCategory().isRange()) {
idx = rangeMaxBox.getSelectedIndex();
if (idx < 0) {
return;
}
max = at.getValue(Short.parseShort(rangeMaxBox.getValue(idx)));
if (max == null) {
return;
}
} else {
// If its not a range, the maximum box was disabled. Use the min
// value as the max, and select the min from the category values.
//
max = min;
min = at.getMin();
for (ApprovalCategoryValue v : at.getValues()) {
if (0 <= v.getValue() && v.getValue() <= max.getValue()) {
min = v;
break;
}
}
}
final String groupName = nameTxt.getText();
@@ -373,6 +387,7 @@ public class ProjectRightsPanel extends Composite {
}
rangeMinBox.setSelectedIndex(minIndex >= 0 ? minIndex : 0);
rangeMaxBox.setSelectedIndex(maxIndex >= 0 ? maxIndex : curIndex - 1);
rangeMaxBox.setVisible(at.getCategory().isRange());
addRight.setEnabled(true);
}
@@ -472,11 +487,11 @@ public class ProjectRightsPanel extends Composite {
min = ar != null ? ar.getValue(right.getMinValue()) : null;
max = ar != null ? ar.getValue(right.getMaxValue()) : null;
formatValue(m, right.getMinValue(), min);
if (right.getMinValue() != right.getMaxValue()) {
if (ar != null && ar.getCategory().isRange()) {
formatValue(m, right.getMinValue(), min);
m.br();
formatValue(m, right.getMaxValue(), max);
}
formatValue(m, right.getMaxValue(), max);
SafeHtml.set(table, row, 5, m);
}

View File

@@ -157,6 +157,10 @@ public final class ApprovalCategory {
return position < 0;
}
public boolean isRange() {
return !isAction();
}
public String getFunctionName() {
return functionName;
}