ItEr37S06ValidacionEProbasFuncionaisItEr36S07: Using zk constraint for resources per day in order to show feedback sooner
This commit is contained in:
parent
89b4f0936b
commit
79abecd496
2 changed files with 30 additions and 6 deletions
|
|
@ -49,6 +49,10 @@ import org.zkoss.zul.SimpleConstraint;
|
|||
*/
|
||||
public abstract class AllocationRow {
|
||||
|
||||
public static final SimpleConstraint CONSTRAINT_FOR_RESOURCES_PER_DAY = new SimpleConstraint(
|
||||
SimpleConstraint.NO_EMPTY
|
||||
| SimpleConstraint.NO_ZERO | SimpleConstraint.NO_NEGATIVE);
|
||||
|
||||
public static void assignHours(List<AllocationRow> rows, int[] hours) {
|
||||
int i = 0;
|
||||
for (AllocationRow each : rows) {
|
||||
|
|
@ -275,15 +279,26 @@ public abstract class AllocationRow {
|
|||
hoursInput
|
||||
.setDisabled(calculatedValue != CalculatedValue.RESOURCES_PER_DAY
|
||||
|| recommendedAllocation);
|
||||
if (!hoursInput.isDisabled()) {
|
||||
hoursInput.setConstraint(new SimpleConstraint(
|
||||
SimpleConstraint.NO_EMPTY | SimpleConstraint.NO_NEGATIVE));
|
||||
} else {
|
||||
hoursInput.setConstraint((Constraint) null);
|
||||
}
|
||||
hoursInput.setConstraint(constraintForHoursInput());
|
||||
resourcesPerDayInput
|
||||
.setDisabled(calculatedValue == CalculatedValue.RESOURCES_PER_DAY
|
||||
|| recommendedAllocation);
|
||||
resourcesPerDayInput.setConstraint(constraintForResourcesPerDayInput());
|
||||
}
|
||||
|
||||
private Constraint constraintForHoursInput() {
|
||||
if (hoursInput.isDisabled()) {
|
||||
return null;
|
||||
}
|
||||
return new SimpleConstraint(SimpleConstraint.NO_EMPTY
|
||||
| SimpleConstraint.NO_NEGATIVE);
|
||||
}
|
||||
|
||||
private Constraint constraintForResourcesPerDayInput() {
|
||||
if (resourcesPerDayInput.isDisabled()) {
|
||||
return null;
|
||||
}
|
||||
return CONSTRAINT_FOR_RESOURCES_PER_DAY;
|
||||
}
|
||||
|
||||
public void loadDataFromLast() {
|
||||
|
|
|
|||
|
|
@ -296,6 +296,15 @@ class FormBinder {
|
|||
this.allResourcesPerDay.setVisible(recommendedAllocation);
|
||||
this.allResourcesPerDay.setDisabled(allocationRowsHandler
|
||||
.getCalculatedValue() == CalculatedValue.RESOURCES_PER_DAY);
|
||||
this.allResourcesPerDay
|
||||
.setConstraint(constraintForAllResourcesPerDay());
|
||||
}
|
||||
|
||||
private Constraint constraintForAllResourcesPerDay() {
|
||||
if (!allResourcesPerDay.isVisible() || allResourcesPerDay.isDisabled()) {
|
||||
return null;
|
||||
}
|
||||
return AllocationRow.CONSTRAINT_FOR_RESOURCES_PER_DAY;
|
||||
}
|
||||
|
||||
public List<AllocationRow> getCurrentRows() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue