Skip to content

Commit c20bae1

Browse files
committed
optimized implementation of workflow graph
1 parent 72422df commit c20bae1

File tree

10 files changed

+32
-144
lines changed

10 files changed

+32
-144
lines changed

administrator/components/com_content/forms/article.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,6 @@
259259
section="article"
260260
validate="rules"
261261
/>
262-
263-
<field
264-
name="workflowgraphbtn"
265-
type="transition"
266-
workflow_stage="0"
267-
extension="com_content"
268-
layout="joomla.form.field.workflow.graphbtn"
269-
/>
270-
271262
</fieldset>
272263

273264
<fields name="attribs" label="COM_CONTENT_ATTRIBS_FIELDSET_LABEL">

administrator/components/com_content/src/Model/ArticleModel.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,6 @@ public function getItem($pk = null)
404404
if (!empty($item->id)) {
405405
$item->tags = new TagsHelper();
406406
$item->tags->getTagIds($item->id, 'com_content.article');
407-
$workflow_assoc = $this->workflow->getAssociation($item->id);
408-
409-
if (!empty($workflow_assoc->workflow_id)) {
410-
$item->workflow_id = $workflow_assoc->workflow_id;
411-
}
412407

413408
$item->featured_up = null;
414409
$item->featured_down = null;
@@ -1049,6 +1044,8 @@ protected function preprocessForm(Form $form, $data, $group = 'content')
10491044

10501045
$this->workflowPreprocessForm($form, $data);
10511046

1047+
$form->setFieldAttribute('transition', 'layout', 'joomla.form.field.groupedlist-transition');
1048+
10521049
parent::preprocessForm($form, $data, $group);
10531050
}
10541051

administrator/components/com_content/tmpl/article/edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
</div>
7676
</div>
7777
<div class="col-lg-3">
78-
<?php echo LayoutHelper::render('joomla.edit.article_options', $this); ?>
78+
<?php echo LayoutHelper::render('joomla.edit.global', $this); ?>
7979
</div>
8080
</div>
8181

components/com_content/forms/article.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,6 @@
211211
validate="captcha"
212212
namespace="article"
213213
/>
214-
215-
<field
216-
name="workflowgraphbtn"
217-
type="transition"
218-
workflow_stage="0"
219-
extension="com_content"
220-
layout="joomla.form.field.workflow.graphbtn"
221-
/>
222-
223214
</fieldset>
224215
<fields name="images">
225216
<fieldset name="image-intro">

components/com_content/src/Model/FormModel.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,6 @@ public function getItem($itemId = null)
177177
}
178178
}
179179

180-
if (!empty($value->id)) {
181-
$workflow_assoc = $this->workflow->getAssociation($value->id);
182-
183-
if (!empty($workflow_assoc->workflow_id)) {
184-
$value->workflow_id = $workflow_assoc->workflow_id;
185-
}
186-
}
187180
return $value;
188181
}
189182

components/com_content/tmpl/form/edit.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,7 @@
101101

102102
<?php echo HTMLHelper::_('uitab.addTab', $this->tab_name, 'publishing', Text::_('COM_CONTENT_PUBLISHING')); ?>
103103

104-
<div style="display:flex;align-items:center;gap:8px;">
105-
<div class="w-100">
106-
<?php echo $this->form->renderField('transition'); ?>
107-
</div>
108-
<?php echo $this->form->renderField('workflowgraphbtn'); ?>
109-
</div>
104+
<?php echo $this->form->renderField('transition'); ?>
110105
<?php echo $this->form->renderField('state'); ?>
111106
<?php echo $this->form->renderField('catid'); ?>
112107
<?php echo $this->form->renderField('tags'); ?>

layouts/joomla/edit/article_options.php

Lines changed: 0 additions & 92 deletions
This file was deleted.

layouts/joomla/form/field/workflow/graphbtn.php renamed to layouts/joomla/form/field/groupedlist-transition.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212

