Skip to content

Commit

Permalink
[4.0] Workflow enhancement
Browse files Browse the repository at this point in the history
Move workflows towards a state machine with workflow plugins
  • Loading branch information
wilsonge authored May 29, 2020
2 parents 99ba11a + bd5e237 commit fe0563c
Show file tree
Hide file tree
Showing 125 changed files with 4,664 additions and 1,966 deletions.
15 changes: 15 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,18 @@ plugins/system/webauthn/* @nikosdion
media/plg_system_webauthn/* @nikosdion
language/administrator/en-GB/en-GB.plg_system_webauthn.ini @nikosdion
language/administrator/en-GB/en-GB.plg_system_webauthn.sys.ini @nikosdion

# Workflow
administrator/components/com_workflow/* @bembelimen @hleithner
administrator/language/en-GB/com_workflow.ini @bembelimen @hleithner
administrator/language/en-GB/com_workflow.sys.ini @bembelimen @hleithner
administrator/language/en-GB/plg_workflow_publishing.ini @bembelimen @hleithner
administrator/language/en-GB/plg_workflow_publishing.sys.ini @bembelimen @hleithner
libraries/src/Form/Field/TransitionField.php @bembelimen @hleithner
libraries/src/Form/Field/Workflow* @bembelimen @hleithner
libraries/src/HTML/Helpers/Workflow* @bembelimen @hleithner
libraries/src/MVC/Model/Workflow* @bembelimen @hleithner
libraries/src/MVC/Model/Workflow* @bembelimen @hleithner
libraries/src/Workflow/* @bembelimen @hleithner
build/media_source/com_workflow/* @bembelimen @hleithner
plugins/workflow/* @bembelimen @hleithner
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ CREATE TABLE IF NOT EXISTS `#__workflows` (
`description` text NOT NULL,
`extension` varchar(50) NOT NULL,
`default` tinyint(1) NOT NULL DEFAULT 0,
`core` tinyint(1) NOT NULL DEFAULT 0,
`ordering` int(11) NOT NULL DEFAULT 0,
`created` datetime NOT NULL,
`created_by` int(10) NOT NULL DEFAULT 0,
Expand All @@ -34,8 +33,8 @@ CREATE TABLE IF NOT EXISTS `#__workflows` (
-- Dumping data for table `#__workflows`
--

INSERT INTO `#__workflows` (`id`, `asset_id`, `published`, `title`, `description`, `extension`, `default`, `core`,`ordering`, `created`, `created_by`, `modified`, `modified_by`, `checked_out_time`, `checked_out`) VALUES
(1, 0, 1, 'COM_WORKFLOW_DEFAULT_WORKFLOW', '', 'com_content', 1, 1, 1, CURRENT_TIMESTAMP(), 0, CURRENT_TIMESTAMP(), 0, NULL, 0);
INSERT INTO `#__workflows` (`id`, `asset_id`, `published`, `title`, `description`, `extension`, `default`, `ordering`, `created`, `created_by`, `modified`, `modified_by`, `checked_out_time`, `checked_out`) VALUES
(1, 0, 1, 'COM_WORKFLOW_BASIC_WORKFLOW', '', 'com_content.article', 1, 1, CURRENT_TIMESTAMP(), 0, CURRENT_TIMESTAMP(), 0, NULL, 0);

--
-- Table structure for table `#__workflow_associations`
Expand Down Expand Up @@ -64,7 +63,6 @@ CREATE TABLE IF NOT EXISTS `#__workflow_stages` (
`published` tinyint(1) NOT NULL DEFAULT 0,
`title` varchar(255) NOT NULL,
`description` text NOT NULL,
`condition` int(10) DEFAULT 0,
`default` tinyint(1) NOT NULL DEFAULT 0,
`checked_out_time` datetime,
`checked_out` int(10) NOT NULL DEFAULT 0,
Expand All @@ -80,11 +78,8 @@ CREATE TABLE IF NOT EXISTS `#__workflow_stages` (
-- Dumping data for table `#__workflow_stages`
--

INSERT INTO `#__workflow_stages` (`id`, `asset_id`, `ordering`, `workflow_id`, `published`, `title`, `description`, `condition`, `default`, `checked_out_time`, `checked_out`) VALUES
(1, 0, 1, 1, 1, 'JUNPUBLISHED', '', 0, 1, NULL, 0),
(2, 0, 2, 1, 1, 'JPUBLISHED', '', 1, 0, NULL, 0),
(3, 0, 3, 1, 1, 'JTRASHED', '', -2, 0, NULL, 0),
(4, 0, 4, 1, 1, 'JARCHIVED', '', 2, 0, NULL, 0);
INSERT INTO `#__workflow_stages` (`id`, `asset_id`, `ordering`, `workflow_id`, `published`, `title`, `description`, `default`, `checked_out_time`, `checked_out`) VALUES
(1, 0, 1, 1, 1, 'COM_WORKFLOW_BASIC_STAGE', '', 1, NULL, 0);

--
-- Table structure for table `#__workflow_transitions`
Expand All @@ -100,6 +95,7 @@ CREATE TABLE IF NOT EXISTS `#__workflow_transitions` (
`description` text NOT NULL,
`from_stage_id` int(10) NOT NULL,
`to_stage_id` int(10) NOT NULL,
`options` text NOT NULL,
`checked_out_time` datetime,
`checked_out` int(10) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
Expand All @@ -115,21 +111,31 @@ CREATE TABLE IF NOT EXISTS `#__workflow_transitions` (
-- Dumping data for table `#__workflow_transitions`
--

INSERT INTO `#__workflow_transitions` (`id`, `asset_id`, `published`, `ordering`, `workflow_id`, `title`, `description`, `from_stage_id`, `to_stage_id`, `checked_out_time`, `checked_out`) VALUES
(1, 0, 1, 1, 1, 'Unpublish', '', -1, 1, NULL, 0),
(2, 0, 1, 2, 1, 'Publish', '', -1, 2, NULL, 0),
(3, 0, 1, 3, 1, 'Trash', '', -1, 3, NULL, 0),
(4, 0, 1, 4, 1, 'Archive', '', -1, 4, NULL, 0);
INSERT INTO `#__workflow_transitions` (`id`, `asset_id`, `published`, `ordering`, `workflow_id`, `title`, `description`, `from_stage_id`, `to_stage_id`, `options`, `checked_out_time`, `checked_out`) VALUES
(1, 0, 1, 1, 1, 'Unpublish', '', -1, 1, '{"publishing":"0"}', NULL, 0),
(2, 0, 1, 2, 1, 'Publish', '', -1, 1, '{"publishing":"1"}', NULL, 0),
(3, 0, 1, 3, 1, 'Trash', '', -1, 1, '{"publishing":"-2"}', NULL, 0),
(4, 0, 1, 4, 1, 'Archive', '', -1, 1, '{"publishing":"2"}', NULL, 0),
(5, 0, 1, 5, 1, 'Feature', '', -1, 1, '{"featuring":"1"}', NULL, 0),
(6, 0, 1, 6, 1, 'Unfeature', '', -1, 1, '{"featuring":"0"}', NULL, 0),
(7, 0, 1, 7, 1, 'Publish & Feature', '', -1, 1, '{"publishing":"1","featuring":"1"}', NULL, 0);

--
-- Creating extension entry
--
-- Note that the old pseudo null dates have to be used for the `checked_out_time`
-- column because the conversion to real null dates will be done with a later
-- update SQL script.
--

INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES
(0, 'com_workflow', 'component', 'com_workflow', '', 1, 1, 0, 0, '', '{}', 0, '0000-00-00 00:00:00', 0, 0);
(0, 'com_workflow', 'component', 'com_workflow', '', 1, 1, 0, 1, '', '{}', 0, '0000-00-00 00:00:00', 0, 0),
(0, 'plg_workflow_publishing', 'plugin', 'publishing', 'workflow', 0, 1, 1, 0, '', '{}', 0, '0000-00-00 00:00:00', 0, 0),
(0, 'plg_workflow_featuring', 'plugin', 'featuring', 'workflow', 0, 1, 1, 0, '', '{}', 0, '0000-00-00 00:00:00', 0, 0),
(0, 'plg_workflow_notification', 'plugin', 'notification', 'workflow', 0, 1, 1, 0, '', '{}', 0, '0000-00-00 00:00:00', 0, 0);

--
-- Creating Associations for existing content
--
INSERT INTO `#__workflow_associations` (`item_id`, `stage_id`, `extension`)
SELECT `id`, CASE WHEN `state` = -2 THEN 3 WHEN `state` = 0 THEN 1 WHEN `state` = 2 THEN 4 ELSE 2 END, 'com_content' FROM `#__content`;
SELECT `id`, 1, 'com_content.article' FROM `#__content`;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ CREATE TABLE IF NOT EXISTS "#__workflows" (
"description" text NOT NULL,
"extension" varchar(50) NOT NULL,
"default" smallint NOT NULL DEFAULT 0,
"core" smallint NOT NULL DEFAULT 0,
"ordering" bigint NOT NULL DEFAULT 0,
"created" timestamp without time zone NOT NULL,
"created_by" bigint DEFAULT 0 NOT NULL,
Expand All @@ -31,8 +30,8 @@ CREATE INDEX "#__workflows_idx_modified" ON "#__workflows" ("modified");
CREATE INDEX "#__workflows_idx_modified_by" ON "#__workflows" ("modified_by");
CREATE INDEX "#__workflows_idx_checked_out" ON "#__workflows" ("checked_out");

INSERT INTO "#__workflows" ("id", "asset_id", "published", "title", "description", "extension", "default", "core", "ordering", "created", "created_by", "modified", "modified_by", "checked_out_time", "checked_out") VALUES
(1, 0, 1, 'COM_WORKFLOW_DEFAULT_WORKFLOW', '', 'com_content', 1, 1, 1, CURRENT_TIMESTAMP, 0, CURRENT_TIMESTAMP, 0, NULL, 0);
INSERT INTO "#__workflows" ("id", "asset_id", "published", "title", "description", "extension", "default", "ordering", "created", "created_by", "modified", "modified_by", "checked_out_time", "checked_out") VALUES
(1, 0, 1, 'COM_WORKFLOW_BASIC_WORKFLOW', '', 'com_content.article', 1, 1, CURRENT_TIMESTAMP, 0, CURRENT_TIMESTAMP, 0, NULL, 0);

--
-- Table structure for table "#__workflow_associations"
Expand Down Expand Up @@ -64,7 +63,6 @@ CREATE TABLE IF NOT EXISTS "#__workflow_stages" (
"published" smallint NOT NULL DEFAULT 0,
"title" varchar(255) NOT NULL,
"description" text NOT NULL,
"condition" bigint DEFAULT 0 NOT NULL,
"default" smallint NOT NULL DEFAULT 0,
"checked_out_time" timestamp without time zone,
"checked_out" bigint DEFAULT 0 NOT NULL,
Expand All @@ -80,11 +78,8 @@ CREATE INDEX "#__workflow_stages_idx_checked_out" ON "#__workflow_stages" ("chec
-- Dumping data for table "#__workflow_stages"
--

INSERT INTO "#__workflow_stages" ("id", "asset_id", "ordering", "workflow_id", "published", "title", "description", "condition", "default", "checked_out_time", "checked_out") VALUES
(1, 0, 1, 1, 1, 'JUNPUBLISHED', '', 0, 1, NULL, 0),
(2, 0, 2, 1, 1, 'JPUBLISHED', '', 1, 0, NULL, 0),
(3, 0, 3, 1, 1, 'JTRASHED', '', -2, 0, NULL, 0),
(4, 0, 4, 1, 1, 'JARCHIVED', '', 2, 0, NULL, 0);
INSERT INTO "#__workflow_stages" ("id", "asset_id", "ordering", "workflow_id", "published", "title", "description", "default", "checked_out_time", "checked_out") VALUES
(1, 0, 1, 1, 1, 'COM_WORKFLOW_BASIC_STAGE', '', 1, NULL, 0);

--
-- Table structure for table "#__workflow_transitions"
Expand All @@ -100,6 +95,7 @@ CREATE TABLE IF NOT EXISTS "#__workflow_transitions" (
"description" text NOT NULL,
"from_stage_id" bigint DEFAULT 0 NOT NULL,
"to_stage_id" bigint DEFAULT 0 NOT NULL,
"options" text NOT NULL,
"checked_out_time" timestamp without time zone,
"checked_out" bigint DEFAULT 0 NOT NULL,
PRIMARY KEY ("id")
Expand All @@ -111,21 +107,31 @@ CREATE INDEX "#__workflow_transitions_idx_to_stage_id" ON "#__workflow_transitio
CREATE INDEX "#__workflow_transitions_idx_workflow_id" ON "#__workflow_transitions" ("workflow_id");
CREATE INDEX "#__workflow_transitions_idx_checked_out" ON "#__workflow_transitions" ("checked_out");

INSERT INTO "#__workflow_transitions" ("id", "asset_id", "published", "ordering", "workflow_id", "title", "description", "from_stage_id", "to_stage_id", "checked_out_time", "checked_out") VALUES
(1, 0, 1, 1, 1, 'Unpublish', '', -1, 1, NULL, 0),
(2, 0, 1, 2, 1, 'Publish', '', -1, 2, NULL, 0),
(3, 0, 1, 3, 1, 'Trash', '', -1, 3, NULL, 0),
(4, 0, 1, 4, 1, 'Archive', '', -1, 4, NULL, 0);
INSERT INTO "#__workflow_transitions" ("id", "asset_id", "published", "ordering", "workflow_id", "title", "description", "from_stage_id", "to_stage_id", "options", "checked_out_time", "checked_out") VALUES
(1, 0, 1, 1, 1, 'Unpublish', '', -1, 1, '{"publishing":"0"}', NULL, 0),
(2, 0, 1, 2, 1, 'Publish', '', -1, 1, '{"publishing":"1"}', NULL, 0),
(3, 0, 1, 3, 1, 'Trash', '', -1, 1, '{"publishing":"-2"}', NULL, 0),
(4, 0, 1, 4, 1, 'Archive', '', -1, 1, '{"publishing":"2"}', NULL, 0),
(5, 0, 1, 5, 1, 'Feature', '', -1, 1, '{"featuring":"1"}', NULL, 0),
(6, 0, 1, 6, 1, 'Unfeature', '', -1, 1, '{"featuring":"0"}', NULL, 0),
(7, 0, 1, 7, 1, 'Publish & Feature', '', -1, 1, '{"publishing":"1","featuring":"1"}', NULL, 0);

--
-- Creating extension entry
--
-- Note that the old pseudo null dates have to be used for the "checked_out_time"
-- column because the conversion to real null dates will be done with a later
-- update SQL script.
--

INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "checked_out", "checked_out_time", "ordering", "state") VALUES
(0, 'com_workflow', 'component', 'com_workflow', '', 1, 1, 0, 0, '', '{}', 0, '1970-01-01 00:00:00', 0, 0);
(0, 'com_workflow', 'component', 'com_workflow', '', 1, 1, 0, 1, '', '{}', 0, '1970-01-01 00:00:00', 0, 0),
(0, 'plg_workflow_publishing', 'plugin', 'publishing', 'workflow', 0, 1, 1, 0, '', '{}', 0, '1970-01-01 00:00:00', 0, 0),
(0, 'plg_workflow_featuring', 'plugin', 'featuring', 'workflow', 0, 1, 1, 0, '', '{}', 0, '1970-01-01 00:00:00', 0, 0),
(0, 'plg_workflow_notification', 'plugin', 'notification', 'workflow', 0, 1, 1, 0, '', '{}', 0, '1970-01-01 00:00:00', 0, 0);

--
-- Creating Associations for existing content
--
INSERT INTO "#__workflow_associations" ("item_id", "stage_id", "extension")
SELECT "id", CASE WHEN "state" = -2 THEN 3 WHEN "state" = 0 THEN 1 WHEN "state" = 2 THEN 4 ELSE 2 END, 'com_content' FROM "#__content";
SELECT "id", 1, 'com_content.article' FROM "#__content";
12 changes: 8 additions & 4 deletions administrator/components/com_content/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1039,13 +1039,17 @@
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

</fieldset>
<fieldset
name="integration_workflows"
label="JWORKFLOW_TITLE"
>
<field
name="workflows_enable"
name="workflow_enabled"
type="radio"
label="JGLOBAL_WORKFLOWS_ENABLE_LABEL"
label="JWORKFLOW_ENABLED_LABEL"
layout="joomla.form.field.radio.switcher"
default="1"
default="0"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
Expand Down
59 changes: 32 additions & 27 deletions administrator/components/com_content/forms/article.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,18 @@
/>

<field
name="transition"
type="transition"
label="COM_CONTENT_TRANSITION"
extension="com_content"
/>
name="state"
type="list"
label="JSTATUS"
class="custom-select-color-state"
size="1"
default="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>

<field
name="tags"
Expand Down Expand Up @@ -157,6 +164,26 @@
filter="user_utc"
/>

<field
name="featured_up"
type="calendar"
label="COM_CONTENT_FIELD_FEATURED_UP_LABEL"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>

<field
name="featured_down"
type="calendar"
label="COM_CONTENT_FIELD_FEATURED_DOWN_LABEL"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
/>

<field
name="version"
type="text"
Expand Down Expand Up @@ -228,28 +255,6 @@
<option value="1">JYES</option>
</field>

<field
name="featured_up"
type="calendar"
label="COM_CONTENT_FIELD_FEATURED_UP_LABEL"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
showon="featured:1"
/>

<field
name="featured_down"
type="calendar"
label="COM_CONTENT_FIELD_FEATURED_DOWN_LABEL"
translateformat="true"
showtime="true"
size="22"
filter="user_utc"
showon="featured:1"
/>

<field
name="rules"
type="rules"
Expand Down
10 changes: 5 additions & 5 deletions administrator/components/com_content/forms/filter_articles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
label="JOPTION_SELECT_STAGE"
onchange="this.form.submit();"
activeonly="true"
extension="com_content"
extension="com_content.article"
>
<option value="">JOPTION_SELECT_STAGE</option>
</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
10 changes: 5 additions & 5 deletions administrator/components/com_content/forms/filter_featured.xml
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"
extension="com_content.article"
>
<option value="">JOPTION_SELECT_CONDITION</option>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>

<field
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_content/presets/content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
title="COM_CONTENT_MENUS_WORKFLOW"
type="component"
element="com_workflow"
link="index.php?option=com_workflow&amp;view=workflows&amp;extension=com_content"
link="index.php?option=com_workflow&amp;view=workflows&amp;extension=com_content.article"
/>

<menuitem
Expand Down
Loading

0 comments on commit fe0563c

Please sign in to comment.