Skip to content

Commit f1af875

Browse files
authored
Added visual graph feature for non Admins in article at run transition (joomla#20)
* added initial workflow graph * removed unused dependency * added some more css changes * permissions added * allowed the workflow access when its graph view * complete implementation * added workflow id from model in both frontend and backend * php alignment issues cleared * php stan error cleared * php code style added * system test errors cleared * cypress error cleared * doc string updated * added workflowgraphbtn field * optimized implementation of workflow graph * Fix XML formatting in article.xml * php style corrected * added typecast to query
1 parent df147bb commit f1af875

File tree

8 files changed

+1109
-4
lines changed

8 files changed

+1109
-4
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,8 @@ protected function preprocessForm(Form $form, $data, $group = 'content')
10441044

10451045
$this->workflowPreprocessForm($form, $data);
10461046

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

administrator/components/com_workflow/src/Controller/GraphController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ public function getTransitions()
257257
foreach ($transitions as $transition) {
258258
$canEdit = $user->authorise('core.edit', $this->extension . '.transition.' . (int) $transition->id);
259259
$canDelete = $user->authorise('core.delete', $this->extension . '.transition.' . (int) $transition->id);
260+
$canRun = $user->authorise('core.execute.transition', $this->extension . '.transition.' . (int) $transition->id);
260261

261262
$response[] = [
262263
'id' => (int) $transition->id,
@@ -268,8 +269,9 @@ public function getTransitions()
268269
'ordering' => (int) $transition->ordering,
269270
'workflow_id' => (int) $transition->workflow_id,
270271
'permissions' => [
271-
'edit' => $canEdit,
272-
'delete' => $canDelete,
272+
'edit' => $canEdit,
273+
'delete' => $canDelete,
274+
'run_transition' => $canRun,
273275
],
274276
];
275277
}

administrator/components/com_workflow/src/Dispatcher/Dispatcher.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,16 @@ class Dispatcher extends ComponentDispatcher
3131
*/
3232
protected function checkAccess()
3333
{
34-
$extension = $this->getApplication()->getInput()->getCmd('extension');
34+
$input = $this->app->getInput();
35+
$view = $input->getCmd('view');
36+
$layout = $input->getCmd('layout');
37+
$extension = $input->getCmd('extension');
38+
$parts = explode('.', $extension);
3539

36-
$parts = explode('.', $extension);
40+
// Allow access to the 'graph' view for all users with access
41+
if ($this->app->isClient('administrator') && $view === 'graph' && $layout === 'modal') {
42+
return;
43+
}
3744

3845
// Check the user has permission to access this component if in the backend
3946
if ($this->app->isClient('administrator') && !$this->app->getIdentity()->authorise('core.manage.workflow', $parts[0])) {

build/media_source/com_workflow/joomla.asset.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@
3131
"attributes": {
3232
"type": "module"
3333
}
34+
},
35+
{
36+
"name" : "com_workflow.workflowgraphclient",
37+
"type": "style",
38+
"uri": "com_workflow/workflow-graph-client.min.css"
39+
},
40+
{
41+
"name": "com_workflow.workflowgraphclient",
42+
"type": "script",
43+
"uri": "com_workflow/workflow-graph-client.min.js",
44+
"dependencies": [
45+
"core"
46+
],
47+
"attributes": {
48+
"type": "module"
49+
}
3450
}
3551
]
3652
}

0 commit comments

Comments
 (0)