From 2c98e99d638388f087ee7c55eb78c5f49809532b Mon Sep 17 00:00:00 2001 From: Manuel Rego Casasnovas Date: Mon, 12 Nov 2012 13:00:44 +0100 Subject: [PATCH] Disable resource allocation pop-up for tasks updated from timesheets FEA: ItEr77S12AdaptPlanningAccordingTimesheets --- .../allocation/AllocationConfiguration.java | 3 ++- .../allocation/AllocationRowsHandler.java | 5 ++++ .../web/planner/allocation/FormBinder.java | 23 ++++++++++++++----- .../ResourceAllocationController.java | 10 +++++--- ..._tabPanelNonLimitingResourceAllocation.zul | 2 +- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AllocationConfiguration.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AllocationConfiguration.java index 420554f13..3c13cf7a9 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AllocationConfiguration.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AllocationConfiguration.java @@ -107,7 +107,8 @@ public class AllocationConfiguration extends HtmlMacroComponent { .getCalculatedValue())) { radio.setChecked(true); } - radio.setDisabled(formBinder.isAnyManual()); + radio.setDisabled(formBinder.isAnyManual() + || formBinder.isTaskUpdatedFromTimesheets()); } } }; diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AllocationRowsHandler.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AllocationRowsHandler.java index a1ce03b4c..ed534013a 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AllocationRowsHandler.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AllocationRowsHandler.java @@ -423,4 +423,9 @@ public class AllocationRowsHandler { private ArrayList copyOfCurrentRowsToAvoidConcurrentModification() { return new ArrayList(currentRows); } + + public boolean isTaskUpdatedFromTimesheets() { + return task.isUpdatedFromTimesheets(); + } + } \ No newline at end of file diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/FormBinder.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/FormBinder.java index 01ce78435..317d7ada6 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/FormBinder.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/FormBinder.java @@ -216,7 +216,7 @@ public class FormBinder { boolean disabled = rows.isEmpty() || (CalculatedValue.NUMBER_OF_HOURS == c) || (c == CalculatedValue.RESOURCES_PER_DAY && !recommendedAllocation) - || isAnyManual(); + || isAnyManual() || isTaskUpdatedFromTimesheets(); this.effortInput.setDisabled(disabled); } @@ -244,13 +244,14 @@ public class FormBinder { allResourcesPerDayVisibilityRule(); applyDisabledRulesOnRows(); this.btnRecommendedAllocation.setDisabled(recommendedAllocation - || isAnyManual()); + || isAnyManual() || isTaskUpdatedFromTimesheets()); } private void applyDisabledRulesOnRows() { for (AllocationRow each : rows) { each.applyDisabledRules(getCalculatedValue(), - recommendedAllocation, isAnyManual()); + recommendedAllocation, isAnyManual() + || isTaskUpdatedFromTimesheets()); } } @@ -358,7 +359,7 @@ public class FormBinder { void applyDisabledRules() { this.taskWorkableDays.setDisabled(allocationRowsHandler .getCalculatedValue() == CalculatedValue.END_DATE - || isAnyManual()); + || isAnyManual() || isTaskUpdatedFromTimesheets()); } private void initializeDateAndDurationFieldsFromTaskOriginalValues() { @@ -461,7 +462,8 @@ public class FormBinder { CalculatedValue c = allocationRowsHandler.getCalculatedValue(); this.allResourcesPerDay.setDisabled(rows.isEmpty() || c == CalculatedValue.RESOURCES_PER_DAY - || !recommendedAllocation || isAnyManual()); + || !recommendedAllocation || isAnyManual() + || isTaskUpdatedFromTimesheets()); this.allResourcesPerDay .setConstraint(constraintForAllResourcesPerDay()); } @@ -518,6 +520,10 @@ public class FormBinder { * exit the edition form */ public boolean accept() { + if (isTaskUpdatedFromTimesheets()) { + return true; + } + Flagged result = resourceAllocationModel .accept(); @@ -703,7 +709,8 @@ public class FormBinder { public void setRecommendedAllocation(Button recommendedAllocation) { this.btnRecommendedAllocation = recommendedAllocation; - this.btnRecommendedAllocation.setDisabled(isAnyManual()); + this.btnRecommendedAllocation.setDisabled(isAnyManual() + || isTaskUpdatedFromTimesheets()); Util.ensureUniqueListener(recommendedAllocation, Events.ON_CLICK, new EventListener() { @Override @@ -935,4 +942,8 @@ public class FormBinder { return false; } + public boolean isTaskUpdatedFromTimesheets() { + return allocationRowsHandler.isTaskUpdatedFromTimesheets(); + } + } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/ResourceAllocationController.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/ResourceAllocationController.java index e3045f3b6..0b2509bc2 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/ResourceAllocationController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/ResourceAllocationController.java @@ -602,7 +602,7 @@ public class ResourceAllocationController extends GenericForwardComposer { // On click delete button Button deleteButton = appendDeleteButton(row); - deleteButton.setDisabled(isAnyManual()); + deleteButton.setDisabled(isAnyManualOrTaskUpdatedFromTimesheets()); formBinder.setDeleteButtonFor(data, deleteButton); deleteButton.addEventListener("onClick", new EventListener() { @@ -671,8 +671,12 @@ public class ResourceAllocationController extends GenericForwardComposer { return formBinder != null && formBinder.isAnyNotFlat(); } - public boolean isAnyManual() { - return formBinder != null && formBinder.isAnyManual(); + public boolean isAnyManualOrTaskUpdatedFromTimesheets() { + if (formBinder == null) { + return false; + } + return formBinder.isAnyManual() + || formBinder.isTaskUpdatedFromTimesheets(); } } diff --git a/libreplan-webapp/src/main/webapp/planner/taskpanels/_tabPanelNonLimitingResourceAllocation.zul b/libreplan-webapp/src/main/webapp/planner/taskpanels/_tabPanelNonLimitingResourceAllocation.zul index 302c4ac97..271e6b0ff 100644 --- a/libreplan-webapp/src/main/webapp/planner/taskpanels/_tabPanelNonLimitingResourceAllocation.zul +++ b/libreplan-webapp/src/main/webapp/planner/taskpanels/_tabPanelNonLimitingResourceAllocation.zul @@ -64,7 +64,7 @@