Now, when doing a resource allocation, instead of specifying an 'end date' the user will input a duration in days.
* Change field 'End date' (Datebox) in Allocation configuration to 'Workable days' (Decimalbox) * The field is set first as the difference between task.end - task.start * Task stores now a new 'workableDays' field that is used when doing the resource allocations * Do some UI improvements (rearrange buttons, layout, etc) FEA: ItEr61OTS04PlanificacionHaciaAtras
This commit is contained in:
parent
0549f8d22b
commit
c0a53675e7
13 changed files with 206 additions and 119 deletions
|
|
@ -25,5 +25,5 @@ package org.navalplanner.business.planner.entities;
|
|||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*/
|
||||
public enum CalculatedValue {
|
||||
NUMBER_OF_HOURS, END_DATE, RESOURCES_PER_DAY;
|
||||
NUMBER_OF_HOURS, WORKABLE_DAYS, RESOURCES_PER_DAY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
|
|||
setIntraDayEndDate(newEnd);
|
||||
}
|
||||
|
||||
private CalculatedValue calculatedValue = CalculatedValue.END_DATE;
|
||||
private CalculatedValue calculatedValue = CalculatedValue.WORKABLE_DAYS;
|
||||
|
||||
private Set<ResourceAllocation<?>> resourceAllocations = new HashSet<ResourceAllocation<?>>();
|
||||
|
||||
|
|
@ -256,7 +256,7 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
|
|||
|
||||
public CalculatedValue getCalculatedValue() {
|
||||
if (calculatedValue == null) {
|
||||
return CalculatedValue.END_DATE;
|
||||
return CalculatedValue.WORKABLE_DAYS;
|
||||
}
|
||||
return calculatedValue;
|
||||
}
|
||||
|
|
@ -524,7 +524,7 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
|
|||
ResourceAllocation.allocating(allocations)
|
||||
.allocateOnTaskLength();
|
||||
break;
|
||||
case END_DATE:
|
||||
case WORKABLE_DAYS:
|
||||
IntraDayDate end = ResourceAllocation
|
||||
.allocating(allocations)
|
||||
.untilAllocating(getAssignedHours());
|
||||
|
|
@ -627,7 +627,7 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
|
|||
|
||||
@Override
|
||||
protected boolean canBeResized() {
|
||||
return ((calculatedValue != CalculatedValue.END_DATE) || (resourceAllocations
|
||||
return ((calculatedValue != CalculatedValue.WORKABLE_DAYS) || (resourceAllocations
|
||||
.isEmpty()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,6 +118,8 @@ public abstract class TaskElement extends BaseEntity {
|
|||
|
||||
private IntraDayDate endDate;
|
||||
|
||||
private BigDecimal workableDays;
|
||||
|
||||
private LocalDate deadline;
|
||||
|
||||
private String name;
|
||||
|
|
@ -171,7 +173,6 @@ public abstract class TaskElement extends BaseEntity {
|
|||
this.taskSource = task.getTaskSource();
|
||||
}
|
||||
|
||||
|
||||
public TaskSource getTaskSource() {
|
||||
return taskSource;
|
||||
}
|
||||
|
|
@ -603,4 +604,12 @@ public abstract class TaskElement extends BaseEntity {
|
|||
return sumOfHoursAllocated;
|
||||
}
|
||||
|
||||
public void setWorkableDays(BigDecimal workableDays) {
|
||||
this.workableDays = workableDays;
|
||||
}
|
||||
|
||||
public BigDecimal getWorkableDays() {
|
||||
return workableDays;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class TaskMilestone extends TaskElement implements ITaskLeafConstraint {
|
|||
return createWithoutTaskSource(milestone);
|
||||
}
|
||||
|
||||
private CalculatedValue calculatedValue = CalculatedValue.END_DATE;
|
||||
private CalculatedValue calculatedValue = CalculatedValue.WORKABLE_DAYS;
|
||||
|
||||
private TaskStartConstraint startConstraint = new TaskStartConstraint();
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ public class TaskMilestone extends TaskElement implements ITaskLeafConstraint {
|
|||
|
||||
public CalculatedValue getCalculatedValue() {
|
||||
if (calculatedValue == null) {
|
||||
return CalculatedValue.END_DATE;
|
||||
return CalculatedValue.WORKABLE_DAYS;
|
||||
}
|
||||
return calculatedValue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ public class AdvancedAllocationController extends GenericForwardComposer {
|
|||
|
||||
public static Restriction build(IRestrictionSource restrictionSource) {
|
||||
switch (restrictionSource.getCalculatedValue()) {
|
||||
case END_DATE:
|
||||
case WORKABLE_DAYS:
|
||||
return Restriction.fixedHours(restrictionSource.getStart(),
|
||||
restrictionSource.getTotalHours());
|
||||
case NUMBER_OF_HOURS:
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ public class AllocationRowsHandler {
|
|||
switch (calculatedValue) {
|
||||
case NUMBER_OF_HOURS:
|
||||
break;
|
||||
case END_DATE:
|
||||
case WORKABLE_DAYS:
|
||||
case RESOURCES_PER_DAY:
|
||||
return calculateHoursGroupByResourceType(type);
|
||||
}
|
||||
|
|
@ -208,7 +208,7 @@ public class AllocationRowsHandler {
|
|||
&& !currentRows.isEmpty() && formBinder.getAssignedHours() <= 0) {
|
||||
formBinder.markAssignedHoursMustBePositive();
|
||||
}
|
||||
if (calculatedValue != CalculatedValue.END_DATE
|
||||
if (calculatedValue != CalculatedValue.WORKABLE_DAYS
|
||||
&& formBinder.getAllocationEnd().isBefore(
|
||||
new LocalDate(task.getStartDate()))) {
|
||||
formBinder.markEndDateMustBeAfterStartDate();
|
||||
|
|
@ -238,7 +238,7 @@ public class AllocationRowsHandler {
|
|||
case NUMBER_OF_HOURS:
|
||||
calculateNumberOfHoursAllocation();
|
||||
break;
|
||||
case END_DATE:
|
||||
case WORKABLE_DAYS:
|
||||
calculateEndDateAllocation();
|
||||
break;
|
||||
case RESOURCES_PER_DAY:
|
||||
|
|
|
|||
|
|
@ -55,9 +55,7 @@ import org.zkoss.zk.ui.event.EventListener;
|
|||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.util.Clients;
|
||||
import org.zkoss.zul.Button;
|
||||
import org.zkoss.zul.Checkbox;
|
||||
import org.zkoss.zul.Constraint;
|
||||
import org.zkoss.zul.Datebox;
|
||||
import org.zkoss.zul.Decimalbox;
|
||||
import org.zkoss.zul.Grid;
|
||||
import org.zkoss.zul.Intbox;
|
||||
|
|
@ -83,8 +81,6 @@ public class FormBinder {
|
|||
|
||||
private AllocationResult lastAllocation;
|
||||
|
||||
private Datebox endDate;
|
||||
|
||||
private Button applyButton;
|
||||
|
||||
private EventListener onChangeEnableApply = new EventListener() {
|
||||
|
|
@ -115,9 +111,13 @@ public class FormBinder {
|
|||
|
||||
private List<AllocationRow> rows = Collections.emptyList();
|
||||
|
||||
private Checkbox recommendedAllocationCheckbox;
|
||||
private Decimalbox taskWorkableDays;
|
||||
|
||||
private EventListener recommendedCheckboxListener;
|
||||
private Date taskStartDate;
|
||||
|
||||
private Button btnRecommendedAllocation;
|
||||
|
||||
private boolean recommendedAllocationIsPressed = false;
|
||||
|
||||
private ProportionalDistributor hoursDistributorForRecommendedAllocation;
|
||||
|
||||
|
|
@ -215,14 +215,13 @@ public class FormBinder {
|
|||
}
|
||||
allocationRowsHandler.setCalculatedValue(calculatedValue);
|
||||
applyDisabledRules();
|
||||
loadValueForEndDate();
|
||||
sumResourcesPerDayFromRowsAndAssignToAllResourcesPerDay();
|
||||
applyButton.setDisabled(false);
|
||||
}
|
||||
|
||||
private void applyDisabledRules() {
|
||||
allHoursInputComponentDisabilityRule();
|
||||
endDateDisabilityRule();
|
||||
taskDurationDisabilityRule();
|
||||
allResourcesPerDayVisibilityRule();
|
||||
applyDisabledRulesOnRows();
|
||||
}
|
||||
|
|
@ -282,15 +281,16 @@ public class FormBinder {
|
|||
|
||||
private void onChangeEnableApply(InputElement inputElement) {
|
||||
inputElement.addEventListener(Events.ON_CHANGE, onChangeEnableApply);
|
||||
|
||||
}
|
||||
|
||||
public void setEndDate(Datebox endDate) {
|
||||
this.endDate = endDate;
|
||||
this.endDate.setConstraint(datePosteriorOrEqualToStartDate());
|
||||
endDateDisabilityRule();
|
||||
loadValueForEndDate();
|
||||
onChangeEnableApply(endDate);
|
||||
public void setStartDate(Date startDate) {
|
||||
this.taskStartDate = startDate;
|
||||
}
|
||||
|
||||
public void setWorkableDays(Decimalbox duration) {
|
||||
this.taskWorkableDays = duration;
|
||||
taskDurationDisabilityRule();
|
||||
onChangeEnableApply(taskWorkableDays);
|
||||
}
|
||||
|
||||
public void setAllResourcesPerDay(Decimalbox allResourcesPerDay) {
|
||||
|
|
@ -301,28 +301,9 @@ public class FormBinder {
|
|||
onChangeEnableApply(allResourcesPerDay);
|
||||
}
|
||||
|
||||
private Constraint datePosteriorOrEqualToStartDate() {
|
||||
return new Constraint() {
|
||||
@Override
|
||||
public void validate(Component comp, Object value)
|
||||
throws WrongValueException {
|
||||
Date date = (Date) value;
|
||||
LocalDate startDate = allocationRowsHandler.getStartDate();
|
||||
if (new LocalDate(date).isBefore(startDate)) {
|
||||
throw new WrongValueException(comp, _(
|
||||
"{0} must not be before {1}", date, startDate));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void loadValueForEndDate() {
|
||||
this.endDate.setValue(allocationRowsHandler.getEnd());
|
||||
}
|
||||
|
||||
private void endDateDisabilityRule() {
|
||||
this.endDate.setDisabled(allocationRowsHandler
|
||||
.getCalculatedValue() == CalculatedValue.END_DATE);
|
||||
private void taskDurationDisabilityRule() {
|
||||
this.taskWorkableDays.setDisabled(allocationRowsHandler
|
||||
.getCalculatedValue() == CalculatedValue.WORKABLE_DAYS);
|
||||
}
|
||||
|
||||
private void allResourcesPerDayVisibilityRule() {
|
||||
|
|
@ -390,7 +371,6 @@ public class FormBinder {
|
|||
loadResourcesPerDay();
|
||||
loadHoursValues();
|
||||
loadValueForAssignedHoursComponent();
|
||||
loadValueForEndDate();
|
||||
loadDerivedAllocations();
|
||||
loadSclassRowSatisfied();
|
||||
Util.reloadBindings(allocationsGrid);
|
||||
|
|
@ -456,7 +436,8 @@ public class FormBinder {
|
|||
}
|
||||
|
||||
public LocalDate getAllocationEnd() {
|
||||
return new LocalDate(endDate.getValue());
|
||||
LocalDate result = new LocalDate(taskStartDate);
|
||||
return result.plusDays(taskWorkableDays.getValue().intValue());
|
||||
}
|
||||
|
||||
public void setDeleteButtonFor(AllocationRow row,
|
||||
|
|
@ -515,7 +496,7 @@ public class FormBinder {
|
|||
DateTimeFormatter formatter = ISODateTimeFormat.basicDate().withLocale(
|
||||
Locales.getCurrent());
|
||||
LocalDate start = allocationRowsHandler.getStartDate();
|
||||
throw new WrongValueException(endDate, _(
|
||||
throw new WrongValueException(taskWorkableDays, _(
|
||||
"end date: {0} must be after start date: {1}",
|
||||
getAllocationEnd().toString(formatter), start
|
||||
.toString(formatter)));
|
||||
|
|
@ -546,35 +527,25 @@ public class FormBinder {
|
|||
this.applyButton.removeEventListener(Events.ON_CLICK,
|
||||
applyButtonListener);
|
||||
}
|
||||
if (this.recommendedAllocationCheckbox != null) {
|
||||
this.recommendedAllocationCheckbox.removeEventListener(
|
||||
Events.ON_CHECK, recommendedCheckboxListener);
|
||||
}
|
||||
for (InputElement inputElement : inputsAssociatedWithOnChangeEnableApply) {
|
||||
inputElement.removeEventListener(Events.ON_CHANGE,
|
||||
onChangeEnableApply);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCheckbox(Checkbox recommendedAllocation) {
|
||||
this.recommendedAllocationCheckbox = recommendedAllocation;
|
||||
this.recommendedAllocationCheckbox
|
||||
.setChecked(this.recommendedAllocation);
|
||||
disableIfNeededWorkerSearch();
|
||||
recommendedCheckboxListener = new EventListener() {
|
||||
|
||||
public void setRecommendedAllocation(Button recommendedAllocation) {
|
||||
this.btnRecommendedAllocation = recommendedAllocation;
|
||||
btnRecommendedAllocation.addEventListener(Events.ON_CLICK, new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
if (recommendedAllocationCheckbox.isChecked()) {
|
||||
activatingRecommendedAllocation();
|
||||
} else {
|
||||
deactivatingRecommendedAllocation();
|
||||
}
|
||||
recommendedAllocationIsPressed = !recommendedAllocationIsPressed;
|
||||
if (recommendedAllocationIsPressed) {
|
||||
activatingRecommendedAllocation();
|
||||
} else {
|
||||
deactivatingRecommendedAllocation();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
this.recommendedAllocationCheckbox.addEventListener(Events.ON_CHECK,
|
||||
recommendedCheckboxListener);
|
||||
});
|
||||
}
|
||||
|
||||
private void activatingRecommendedAllocation() {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.navalplanner.web.planner.allocation;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -77,4 +78,10 @@ public interface IResourceAllocationModel extends INewAllocationsAdder {
|
|||
|
||||
void setStartDate(Date date);
|
||||
|
||||
}
|
||||
Date getTaskEnd();
|
||||
|
||||
BigDecimal getTaskDuration();
|
||||
|
||||
void setWorkableDays(BigDecimal decimal);
|
||||
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@ package org.navalplanner.web.planner.allocation;
|
|||
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
|
@ -31,6 +32,7 @@ import java.util.List;
|
|||
import org.apache.commons.lang.Validate;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.orders.entities.AggregatedHoursGroup;
|
||||
import org.navalplanner.business.planner.entities.CalculatedValue;
|
||||
import org.navalplanner.business.planner.entities.DerivedAllocation;
|
||||
|
|
@ -44,6 +46,7 @@ import org.navalplanner.web.common.components.AllocationSelector;
|
|||
import org.navalplanner.web.common.components.NewAllocationSelector;
|
||||
import org.navalplanner.web.common.components.NewAllocationSelectorCombo;
|
||||
import org.navalplanner.web.planner.order.PlanningState;
|
||||
import org.navalplanner.web.planner.taskedition.EditTaskController;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
|
||||
|
|
@ -56,12 +59,12 @@ import org.zkoss.zk.ui.Component;
|
|||
import org.zkoss.zk.ui.WrongValueException;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Button;
|
||||
import org.zkoss.zul.Checkbox;
|
||||
import org.zkoss.zul.Column;
|
||||
import org.zkoss.zul.Columns;
|
||||
import org.zkoss.zul.Datebox;
|
||||
import org.zkoss.zul.Decimalbox;
|
||||
import org.zkoss.zul.Grid;
|
||||
import org.zkoss.zul.Hbox;
|
||||
|
|
@ -74,6 +77,7 @@ import org.zkoss.zul.Row;
|
|||
import org.zkoss.zul.RowRenderer;
|
||||
import org.zkoss.zul.SimpleListModel;
|
||||
import org.zkoss.zul.Tab;
|
||||
import org.zkoss.zul.Vbox;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
/**
|
||||
|
|
@ -106,11 +110,14 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
|
||||
private Radiogroup calculationTypeSelector;
|
||||
|
||||
private Checkbox recommendedAllocationCheckbox;
|
||||
private Button btnRecommendedAllocation;
|
||||
|
||||
private Checkbox extendedViewCheckbox;
|
||||
|
||||
private Datebox taskEndDate;
|
||||
private Decimalbox dbTaskWorkableDays;
|
||||
|
||||
// Orientative task end according to number of workable days
|
||||
private Date plannedTaskEnd;
|
||||
|
||||
private Decimalbox allResourcesPerDay;
|
||||
|
||||
|
|
@ -144,10 +151,15 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
.retrieve();
|
||||
}
|
||||
|
||||
private EditTaskController editTaskController;
|
||||
|
||||
public void setEditTaskController(EditTaskController editTaskController) {
|
||||
this.editTaskController = editTaskController;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
taskEndDate = new Datebox();
|
||||
allResourcesPerDay = new Decimalbox();
|
||||
allResourcesPerDay.setWidth("80px");
|
||||
newAllocationSelector.setLimitingResourceFilter(false);
|
||||
|
|
@ -155,7 +167,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
initAllocationLabels();
|
||||
makeReadyInputsForCalculationTypes();
|
||||
prepareCalculationTypesGrid();
|
||||
|
||||
}
|
||||
|
||||
private void initAllocationLabels() {
|
||||
|
|
@ -168,8 +179,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
private void makeReadyInputsForCalculationTypes() {
|
||||
final String width = "90px";
|
||||
taskEndDate.setWidth(width);
|
||||
assignedHoursComponent = new Intbox();
|
||||
assignedHoursComponent.setWidth("80px");
|
||||
}
|
||||
|
|
@ -186,8 +195,7 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
|
||||
@Override
|
||||
public Component cellFor(Integer column, CalculationTypeRadio data) {
|
||||
return data.createComponent(getController(),
|
||||
getCalculationTypeRadio());
|
||||
return data.createRadio(getCalculationTypeRadio());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -218,6 +226,8 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
}
|
||||
allocationRows = resourceAllocationModel.initAllocationsFor(task,
|
||||
context, planningState);
|
||||
initTaskWorkableDays(task);
|
||||
|
||||
formBinder = allocationRows.createFormBinder(planningState
|
||||
.getCurrentScenario(), resourceAllocationModel);
|
||||
formBinder.setAllOriginalHours(allOriginalHours);
|
||||
|
|
@ -230,14 +240,14 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
.setAllConsolidatedResourcesPerDay(allConsolidatedResourcesPerDay);
|
||||
formBinder.setAllResourcesPerDay(allResourcesPerDay);
|
||||
|
||||
formBinder.setEndDate(taskEndDate);
|
||||
formBinder.setWorkableDays(dbTaskWorkableDays);
|
||||
formBinder.setApplyButton(applyButton);
|
||||
formBinder.setAllocationsGrid(allocationsGrid);
|
||||
formBinder.setMessagesForUser(messagesForUser);
|
||||
formBinder.setWorkerSearchTab(workerSearchTab);
|
||||
formBinder
|
||||
.setNewAllocationSelectorCombo(newAllocationSelectorCombo);
|
||||
formBinder.setCheckbox(recommendedAllocationCheckbox);
|
||||
formBinder.setRecommendedAllocation(btnRecommendedAllocation);
|
||||
|
||||
CalculationTypeRadio calculationTypeRadio = CalculationTypeRadio
|
||||
.from(formBinder.getCalculatedValue());
|
||||
|
|
@ -256,12 +266,61 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
}
|
||||
}
|
||||
|
||||
public Date getTaskStart() {
|
||||
private Label lbTaskEnd;
|
||||
|
||||
private void initTaskWorkableDays(org.navalplanner.business.planner.entities.Task task) {
|
||||
dbTaskWorkableDays.setValue(new BigDecimal(task.getDaysDuration()));
|
||||
plannedTaskEnd = resourceAllocationModel.getTaskEnd();
|
||||
dbTaskWorkableDays.setValue(resourceAllocationModel.getTaskDuration());
|
||||
dbTaskWorkableDays.addEventListener(Events.ON_CHANGE, new EventListener() {
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
Decimalbox decimalbox = (Decimalbox) event.getTarget();
|
||||
setTaskWorkableDays(decimalbox.getValue());
|
||||
setPlannedTaskEnd(calculateEndDate(getDuration(decimalbox)));
|
||||
updateTaskEndDateInTaskPropertiesPanel(getPlannedTaskEnd());
|
||||
Util.reloadBindings(lbTaskEnd);
|
||||
}
|
||||
|
||||
private int getDuration(Decimalbox decimalbox) {
|
||||
return decimalbox.getValue() != null ? decimalbox.getValue().toBigInteger().intValue() : 0;
|
||||
}
|
||||
|
||||
private void updateTaskEndDateInTaskPropertiesPanel(Date endDate) {
|
||||
editTaskController.getTaskPropertiesController().updateTaskEndDate(endDate);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private Date calculateEndDate(int duration) {
|
||||
LocalDate result = new LocalDate(getPlannedTaskStart());
|
||||
result = result.plusDays(duration);
|
||||
return toDate(result);
|
||||
}
|
||||
|
||||
private Date toDate(LocalDate date) {
|
||||
return date.toDateTimeAtStartOfDay().toDate();
|
||||
}
|
||||
|
||||
public Date getPlannedTaskStart() {
|
||||
return resourceAllocationModel.getTaskStart();
|
||||
}
|
||||
|
||||
public enum HoursRendererColumn {
|
||||
public Date getPlannedTaskEnd() {
|
||||
return plannedTaskEnd;
|
||||
}
|
||||
|
||||
private void setPlannedTaskEnd(Date taskEnd) {
|
||||
this.plannedTaskEnd = taskEnd;
|
||||
}
|
||||
|
||||
private void setTaskWorkableDays(BigDecimal decimal) {
|
||||
resourceAllocationModel.setWorkableDays(decimal);
|
||||
}
|
||||
|
||||
public enum HoursRendererColumn {
|
||||
|
||||
CRITERIONS {
|
||||
@Override
|
||||
|
|
@ -385,6 +444,18 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
|
||||
public enum CalculationTypeRadio {
|
||||
|
||||
WORKABLE_DAYS(CalculatedValue.WORKABLE_DAYS) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return _("Calculate Workable Days");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component input(
|
||||
ResourceAllocationController resourceAllocationController) {
|
||||
return resourceAllocationController.dbTaskWorkableDays;
|
||||
}
|
||||
},
|
||||
NUMBER_OF_HOURS(CalculatedValue.NUMBER_OF_HOURS) {
|
||||
@Override
|
||||
public String getName() {
|
||||
|
|
@ -397,18 +468,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
return resourceAllocationController.assignedHoursComponent;
|
||||
}
|
||||
},
|
||||
END_DATE(CalculatedValue.END_DATE) {
|
||||
@Override
|
||||
public String getName() {
|
||||
return _("Calculate End Date");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component input(
|
||||
ResourceAllocationController resourceAllocationController) {
|
||||
return resourceAllocationController.taskEndDate;
|
||||
}
|
||||
},
|
||||
RESOURCES_PER_DAY(CalculatedValue.RESOURCES_PER_DAY) {
|
||||
|
||||
@Override
|
||||
|
|
@ -439,17 +498,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
public abstract Component input(
|
||||
ResourceAllocationController resourceAllocationController);
|
||||
|
||||
public Component createComponent(
|
||||
ResourceAllocationController resourceAllocationController,
|
||||
CalculationTypeRadio calculationTypeRadio) {
|
||||
if (this.equals(END_DATE)) {
|
||||
return createHbox(resourceAllocationController.taskEndDate,
|
||||
calculationTypeRadio);
|
||||
} else {
|
||||
return createRadio(calculationTypeRadio);
|
||||
}
|
||||
}
|
||||
|
||||
public Radio createRadio(CalculationTypeRadio calculationTypeRadio) {
|
||||
Radio result = new Radio();
|
||||
result.setLabel(getName());
|
||||
|
|
@ -459,14 +507,15 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
return result;
|
||||
}
|
||||
|
||||
public Hbox createHbox(Datebox datebox,
|
||||
public Hbox createHbox(Decimalbox decimalbox,
|
||||
CalculationTypeRadio calculationTypeRadio) {
|
||||
Vbox vbox;
|
||||
Hbox hbox = new Hbox();
|
||||
hbox.setSpacing("65px");
|
||||
Radio radio = createRadio(calculationTypeRadio);
|
||||
|
||||
hbox.appendChild(radio);
|
||||
hbox.appendChild(datebox);
|
||||
hbox.appendChild(decimalbox);
|
||||
return hbox;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.navalplanner.web.planner.allocation;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
|
@ -396,6 +397,14 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
return task.getStartDate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getTaskEnd() {
|
||||
if (task == null) {
|
||||
return null;
|
||||
}
|
||||
return task.getEndDate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDate(Date date) {
|
||||
if (task != null) {
|
||||
|
|
@ -403,4 +412,19 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getTaskDuration() {
|
||||
if (task == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return new BigDecimal(task.getDaysDuration());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorkableDays(BigDecimal decimal) {
|
||||
if (task != null) {
|
||||
task.setWorkableDays(decimal);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import org.navalplanner.business.planner.entities.CalculatedValue;
|
|||
import org.navalplanner.business.planner.entities.ITaskLeafConstraint;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.business.planner.entities.TaskStartConstraint;
|
||||
import org.navalplanner.business.workingday.IntraDayDate;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
import org.navalplanner.web.common.Level;
|
||||
|
|
@ -116,6 +117,7 @@ public class EditTaskController extends GenericForwardComposer {
|
|||
window = (Window) comp;
|
||||
taskPropertiesController.doAfterCompose(taskPropertiesTabpanel);
|
||||
resourceAllocationController.doAfterCompose(resourceAllocationTabpanel);
|
||||
resourceAllocationController.setEditTaskController(this);
|
||||
subcontractController.doAfterCompose(subcontractTabpanel);
|
||||
initLimitingResourceAllocationController();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,6 +169,8 @@ public class TaskPropertiesController extends GenericForwardComposer {
|
|||
|
||||
private Intbox duration;
|
||||
|
||||
private Datebox endDateBox;
|
||||
|
||||
private Combobox startConstraintTypes;
|
||||
|
||||
private Datebox startConstraintDate;
|
||||
|
|
@ -660,4 +662,9 @@ public class TaskPropertiesController extends GenericForwardComposer {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateTaskEndDate(Date endDate) {
|
||||
getGanttTaskDTO().endDate = endDate;
|
||||
Util.reloadBindings(endDateBox);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,16 +62,34 @@
|
|||
</rows>
|
||||
</grid>
|
||||
</vbox>
|
||||
|
||||
<vbox align="bottom">
|
||||
<button id="btnRecommendedAllocation" label="${i18n:_('Recommended Allocation')}" />
|
||||
</vbox>
|
||||
</groupbox>
|
||||
|
||||
<groupbox sclass="assignedresources" closable="false" width="340px" height="170px" >
|
||||
<caption label="${i18n:_('Allocation configuration')}" />
|
||||
|
||||
<hbox>
|
||||
<label value = "${i18n:_('Task start :')}" />
|
||||
<label value="@{allocationController.taskStart,converter='org.navalplanner.web.common.typeconverters.DateConverter'}" />
|
||||
<!-- Planned Task Start -->
|
||||
<label style="font-weight: bold" value="${i18n:_('Planned start :')}" />
|
||||
<label value="@{allocationController.plannedTaskStart,converter='org.navalplanner.web.common.typeconverters.DateConverter'}" />
|
||||
|
||||
<!-- Planned Task End -->
|
||||
<label style="font-weight: bold" value="${i18n:_('Planned end :')}" />
|
||||
<label id="lbTaskEnd" value="@{allocationController.plannedTaskEnd,converter='org.navalplanner.web.common.typeconverters.DateConverter'}" />
|
||||
|
||||
</hbox>
|
||||
<!-- Planned Workable Days -->
|
||||
<label style="font-weight: bold" value="${i18n:_('Planned workable days :')}" />
|
||||
<decimalbox id="dbTaskWorkableDays" width="90px" />
|
||||
<hbox>
|
||||
|
||||
</hbox>
|
||||
|
||||
<separator orient="horizontal" spacing="10px"/>
|
||||
|
||||
<radiogroup id="calculationTypeSelector"
|
||||
onCheck="allocationController.calculationTypeSelected = self.selectedItem.value;">
|
||||
<grid id="calculationTypesGrid">
|
||||
|
|
@ -80,12 +98,6 @@
|
|||
</columns>
|
||||
</grid>
|
||||
</radiogroup>
|
||||
<hbox>
|
||||
<checkbox id="recommendedAllocationCheckbox" label="${i18n:_('Recommended Allocation')}"/>
|
||||
<separator orient="horizontal" spacing="10px"/>
|
||||
<checkbox id="extendedViewCheckbox" label="${i18n:_('Extended view')}"
|
||||
onCheck="allocationController.onCheckExtendedView()"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
|
||||
</hbox>
|
||||
|
|
@ -95,12 +107,17 @@
|
|||
|
||||
<!-- Multiple allocation selector -->
|
||||
<separator spacing="10px"/>
|
||||
|
||||
<hbox align="bottom">
|
||||
<newAllocationSelectorCombo id="newAllocationSelectorCombo" />
|
||||
<button label="${i18n:_('Add')}" onClick="allocationController.onSelectWorkers(newAllocationSelectorCombo)" />
|
||||
<button label="${i18n:_('Advanced search')}" onClick="allocationController.goToAdvancedSearch()" />
|
||||
<checkbox id="extendedViewCheckbox" label="${i18n:_('Extended view')}"
|
||||
onCheck="allocationController.onCheckExtendedView()"/>
|
||||
</hbox>
|
||||
|
||||
<separator spacing="20px"/>
|
||||
|
||||
<grid id="allocationsGrid"
|
||||
model="@{allocationController.resourceAllocations}"
|
||||
rowRenderer="@{allocationController.resourceAllocationRenderer}"
|
||||
|
|
@ -131,6 +148,7 @@
|
|||
<!-- Worker search -->
|
||||
<tabpanel>
|
||||
<newAllocationSelector id="newAllocationSelector"/>
|
||||
|
||||
<!-- Select worker -->
|
||||
<hbox>
|
||||
<button label="${i18n:_('Select')}" onClick="allocationController.onSelectWorkers(newAllocationSelector)" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue