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

Remove condition from com_content #54

Merged
merged 5 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
</field>

<field
name="condition"
type="workflowcondition"
label="JOPTION_SELECT_CONDITION"
name="published"
type="status"
label="JOPTION_SELECT_PUBLISHED"
onchange="this.form.submit();"
extension="com_content"
>
<option value="">JOPTION_SELECT_CONDITION</option>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
</field>

<field
name="condition"
type="workflowcondition"
label="JOPTION_SELECT_CONDITION"
name="published"
type="status"
label="JOPTION_SELECT_PUBLISHED"
onchange="this.form.submit();"
extension="com_content"
>
<option value="">JOPTION_SELECT_CONDITION</option>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>

<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

defined('_JEXEC') or die;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormFactoryInterface;
Expand Down Expand Up @@ -1418,7 +1419,6 @@ protected function getWorkflowByCategory(int $catId)
$query->select(
[
$db->quoteName('w.id'),
$db->quoteName('ws.condition'),
$db->quoteName('ws.id', 'stage_id'),
]
)
Expand Down Expand Up @@ -1453,7 +1453,6 @@ protected function getWorkflowByCategory(int $catId)
$query->select(
[
$db->quoteName('w.id'),
$db->quoteName('ws.condition'),
$db->quoteName('ws.id', 'stage_id'),
]
)
Expand Down
27 changes: 7 additions & 20 deletions administrator/components/com_content/src/Model/ArticlesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public function __construct($config = array())
'level',
'tag',
'rating_count', 'rating',
'condition',
'stage',
);

Expand Down Expand Up @@ -120,9 +119,6 @@ protected function populateState($ordering = 'a.id', $direction = 'desc')
$published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
$this->setState('filter.published', $published);

$condition = $this->getUserStateFromRequest($this->context . '.filter.condition', 'filter_condition', '');
$this->setState('filter.condition', $condition);

$level = $this->getUserStateFromRequest($this->context . '.filter.level', 'filter_level');
$this->setState('filter.level', $level);

Expand Down Expand Up @@ -251,7 +247,6 @@ protected function getListQuery()
$db->quoteName('ua.name', 'author_name'),
$db->quoteName('wa.stage_id', 'stage_id'),
$db->quoteName('ws.title', 'stage_title'),
$db->quoteName('ws.condition', 'stage_condition'),
$db->quoteName('ws.workflow_id', 'workflow_id'),
]
)
Expand Down Expand Up @@ -339,20 +334,20 @@ protected function getListQuery()
->bind(':stage', $workflowStage, ParameterType::INTEGER);
}

$condition = (string) $this->getState('filter.condition');
$published = (string) $this->getState('filter.published');

if ($condition !== '*')
if ($published !== '*')
{
if (is_numeric($condition))
if (is_numeric($published))
{
$condition = (int) $condition;
$query->where($db->quoteName('ws.condition') . ' = :condition')
->bind(':condition', $condition, ParameterType::INTEGER);
$state = (int) $state;
$query->where($db->quoteName('a.state') . ' = :state')
->bind(':state', $published, ParameterType::INTEGER);
}
elseif (!is_numeric($workflowStage))
{
$query->whereIn(
$db->quoteName('ws.condition'),
$db->quoteName('a.state'),
[
ContentComponent::CONDITION_PUBLISHED,
ContentComponent::CONDITION_UNPUBLISHED,
Expand Down Expand Up @@ -581,7 +576,6 @@ public function getTransitions()
$db->quoteName('t.to_stage_id'),
$db->quoteName('s.id', 'stage_id'),
$db->quoteName('s.title', 'stage_title'),
$db->quoteName('s.condition', 'stage_condition'),
$db->quoteName('s.workflow_id'),
]
)
Expand Down Expand Up @@ -610,13 +604,6 @@ public function getTransitions()
{
unset($transitions[$key]);
}
else
{
// Update the transition text with final state value
$conditionName = $workflow->getConditionName((int) $transition['stage_condition']);

$transitions[$key]['text'] .= ' [' . Text::_($conditionName) . ']';
}
}

$this->cache[$store] = $transitions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function __construct($config = array())
'level',
'tag',
'rating_count', 'rating',
'condition',
'stage',
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public function display($tpl = null)
$this->filterForm->setFieldAttribute('category_id', 'language', '*,' . $forcedLanguage, 'filter');
}
}

/*
@TODO Move to the plugin

$transitions = [
'publish' => [],
Expand Down Expand Up @@ -147,6 +150,8 @@ public function display($tpl = null)
}

$this->document->addScriptOptions('articles.transitions', $transitions);

*/

$articles = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public function display($tpl = null)
unset($this->activeFilters['language']);
$this->filterForm->removeField('language', 'filter');
}


/*
@TODO Move to plugin
$transitions = [
'publish' => [],
'unpublish' => [],
Expand Down Expand Up @@ -126,6 +128,7 @@ public function display($tpl = null)
}

$this->document->addScriptOptions('articles.transitions', $transitions);
*/

$articles = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@
$archive = 0;
$trash = 0;

foreach ($transitions as $transition) :
/*
* @TODO This should be moved to a plugin + the data attributes in the tr below
foreach ($transitions as $transition) :
switch ($transition['stage_condition']) :
case ContentComponent::CONDITION_PUBLISHED:
++$publish;
Expand All @@ -187,7 +189,7 @@
++$trash;
break;
endswitch;
endforeach;
endforeach;*/

?>
<tr class="row<?php echo $i % 2; ?>" data-dragable-group="<?php echo $item->catid; ?>"
Expand Down Expand Up @@ -252,7 +254,7 @@
->addState(ContentComponent::CONDITION_ARCHIVED, '', 'archive', Text::_('COM_CONTENT_CHANGE_STAGE'), ['tip_title' => Text::_('JARCHIVED')])
->addState(ContentComponent::CONDITION_TRASHED, '', 'trash', Text::_('COM_CONTENT_CHANGE_STAGE'), ['tip_title' => Text::_('JTRASHED')])
->setLayout('joomla.button.transition-button')
->render($item->stage_condition, $i, $options, $item->publish_up, $item->publish_down);
->render($item->state, $i, $options, $item->publish_up, $item->publish_down);
?>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\String\StringHelper;
Expand Down Expand Up @@ -285,4 +286,22 @@ protected function loadFormData()

return $data;
}

/**
* Trigger the form preparation for the workflow group
*
* @param Form $form A Form object.
* @param mixed $data The data expected for the form.
* @param string $group The name of the plugin group to import (defaults to "content").
*
* @return void
*
* @see FormField
* @since 4.0.0
* @throws \Exception if there is an error in the form event.
*/
protected function preprocessForm(Form $form, $data, $group = 'workflow')
{
parent::preprocessForm($form, $data, $group);
}
}
1 change: 0 additions & 1 deletion administrator/language/en-GB/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,6 @@ JOPTION_SELECT_AUTHORS="- Select Authors -"
JOPTION_SELECT_AUTHOR_ALIAS="- Select Author Alias -"
JOPTION_SELECT_AUTHOR_ALIASES="- Select Author Aliases -"
JOPTION_SELECT_CATEGORY="- Select Category -"
JOPTION_SELECT_CONDITION="- Select Condition -"
JOPTION_SELECT_EDITOR="- Select Editor -"
JOPTION_SELECT_FEATURED="- Select Featured -"
JOPTION_SELECT_IMAGE="- Select Image -"
Expand Down