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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -157,6 +157,10 @@ public final class ApprovalCategory {
|
||||
return position < 0;
|
||||
}
|
||||
|
||||
public boolean isRange() {
|
||||
return !isAction();
|
||||
}
|
||||
|
||||
public String getFunctionName() {
|
||||
return functionName;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user