diff --git a/administrator/components/com_content/src/Extension/ContentComponent.php b/administrator/components/com_content/src/Extension/ContentComponent.php index 8a41c6f4cde1c..dbb0729887c87 100644 --- a/administrator/components/com_content/src/Extension/ContentComponent.php +++ b/administrator/components/com_content/src/Extension/ContentComponent.php @@ -177,6 +177,24 @@ public function getContexts(): array return $contexts; } + /** + * Returns valid contexts + * + * @return array + * + * @since 4.0.0 + */ + public function getWorkflowContexts(): array + { + Factory::getLanguage()->load('com_content', JPATH_ADMINISTRATOR); + + $contexts = array( + 'com_content.article' => Text::_('COM_CONTENT') + ); + + return $contexts; + } + /** * Returns the table for the count items functions for the given section. * diff --git a/administrator/components/com_workflow/forms/filter_workflows.xml b/administrator/components/com_workflow/forms/filter_workflows.xml index cfd1063ba0274..e6c2915ce6efc 100644 --- a/administrator/components/com_workflow/forms/filter_workflows.xml +++ b/administrator/components/com_workflow/forms/filter_workflows.xml @@ -1,5 +1,13 @@ -
+ +
+ +
getOptions()) < 2) + { + $this->layout = 'joomla.form.field.hidden'; + } + + return parent::getInput(); + } + + /** + * Method to get the field options. + * + * @return array The field option objects. + * + * @since 4.0.0 + */ + protected function getOptions() + { + $parts = explode('.', $this->value); + + $component = Factory::getApplication()->bootComponent($parts[0]); + + if ($component instanceof WorkflowServiceInterface) + { + return $component->getWorkflowContexts(); + } + + return []; + } +} diff --git a/administrator/components/com_workflow/src/Model/WorkflowsModel.php b/administrator/components/com_workflow/src/Model/WorkflowsModel.php index b273b96cbd7e0..a05bb2b15ab02 100644 --- a/administrator/components/com_workflow/src/Model/WorkflowsModel.php +++ b/administrator/components/com_workflow/src/Model/WorkflowsModel.php @@ -116,6 +116,28 @@ public function getItems() return $items; } + /** + * Get the filter form + * + * @param array $data data + * @param boolean $loadData load current data + * + * @return \JForm|false the JForm object or false + * + * @since 4.0.0 + */ + public function getFilterForm($data = array(), $loadData = true) + { + $form = parent::getFilterForm($data, $loadData); + + if ($form) + { + $form->setValue('extension', null, $this->getState('filter.extension')); + } + + return $form; + } + /** * Add the number of transitions and states to all workflow items * diff --git a/administrator/components/com_workflow/tmpl/workflows/default.php b/administrator/components/com_workflow/tmpl/workflows/default.php index 35466909617b6..18a1c08bcbd66 100644 --- a/administrator/components/com_workflow/tmpl/workflows/default.php +++ b/administrator/components/com_workflow/tmpl/workflows/default.php @@ -53,7 +53,7 @@
$this)); + echo LayoutHelper::render('joomla.searchtools.default', array('view' => $this, 'options' => array('selectorFieldName' => 'extension'))); ?> workflows)) : ?>
@@ -169,7 +169,6 @@ -
diff --git a/libraries/src/Workflow/WorkflowServiceInterface.php b/libraries/src/Workflow/WorkflowServiceInterface.php index e24713929b40b..5632fd6df7fac 100644 --- a/libraries/src/Workflow/WorkflowServiceInterface.php +++ b/libraries/src/Workflow/WorkflowServiceInterface.php @@ -80,4 +80,13 @@ public static function getConditions(string $extension): array; * @since 4.0.0 */ public function getWorkflowTableBySection(?string $section = null): string; + + /** + * Returns valid contexts. + * + * @return array + * + * @since 4.0.0 + */ + public function getWorkflowContexts(): array; }