Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.3] Workflow Transitions #2688

Closed
jgerman-bot opened this issue Dec 15, 2022 · 0 comments · Fixed by #2692
Closed

[4.3] Workflow Transitions #2688

jgerman-bot opened this issue Dec 15, 2022 · 0 comments · Fixed by #2692

Comments

@jgerman-bot
Copy link

New language relevant PR in upstream repo: joomla/joomla-cms#39325 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/language/en-GB/com_content.ini b/administrator/language/en-GB/com_content.ini
index 125930cfacfd..aa6df5a8776b 100644
--- a/administrator/language/en-GB/com_content.ini
+++ b/administrator/language/en-GB/com_content.ini
@@ -160,6 +160,7 @@ COM_CONTENT_PUBLISH_DOWN_DESC="Finish Publishing descending"
 COM_CONTENT_PUBLISH_UP_ASC="Start Publishing ascending"
 COM_CONTENT_PUBLISH_UP_DESC="Start Publishing descending"
 COM_CONTENT_PUBLISHED="Published"
+COM_CONTENT_RUN_TRANSITION="Run Transition"
 COM_CONTENT_RUN_TRANSITIONS="Run Transitions"
 COM_CONTENT_SAVE_SUCCESS="Article saved."
 COM_CONTENT_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the article to customise the alias."
@@ -190,6 +191,7 @@ COM_CONTENT_URL_FIELD_C_BROWSERNAV_LABEL="URL C Target Window"
 COM_CONTENT_WARNING_PROVIDE_VALID_NAME="Please provide a valid, non-blank title."
 COM_CONTENT_WORKFLOW="Workflow"
 COM_CONTENT_WORKFLOW_NOT_FOUND="No default workflow available, please define one or contact an administrator."
+COM_CONTENT_WORKFLOW_STAGE="Workflow Stage"
 COM_CONTENT_WORKFLOW_TRANSITION_NOT_ALLOWED="You're not allowed to execute this transition"
 COM_CONTENT_WORKFLOWS="Workflows"
 COM_CONTENT_XML_DESCRIPTION="Article management component."
diff --git a/layouts/joomla/button/transition-button.php b/layouts/joomla/button/transition-button.php
index 502815a29419..60f09fda7597 100644
--- a/layouts/joomla/button/transition-button.php
+++ b/layouts/joomla/button/transition-button.php
@@ -58,10 +58,11 @@
         <?php
             $default = [
                 HTMLHelper::_('select.option', '', $this->escape($options['title'])),
-                HTMLHelper::_('select.option', '-1', '--------', ['disable' => true])
+                HTMLHelper::_('select.option', '-1', '--------', ['disable' => true]),
+                HTMLHelper::_('select.option', '<OPTGROUP>', Text::_('COM_CONTENT_RUN_TRANSITION')),
             ];
 
-            $transitions = array_merge($default, $options['transitions']);
+            $transitions = array_merge($default, $options['transitions'], [HTMLHelper::_('select.option', '</OPTGROUP>')]);
 
             $attribs = [
                 'id'        => 'transition-select_' . (int) $row ?? '',
diff --git a/libraries/src/Form/Field/TransitionField.php b/libraries/src/Form/Field/TransitionField.php
index 4c0ae25eed3a..03e8396490bf 100644
--- a/libraries/src/Form/Field/TransitionField.php
+++ b/libraries/src/Form/Field/TransitionField.php
@@ -19,11 +19,11 @@
 // phpcs:enable PSR1.Files.SideEffects
 
 /**
- * Components Category field.
+ * Workflow Transitions field.
  *
  * @since  4.0.0
  */
-class TransitionField extends ListField
+class TransitionField extends GroupedlistField
 {
     /**
      * The form field type.
@@ -91,7 +91,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
      *
      * @since  4.0.0
      */
-    protected function getOptions()
+    protected function getGroups()
     {
         // Let's get the id for the current item, either category or content item.
         $jinput = Factory::getApplication()->getInput();
@@ -161,15 +161,20 @@ function ($item) use ($user, $component) {
 
         $workflowName = $db->setQuery($query)->loadResult();
 
-        $default = [HTMLHelper::_('select.option', '', Text::_($workflowName))];
+        $default = [[
+            HTMLHelper::_('select.option', '', Text::_($workflowName))]];
 
-        $options = array_merge(parent::getOptions(), $items);
+        $groups = parent::getGroups();
 
-        if (\count($options)) {
-            $default[] = HTMLHelper::_('select.option', '-1', '--------', ['disable' => true]);
+        if (\count($items)) {
+            $groups[Text::_('COM_CONTENT_RUN_TRANSITION')] = $items;
+        }
+
+        if (\count($groups)) {
+            $default[][] = HTMLHelper::_('select.option', '-1', '--------', ['disable' => true]);
         }
 
         // Merge with defaults
-        return array_merge($default, $options);
+        return array_merge($default, $groups);
     }
 }
diff --git a/libraries/src/MVC/Model/WorkflowBehaviorTrait.php b/libraries/src/MVC/Model/WorkflowBehaviorTrait.php
index cdf0967b6a5b..d5443c8c771e 100644
--- a/libraries/src/MVC/Model/WorkflowBehaviorTrait.php
+++ b/libraries/src/MVC/Model/WorkflowBehaviorTrait.php
@@ -330,7 +330,7 @@ protected function addTransitionField(Form $form, $data)
 
         $field->addAttribute('name', 'transition');
         $field->addAttribute('type', $this->workflowEnabled ? 'transition' : 'hidden');
-        $field->addAttribute('label', 'COM_CONTENT_WORKFLOW');
+        $field->addAttribute('label', 'COM_CONTENT_WORKFLOW_STAGE');
         $field->addAttribute('extension', $extension);
 
         $form->setField($field);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants