From 5b156a4ca30b10b19148cb1128e216dd3323e30f Mon Sep 17 00:00:00 2001 From: Arcadio Quintero Date: Thu, 9 Jan 2025 16:13:11 -0500 Subject: [PATCH 1/3] feat(workflows-portlet) ability to set primary/secondary actions --- .../ext/workflows/schemes/view_steps.jsp | 33 ++--- .../workflows/schemes/view_steps_filtered.jsp | 116 ++++++++++++++---- .../ext/workflows/schemes/workflow_js.jsp | 40 ++++++ 3 files changed, 151 insertions(+), 38 deletions(-) diff --git a/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/view_steps.jsp b/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/view_steps.jsp index 7708cf070362..2183452f3e24 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/view_steps.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/view_steps.jsp @@ -22,10 +22,10 @@ + +<% + // Split actions into primary and secondary + List primaryActions = new ArrayList<>(); + List secondaryActions = new ArrayList<>(); + + for(WorkflowAction action : actions) { + String isSecondary = action.getMetadata() != null ? String.valueOf(action.getMetadata().get("secondary")) : "false"; + if("true".equals(isSecondary)) { + secondaryActions.add(action); + } else { + primaryActions.add(action); + } + } + +%> +
@@ -86,21 +108,63 @@
-
- <%for(WorkflowAction action : actions) { - String subtype = action.getMetadata() != null ? String.valueOf(action.getMetadata().get("subtype")) : ""; - boolean isSeparator = "SEPARATOR".equals(subtype); - %> -
-
-
""> -
-
onClick="actionAdmin.viewAction('<%=scheme.getId()%>', '<%=action.getId() %>');" <% } %>> - <%=action.getName() %> ‣ <%=(WorkflowAction.CURRENT_STEP.equals(action.getNextStep())) ? WorkflowAction.CURRENT_STEP : wapi.findStep(action.getNextStep()).getName() %> -
-
+
+ +
Primary
+
"> + + <%for(WorkflowAction action : primaryActions) { %> + +
+
+
+
+ +
+
+ <%=action.getName()%> + ‣ + <%=(WorkflowAction.CURRENT_STEP.equals(action.getNextStep())) ? + WorkflowAction.CURRENT_STEP : + wapi.findStep(action.getNextStep()).getName()%> + +
+
+
+ <%}%> +
+ +
Secondary
+
""> + + <%for(WorkflowAction action : secondaryActions) { %> + +
+
+
+
+ +
+
+ <%=action.getName()%> + ‣ + <%=(WorkflowAction.CURRENT_STEP.equals(action.getNextStep())) ? + WorkflowAction.CURRENT_STEP : + wapi.findStep(action.getNextStep()).getName()%> + +
+
+
+ <%}%>
- <%} %> +
@@ -111,17 +175,10 @@ <% } %> - <% - String newContentEditorEnabled = Config.getStringProperty("CONTENT_EDITOR2_ENABLED"); - if (newContentEditorEnabled != null && newContentEditorEnabled.equalsIgnoreCase("true")) { - %> -
- Divider -
- <% } %>
Add
+
@@ -145,3 +202,16 @@
+ \ No newline at end of file diff --git a/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/workflow_js.jsp b/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/workflow_js.jsp index ab9a4a05ee01..5e52ae08e58c 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/workflow_js.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/workflow_js.jsp @@ -1140,6 +1140,46 @@ dojo.declare("dotcms.dijit.workflows.ActionAdmin", null, { dojo.xhrPost(xhrArgs); }, + + saveActionPriority : function(ele, isSecondary) { + const actionData = JSON.parse(ele.dataset.wfaction); + + const updatedData = { + schemeId: actionData.schemeId, + actionName: actionData.name, + whoCanUse: actionData.showOn, + actionIcon: actionData.icon, + actionCommentable: actionData.commentable, + showOn: actionData.showOn, + actionNextStep: actionData.nextStep, + actionNextAssign: actionData.nextAssign, + actionCondition: actionData.condition, + actionAssignable: actionData.assignable, + actionRoleHierarchyForAssign: actionData.roleHierarchyForAssign, + metadata: isSecondary + ? { secondary: true } + : null + }; + + + const xhrArgs = { + url: "/api/v1/workflow/actions/" + actionData.id, + headers: { + "Content-Type": "application/json" + }, + postData: dojo.toJson(updatedData), + handle: function (dataOrError, ioArgs) { + if (dojo.isString(dataOrError)) { + if (dataOrError.indexOf("FAILURE") === 0) { + showDotCMSSystemMessage(dataOrError, true); + } + } + } + }; + + dojo.xhrPut(xhrArgs); + }, + saveAction : function(schemeId) { var myForm = dijit.byId("addEditAction"); From 33eb0ac7c77e41521426639f5821ca43ee70c29a Mon Sep 17 00:00:00 2001 From: Arcadio Quintero Date: Thu, 9 Jan 2025 16:22:44 -0500 Subject: [PATCH 2/3] feat(workflows-portlet) persist other metadata properties --- .../html/portlet/ext/workflows/schemes/workflow_js.jsp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/workflow_js.jsp b/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/workflow_js.jsp index 5e52ae08e58c..4e085189282d 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/workflow_js.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/workflow_js.jsp @@ -1157,8 +1157,10 @@ dojo.declare("dotcms.dijit.workflows.ActionAdmin", null, { actionAssignable: actionData.assignable, actionRoleHierarchyForAssign: actionData.roleHierarchyForAssign, metadata: isSecondary - ? { secondary: true } - : null + ? {...actionData.metadata, secondary: true} + : (actionData.metadata ? Object.fromEntries( + Object.entries(actionData.metadata).filter(([key]) => key !== 'secondary') + ) : {}) }; From 9426a94c114983006bfc48122293e19c806ee781 Mon Sep 17 00:00:00 2001 From: Arcadio Quintero Date: Thu, 9 Jan 2025 16:25:02 -0500 Subject: [PATCH 3/3] feat(workflows-portlet) show empty primary actions container --- .../html/portlet/ext/workflows/schemes/view_steps_filtered.jsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/view_steps_filtered.jsp b/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/view_steps_filtered.jsp index c87804e793f6..a004646acdd0 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/view_steps_filtered.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/workflows/schemes/view_steps_filtered.jsp @@ -210,7 +210,7 @@ text-align: center; border-bottom: 1px solid #ccc; } - .wf-secondary-action-wrapper.empty { + .wf-secondary-action-wrapper.empty, .wf-pimary-action-wrapper.empty { min-height: 42px; background: var(--color-palette-primary-op-10); }