ItEr29S06CUAsignacionGrupoRecursosAPlanificacionItEr28S06: Accepting in advanced allocation gives the modified AllocationResult in order to be saved
This commit is contained in:
parent
684e48a229
commit
b64b8bafa5
5 changed files with 56 additions and 16 deletions
|
|
@ -26,6 +26,7 @@ import java.util.Map;
|
|||
|
||||
import org.navalplanner.web.planner.allocation.AdvancedAllocationController;
|
||||
import org.navalplanner.web.planner.allocation.AllocationResult;
|
||||
import org.navalplanner.web.planner.allocation.AdvancedAllocationController.IAdvanceAllocationResultReceiver;
|
||||
import org.navalplanner.web.resourceload.ResourceLoadController;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
|
@ -53,18 +54,21 @@ public class ViewSwitcher implements Composer {
|
|||
isInPlanningOrder = true;
|
||||
}
|
||||
|
||||
public void goToAdvancedAllocation(AllocationResult allocationResult) {
|
||||
public void goToAdvancedAllocation(AllocationResult allocationResult,
|
||||
IAdvanceAllocationResultReceiver resultReceiver) {
|
||||
planningOrder = ComponentsReplacer.replaceAllChildren(parent,
|
||||
"advance_allocation.zul",
|
||||
createArgsForAdvancedAllocation(allocationResult));
|
||||
"advance_allocation.zul", createArgsForAdvancedAllocation(
|
||||
allocationResult, resultReceiver));
|
||||
isInPlanningOrder = false;
|
||||
}
|
||||
|
||||
private Map<String, Object> createArgsForAdvancedAllocation(
|
||||
AllocationResult allocationResult) {
|
||||
AllocationResult allocationResult,
|
||||
IAdvanceAllocationResultReceiver resultReceiver) {
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
result.put("advancedAllocationController",
|
||||
new AdvancedAllocationController(this, allocationResult));
|
||||
new AdvancedAllocationController(this, allocationResult,
|
||||
resultReceiver));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,12 @@ import org.zkoss.zul.api.Column;
|
|||
public class AdvancedAllocationController extends
|
||||
GenericForwardComposer {
|
||||
|
||||
public interface IAdvanceAllocationResultReceiver {
|
||||
public void accepted(AllocationResult modifiedAllocationResult);
|
||||
|
||||
public void cancel();
|
||||
}
|
||||
|
||||
private Div insertionPointTimetracker;
|
||||
private Div insertionPointLeftPanel;
|
||||
private Div insertionPointRightPanel;
|
||||
|
|
@ -58,11 +64,14 @@ public class AdvancedAllocationController extends
|
|||
private TimeTrackedTable<FakeData> table;
|
||||
private final ViewSwitcher switcher;
|
||||
private final AllocationResult allocationResult;
|
||||
private final IAdvanceAllocationResultReceiver resultReceiver;
|
||||
|
||||
public AdvancedAllocationController(ViewSwitcher switcher,
|
||||
AllocationResult allocationResult) {
|
||||
AllocationResult allocationResult,
|
||||
IAdvanceAllocationResultReceiver resultReceiver) {
|
||||
this.switcher = switcher;
|
||||
this.allocationResult = allocationResult;
|
||||
this.resultReceiver = resultReceiver;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -94,15 +103,13 @@ public class AdvancedAllocationController extends
|
|||
}
|
||||
|
||||
public void onClick$acceptButton() {
|
||||
backToPreviousButton();
|
||||
switcher.goToPlanningOrderView();
|
||||
resultReceiver.accepted(allocationResult);
|
||||
}
|
||||
|
||||
public void onClick$cancelButton() {
|
||||
backToPreviousButton();
|
||||
}
|
||||
|
||||
private void backToPreviousButton() {
|
||||
switcher.goToPlanningOrderView();
|
||||
resultReceiver.cancel();
|
||||
}
|
||||
|
||||
public void onClick$zoomIncrease() {
|
||||
|
|
|
|||
|
|
@ -83,4 +83,6 @@ public interface IResourceAllocationModel {
|
|||
org.zkoss.ganttz.data.Task ganttTask,
|
||||
PlanningState planningState);
|
||||
|
||||
void accept(AllocationResult modifiedAllocationResult);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import org.navalplanner.web.common.Util;
|
|||
import org.navalplanner.web.common.ViewSwitcher;
|
||||
import org.navalplanner.web.common.components.WorkerSearch;
|
||||
import org.navalplanner.web.planner.PlanningState;
|
||||
import org.navalplanner.web.planner.allocation.AdvancedAllocationController.IAdvanceAllocationResultReceiver;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
|
|
@ -318,10 +319,26 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
public void advanceAllocation() {
|
||||
AllocationResult allocationResult = allocationsBeingEdited
|
||||
.doAllocation();
|
||||
switcher.goToAdvancedAllocation(allocationResult);
|
||||
switcher.goToAdvancedAllocation(allocationResult,
|
||||
createResultReceiver());
|
||||
window.setVisible(false);
|
||||
}
|
||||
|
||||
private IAdvanceAllocationResultReceiver createResultReceiver() {
|
||||
return new IAdvanceAllocationResultReceiver() {
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
showWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accepted(AllocationResult modifiedAllocationResult) {
|
||||
resourceAllocationModel.accept(modifiedAllocationResult);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a {@link SpecificResourceAllocation} item
|
||||
* @author Diego Pino Garcia <dpino@igalia.com>
|
||||
|
|
|
|||
|
|
@ -103,9 +103,21 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void accept() {
|
||||
stepsBeforeDoingAllocation();
|
||||
doTheAllocation(resourceAllocationsBeingEdited
|
||||
.doAllocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void accept(AllocationResult modifiedAllocationResult) {
|
||||
stepsBeforeDoingAllocation();
|
||||
doTheAllocation(modifiedAllocationResult);
|
||||
}
|
||||
|
||||
private void stepsBeforeDoingAllocation() {
|
||||
planningState.reassociateResourcesWithSession(resourceDAO);
|
||||
removeDeletedAllocations();
|
||||
doTheAllocation();
|
||||
}
|
||||
|
||||
private void removeDeletedAllocations() {
|
||||
|
|
@ -116,9 +128,7 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
}
|
||||
}
|
||||
|
||||
private void doTheAllocation() {
|
||||
AllocationResult allocationResult = resourceAllocationsBeingEdited
|
||||
.doAllocation();
|
||||
private void doTheAllocation(AllocationResult allocationResult) {
|
||||
allocationResult.applyTo(task);
|
||||
ganttTask.setEndDate(task.getEndDate());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue