Skip to content

[4.0][Workflow] Add component specific workflow conditions#21585

Merged
wilsonge merged 19 commits intojoomla:4.0-devfrom
HLeithner:workflow-conditions
Aug 17, 2018
Merged

[4.0][Workflow] Add component specific workflow conditions#21585
wilsonge merged 19 commits intojoomla:4.0-devfrom
HLeithner:workflow-conditions

Conversation

@HLeithner
Copy link
Copy Markdown
Member

Pull Request for Issue # .

Summary of Changes

Introduce condition constants into com_content container used for the workflow. This provides the possibility to define conditions per component. This also reintroduce the archive condition in com_content.

Testing Instructions

Expected result

You should have a "archive" condition.

Additional

@alikon please check the db changes, you already did the enum change for postgresql


$query = $db->getQuery(true);

$query ->select($db->quoteName('condition'))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove spaces

@wilsonge
Copy link
Copy Markdown
Contributor

OK can you fix conflicts here - then let's get this one tested

@HLeithner HLeithner force-pushed the workflow-conditions branch from ac1ea48 to 789aef1 Compare August 14, 2018 21:44
@HLeithner
Copy link
Copy Markdown
Member Author

@wilsonge rebase done, @bembelimen can you retest the pr?

$section = $parts[1];
}

$join = $db->quoteName('#__content') . ' AS c ON ct.content_item_id=c.id';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the quoteName second param here instead of hardcoding the AS

* registering HTML services.
*
* @param ContainerInterface $container The container
* @param ContainerInterface $container The container
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style is 3 spaces then TypeHint 2 spaces then variable name 2 spaces then description. You've broken it in every function of this file (hence the code style failure)

elseif (!is_numeric($workflowStage))
{
$query->where($db->quoteName('ws.condition') . ' IN (' . $query->quote(Workflow::PUBLISHED) . ',' . $query->quote(Workflow::UNPUBLISHED) . ')');
$query->where($db->quoteName('ws.condition') . ' IN (' .
Copy link
Copy Markdown
Contributor

@wilsonge wilsonge Aug 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use $query->whereIn function

$query->where($db->quoteName('ws.condition') . ' = ' . $query->quote($condition));
}
}
$query->where($db->quoteName('ws.condition') . ' = ' . (int) $condition);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabs not spaces please

<option value="">COM_WORKFLOW_SELECT_CONDITION</option>
</field>


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the extra space here

elseif (!is_numeric($workflowStage))
{
$query->where($db->quoteName('ws.condition') . ' IN ("0","1")');
$query->where($db->quoteName('ws.condition') . ' IN (' .
Copy link
Copy Markdown
Contributor

@wilsonge wilsonge Aug 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabs here and use whereIn

];

/**
* @var oomla\Database\DatabaseDriver
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joomla

elseif (!is_numeric($workflowStage))
{
$query->where($db->quoteName('ws.condition') . ' IN (' . $query->quote(Workflow::PUBLISHED) . ',' . $query->quote(Workflow::UNPUBLISHED) . ')');
$query->whereIn($db->quoteName('ws.condition'), [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameters need to be on a new line. So

$query->whereIn(
	$db->quoteName('ws.condition'),
	[

and for the other 2 places

@HLeithner
Copy link
Copy Markdown
Member Author

@wilsonge may could you describe it for an idiot?

name="condition"
type="list"
label="COM_CONTENT_STATES"
type="workflowcondition"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduce indentation by 1 from lines 24-28

description="COM_WORKFLOW_CONDITION_DESC"
onchange="this.form.submit();"
extension="com_content"
>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent by 1.

elseif (!is_numeric($workflowStage))
{
$query->whereIn($db->quoteName('ws.condition'), [
$query->whereIn($db->quoteName('ws.condition'),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope :) Look at my example again :P

$query->whereIn(
	$db->quoteName('ws.condition'),
	[

(2, 0, 2, 1, 1, 'Published', '', 1, 1),
(3, 0, 3, 1, 1, 'Trashed', '', -2, 0),
(4, 0, 4, 1, 1, 'Archived', '', 1, 0);
(4, 0, 4, 1, 1, 'Archived', '', 2, 0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be done in the postgres files too

@wilsonge
Copy link
Copy Markdown
Contributor

Now you can fix codestyle again :D

@HLeithner
Copy link
Copy Markdown
Member Author

YaY

->from($db->quoteName('#__workflow_stages'))
->where($db->quoteName('workflow_id') . ' IN(' . implode(',', $ids) . ')')
->where($db->quoteName('published') . '>= 0')
->group('workflow_id');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use $db->quoteName()

->from($db->quoteName('#__workflow_transitions'))
->where($db->quoteName('workflow_id') . ' IN(' . implode(',', $ids) . ')')
->where($db->quoteName('published') . '>= 0')
->group('workflow_id');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use $db->quoteName()


/**
* The extension where we're
* The component and section seperated by ".".
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separated not seperated. twice

@bembelimen
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on 887f57e


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/21585.

@infograf768
Copy link
Copy Markdown
Member

Looks ok, although I do not have anymore the Articles - Archived module available in the list of new modules to create and therefore can't test archived articles.
screen shot 2018-08-17 at 11 08 35

@HLeithner
Copy link
Copy Markdown
Member Author

The module isn't part of this PR and should comeback when archive is restored. This PR is only the base that it is possible to do the archive behavior

@infograf768
Copy link
Copy Markdown
Member

infograf768 commented Aug 17, 2018

It is apparently replaced by a Module called Articles-List which is not in the list of modules (in the modules/ folder)
screen shot 2018-08-17 at 11 16 35

There we have a "Choose State" field where it looks like it displays a workflow with its default stages.
By default it is set to Archived and the result in frontend is not a display of the Archived articles

EDIT: In fact it is the archived module which denomination has changed to Articles - List...

@infograf768
Copy link
Copy Markdown
Member

I have tested this item ✅ successfully on 887f57e

Let's this get in as other PRs are dependent from it.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/21585.

@ghost
Copy link
Copy Markdown

ghost commented Aug 17, 2018

Ready to Commit after two successful tests.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Aug 17, 2018
@wilsonge wilsonge merged commit aca906d into joomla:4.0-dev Aug 17, 2018
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Aug 17, 2018
@wilsonge wilsonge added this to the Joomla 4.0 milestone Aug 17, 2018
@HLeithner HLeithner deleted the workflow-conditions branch March 29, 2020 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants