ItEr37S08CUCreacionUnidadesPlanificacionItEr36S11: The total hours is kept synchronized with the hours inputs when they are changed.
This commit is contained in:
parent
e614632a01
commit
8aef6af117
2 changed files with 30 additions and 1 deletions
|
|
@ -244,7 +244,7 @@ public abstract class AllocationRow {
|
|||
if (origin != null) {
|
||||
return origin.getAssignedHours();
|
||||
}
|
||||
return null;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void applyDisabledRules(CalculatedValue calculatedValue) {
|
||||
|
|
@ -258,4 +258,8 @@ public abstract class AllocationRow {
|
|||
hoursInput.setValue(last.getAssignedHours());
|
||||
resourcesPerDayInput.setValue(last.getResourcesPerDay().getAmount());
|
||||
}
|
||||
|
||||
public void addListenerForHoursInputChange(EventListener listener) {
|
||||
hoursInput.addEventListener(Events.ON_CHANGE, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,16 @@ class FormBinder {
|
|||
|
||||
private EventListener recommendedCheckboxListener;
|
||||
|
||||
private EventListener hoursInputChange = new EventListener() {
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
if (assignedHoursComponent.isDisabled()) {
|
||||
assignedHoursComponent.setValue(sumAllHoursFromHoursInputs());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public FormBinder(
|
||||
AllocationRowsHandler allocationRowsHandler,
|
||||
IResourceAllocationModel resourceAllocationModel) {
|
||||
|
|
@ -163,6 +173,20 @@ class FormBinder {
|
|||
}
|
||||
}
|
||||
|
||||
private void bindTotalHoursToHoursInputs() {
|
||||
for (AllocationRow each : rows) {
|
||||
each.addListenerForHoursInputChange(hoursInputChange);
|
||||
}
|
||||
}
|
||||
|
||||
private int sumAllHoursFromHoursInputs() {
|
||||
int result = 0;
|
||||
for (AllocationRow each : rows) {
|
||||
result += each.getHoursFromInput();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public CalculatedValue getCalculatedValue() {
|
||||
return allocationRowsHandler.getCalculatedValue();
|
||||
}
|
||||
|
|
@ -221,6 +245,7 @@ class FormBinder {
|
|||
.getCurrentRows());
|
||||
rows = result;
|
||||
applyDisabledRulesOnRows();
|
||||
bindTotalHoursToHoursInputs();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue