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 #39325

Merged
merged 9 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions administrator/language/en-GB/com_content.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -189,6 +190,7 @@ COM_CONTENT_URL_FIELD_BROWSERNAV_LABEL="URL Target Window"
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_STAGE="Workflow Stage"
COM_CONTENT_WORKFLOW_NOT_FOUND="No default workflow available, please define one or contact an administrator."
obuisard marked this conversation as resolved.
Show resolved Hide resolved
COM_CONTENT_WORKFLOW_TRANSITION_NOT_ALLOWED="You're not allowed to execute this transition"
COM_CONTENT_WORKFLOWS="Workflows"
Expand Down
5 changes: 3 additions & 2 deletions layouts/joomla/button/transition-button.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? '',
Expand Down
21 changes: 13 additions & 8 deletions libraries/src/Form/Field/TransitionField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion libraries/src/MVC/Model/WorkflowBehaviorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down