1313
use Joomla\CMS\Factory;
1414
use Joomla\CMS\Language\Text;
15+
use Joomla\CMS\Layout\LayoutHelper;
1516

17+
extract($displayData);
1618
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
1719
$wa->getRegistry()->addExtensionRegistryFile('com_workflow');
1820

1921
$wa->useScript('joomla.dialog-autocreate');
2022
$wa->useStyle('com_workflow.workflowgraphclient');
2123

2224
$script = $wa->getAsset('script', name: 'com_workflow.workflowgraphclient')->getUri(true);
23-
$field = $displayData['field'] ?? null;
2425
$workflowId = $field ? $field->getAttribute('workflow_id') : null;
25-
$ishidden = $field && $field->getAttribute('type') === 'hidden';
26-
if ($ishidden || !$workflowId) {
26+
if (!$workflowId) {
2727
return;
2828
}
2929
$popupId = 'workflow-graph-modal-content';
@@ -36,16 +36,23 @@
3636
]);
3737

3838
?>
39-
<div class="align-center text-center btns" style="width: max-content;">
40-
<button type="button" class="btn btn-primary px-3 py-2" data-joomla-dialog="<?php echo htmlspecialchars($popupOptions, ENT_QUOTES, 'UTF-8'); ?>">
41-
<span class="fa fa-diagram-project" aria-hidden="true"></span>
42-
</button>
43-
<div role="tooltip" id="tip-graph">
44-
<?php echo Text::_('COM_WORKFLOW_GRAPH'); ?>
39+
<div class="d-flex align-items-center gap-3">
40+
<div class="flex-grow-1">
41+
<?php echo LayoutHelper::render('joomla.form.field.groupedlist-fancy-select', $displayData); ?>
42+
</div>
43+
<div class="flex-shrink-0">
44+
<div class="align-center text-center btns" style="width: max-content;">
45+
<button type="button" class="btn btn-primary px-3 py-2" data-joomla-dialog="<?php echo htmlspecialchars($popupOptions, ENT_QUOTES, 'UTF-8'); ?>">
46+
<span class="fa fa-diagram-project" aria-hidden="true"></span>
47+
</button>
48+
<div role="tooltip" id="tip-graph">
49+
<?php echo Text::_('COM_WORKFLOW_GRAPH'); ?>
50+
</div>
51+
</div>
4552
</div>
4653
</div>
47-
<template id="workflow-graph-modal-content">
4854

55+
<template id="workflow-graph-modal-content">
4956
<div class="p-3">
5057
<section
5158
class="d-flex flex-wrap align-items-center justify-content-between"

libraries/src/Form/Field/TransitionField.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
7979
} else {
8080
$this->workflowStage = $input->getInt('id');
8181
}
82+
83+
$db = $this->getDatabase();
84+
$workflowStage = (int) $this->workflowStage;
85+
86+
87+
$query = $db->getQuery(true)
88+
->select($db->quoteName('workflow_id'))
89+
->from($db->quoteName('#__workflow_stages'))
90+
->where($db->quoteName('id') . ' = ' . (int) $workflowStage);
91+
92+
$this->form->setFieldAttribute('transition', 'workflow_id', $db->setQuery($query)->loadResult());
8293
}
8394

8495
return $result;

libraries/src/MVC/Model/WorkflowBehaviorTrait.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,6 @@ protected function addTransitionField(Form $form, $data)
356356
if (!empty($assoc->stage_id)) {
357357
$form->setFieldAttribute('transition', 'workflow_stage', (int) $assoc->stage_id);
358358
}
359-
360-
if (!empty($assoc->workflow_id)) {
361-
$form->setFieldAttribute('workflowgraphbtn', 'workflow_id', (int) $assoc->workflow_id);
362-
$form->setFieldAttribute('workflowgraphbtn', 'type', $this->workflowEnabled ? 'transition' : 'hidden');
363-
}
364359
} else {
365360
$stage_id = $this->getStageForNewItem($form, $data);
366361

0 commit comments

Comments
 (0)