Skip to content

Commit 66833cf

Browse files
committed
show default option in workflow field
1 parent a5b5a1b commit 66833cf

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

administrator/components/com_modules/src/Extension/ModulesComponent.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,4 @@ public function filterTransitions(array $transitions, int $pk): array
134134
{
135135
return ModuleHelper::filterTransitions($transitions, $pk);
136136
}
137-
138137
}

administrator/components/com_modules/src/Model/ModuleModel.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,7 @@ protected function preprocessForm(Form $form, $data, $group = 'content')
979979
{
980980
// Import the workflow plugin group to allow form manipulation.
981981
$this->importWorkflowPlugins();
982+
$this->prepareWorkflowField($form, $data);
982983
}
983984
}
984985

@@ -1316,4 +1317,43 @@ protected function getStageForNewItem(Form $form, $data)
13161317

13171318
return $defaultStage;
13181319
}
1320+
1321+
/**
1322+
* Adds defaylt stage to workflow field in the form.
1323+
*
1324+
* @param Form $form The form to change
1325+
* @param array|object $data The form data
1326+
*
1327+
* @return void
1328+
*
1329+
* @since __DEPLOY_VERSION__
1330+
*/
1331+
public static function prepareWorkflowField(Form $form, $data)
1332+
{
1333+
$db = Factory::getDbo();
1334+
1335+
$data = (array) $data;
1336+
1337+
$form->setFieldAttribute('workflow_id', 'default', 'inherit');
1338+
1339+
$query = $db->getQuery(true);
1340+
1341+
$query->select($db->quoteName('title'))
1342+
->from($db->quoteName('#__workflows'))
1343+
->where(
1344+
[
1345+
$db->quoteName('default') . ' = 1',
1346+
$db->quoteName('published') . ' = 1',
1347+
$db->quoteName('extension') . ' = "com_modules.module"',
1348+
]
1349+
);
1350+
1351+
$defaulttitle = $db->setQuery($query)->loadResult();
1352+
1353+
$field = $form->getField('workflow_id');
1354+
1355+
$field->addOption(Text::sprintf('COM_WORKFLOW_USE_DEFAULT_WORKFLOWS', Text::_($defaulttitle)), ['value' => 'use_default']);
1356+
1357+
$field->addOption('- ' . Text::_('COM_MODULES_WORKFLOW') . ' -', ['disabled' => 'true']);
1358+
}
13191359
}

administrator/language/en-GB/com_modules.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ COM_MODULES_TABLE_CAPTION="Table of Modules"
192192
COM_MODULES_TYPE_CHOOSE="Select a Module Type"
193193
COM_MODULES_TYPE_OR_SELECT_POSITION="Type or Select a Position"
194194
COM_MODULES_WORKFLOW="Workflow"
195+
COM_MODULES_WORKFLOW="Workflows"
195196
COM_MODULES_WORKFLOW_NOT_FOUND="No default workflow available, please define one or contact an administrator."
196197
COM_MODULES_WORKFLOW_TRANSITION_NOT_ALLOWED="You're not allowed to execute this transition"
197198
COM_MODULES_XML_DESCRIPTION="Component for module management in the Administrator Backend."

0 commit comments

Comments
 (0)