From c95006b9c00e32756f4007ce0627e92239e33bef Mon Sep 17 00:00:00 2001 From: lmluat-axonivy Date: Tue, 10 Sep 2024 11:38:34 +0700 Subject: [PATCH 1/2] bug/IVYPORTAL-17553-TaskWriteExpiryTimestamp-does-not-work-as-expected-LE - Fix bug --- .../addon/portalkit/bean/TaskActionBean.java | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/bean/TaskActionBean.java b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/bean/TaskActionBean.java index 046a892dd46..b48abab025e 100644 --- a/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/bean/TaskActionBean.java +++ b/AxonIvyPortal/portal/src/ch/ivy/addon/portalkit/bean/TaskActionBean.java @@ -130,11 +130,34 @@ public boolean canChangePriority(ITask task) { return isNotDone(task) && hasPermission(task, IPermission.TASK_WRITE_ORIGINAL_PRIORITY); } + /** + * Logic to check if user can change task expiry date: + * - Task not null + * - Task state is different from DONE, DESTROYED + * - User has permission TaskWriteExpiryTimestamp + * - The task has expiry handler or has expiry option 'Nobody & delete' + * + * @param task + * @return condition whether the user can change expiry time + */ + public boolean canChangeExpiry(ITask task) { - List taskStates = Arrays.asList(TaskBusinessState.DONE, TaskBusinessState.DESTROYED); - return (hasPermission(task, IPermission.TASK_WRITE_EXPIRY_TIMESTAMP) - || (task != null && StringUtils.isNotBlank(task.getExpiryTaskStartElementPid()))) - && !taskStates.contains(task.getBusinessState()); + List nonChangeableExpiryStates = Arrays.asList(TaskState.DONE, + TaskState.DESTROYED); + + if (task == null || nonChangeableExpiryStates.contains(task.getState())) { + return false; + } + + boolean isAutoDeleteAfterExpiry = StringUtils + .isBlank(task.getExpiryActivatorName()) + && StringUtils.isBlank(task.getExpiryTaskStartElementPid()); + + boolean hasExpiryHandler = StringUtils + .isNotBlank(task.getExpiryTaskStartElementPid()); + + return hasPermission(task, IPermission.TASK_WRITE_EXPIRY_TIMESTAMP) + && (isAutoDeleteAfterExpiry || hasExpiryHandler); } public boolean canChangeDelayTimestamp(ITask task) { From b692ae3e8ea46da35a0388e9a0350cb85f410ff9 Mon Sep 17 00:00:00 2001 From: lmluat-axonivy Date: Wed, 11 Sep 2024 10:19:38 +0700 Subject: [PATCH 2/2] bug/IVYPORTAL-17553-TaskWriteExpiryTimestamp-does-not-work-as-expected-LE - Fix GUI tests --- .../Start Processes/DataCreation.p.json | 21 +++++++++++++++++++ .../Start Processes/CreateTestData.p.json | 9 +++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/AxonIvyPortal/PortalKitTestHelper/processes/Start Processes/DataCreation.p.json b/AxonIvyPortal/PortalKitTestHelper/processes/Start Processes/DataCreation.p.json index 7af11747ee3..b58ccf85c3e 100644 --- a/AxonIvyPortal/PortalKitTestHelper/processes/Start Processes/DataCreation.p.json +++ b/AxonIvyPortal/PortalKitTestHelper/processes/Start Processes/DataCreation.p.json @@ -1299,6 +1299,27 @@ "visual" : { "at" : { "x" : 640, "y" : 160 } } + }, { + "id" : "S10-f8", + "type" : "ErrorStartEvent", + "name" : "test:expiry", + "config" : { + "errorCode" : "test:expiry" + }, + "visual" : { + "at" : { "x" : 64, "y" : 464 }, + "labelOffset" : { "x" : 13, "y" : 33 } + }, + "connect" : [ + { "id" : "S10-f9", "to" : "S10-f12" } + ] + }, { + "id" : "S10-f12", + "type" : "TaskEnd", + "visual" : { + "at" : { "x" : 544, "y" : 464 }, + "labelOffset" : { "x" : 13, "y" : 33 } + } } ], "visual" : { "at" : { "x" : 256, "y" : 1152 }, diff --git a/Showcase/portal-developer-examples/processes/Start Processes/CreateTestData.p.json b/Showcase/portal-developer-examples/processes/Start Processes/CreateTestData.p.json index 2ff7e477ea7..14f8a6da235 100644 --- a/Showcase/portal-developer-examples/processes/Start Processes/CreateTestData.p.json +++ b/Showcase/portal-developer-examples/processes/Start Processes/CreateTestData.p.json @@ -605,7 +605,8 @@ "level" : "HIGH" }, "expiry" : { - "timeout" : "new Duration(\"1D\")" + "timeout" : "new Duration(\"1D\")", + "error" : "f88" }, "customFields" : [ { "name" : "AccountNumber", "type" : "NUMBER", "value" : "14" }, @@ -624,7 +625,8 @@ "activator" : "\"demo\"" }, "expiry" : { - "timeout" : "new Duration(\"3H\")" + "timeout" : "new Duration(\"3H\")", + "error" : "f88" }, "customFields" : [ { "name" : "AccountNumber", "type" : "NUMBER", "value" : "7" }, @@ -642,7 +644,8 @@ "level" : "LOW" }, "expiry" : { - "timeout" : "new Duration(\"2D\")" + "timeout" : "new Duration(\"2D\")", + "error" : "f88" }, "customFields" : [ { "name" : "AccountNumber", "type" : "NUMBER", "value" : "13" },