From 7e11ead8a8b0293fdfa68aef43bee2dd5bc98cb7 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 3 Jan 2017 11:32:02 +0100 Subject: [PATCH] ProcessController: unify view scripts for config... ...and diff --- application/controllers/ProcessController.php | 74 +++++++++++++++---- .../views/scripts/process/config.phtml | 18 +---- .../views/scripts/process/source.phtml | 16 +--- 3 files changed, 65 insertions(+), 43 deletions(-) diff --git a/application/controllers/ProcessController.php b/application/controllers/ProcessController.php index 6816d77..991b760 100644 --- a/application/controllers/ProcessController.php +++ b/application/controllers/ProcessController.php @@ -296,27 +296,71 @@ class ProcessController extends Controller */ public function sourceAction() { - $this->tabsForConfig()->activate('source'); $bp = $this->loadModifiedBpConfig(); + $this->view->showDiff = $showDiff = (bool) $this->params->get('showDiff', false); $this->view->source = $this->storage()->render($bp); - $this->view->showDiff = (bool) $this->params->get('showDiff', false); - if ($this->view->showDiff) { $this->view->diff = ConfigDiff::create( $this->storage()->getSource($this->view->configName), $this->view->source ); - $this->view->title = sprintf( + $title = sprintf( $this->translate('%s: Source Code Differences'), $bp->getTitle() ); } else { - $this->view->title = sprintf( + $title = sprintf( $this->translate('%s: Source Code'), $bp->getTitle() ); } + + $actionBar = new ActionBar(); + $this->setTitle($title); + $this->controls() + ->add($this->tabsForConfig()->activate('source')) + ->add(HtmlTag::h1($title)) + ->add($actionBar); + + if ($showDiff) { + $actionBar->add( + Link::create( + $this->translate('Source'), + $this->url()->without('showDiff'), + null, + array( + 'class' => 'icon-doc-text', + 'title' => $this->translate('Show source code'), + ) + ) + ); + } else { + $actionBar->add( + Link::create( + $this->translate('Diff'), + $this->url()->with('showDiff', true), + null, + array( + 'class' => 'icon-flapping', + 'title' => $this->translate('Highlight changes'), + ) + ) + ); + } + + $actionBar->add( + Link::create( + $this->translate('Download'), + 'businessprocess/process/download', + array('config' => $bp->getName()), + array( + 'target' => '_blank', + 'class' => 'icon-download', + 'title' => $this->translate('Download process configuration') + ) + ) + ); } /** @@ -345,24 +389,28 @@ class ProcessController extends Controller */ public function configAction() { - $this->tabsForConfig()->activate('config'); $bp = $this->loadModifiedBpConfig(); - $this->setTitle( + $title = sprintf( $this->translate('%s: Configuration'), $bp->getTitle() ); + $this->setTitle($title); + $this->controls() + ->add($this->tabsForConfig()->activate('config')) + ->add(HtmlTag::h1($title)); $url = Url::fromPath( 'businessprocess/process/show?unlocked', array('config' => $bp->getName()) ); - - $this->view->form = $this->loadForm('bpConfig') - ->setProcessConfig($bp) - ->setStorage($this->storage()) - ->setSuccessUrl($url) - ->handleRequest(); + $this->content()->add( + $this->loadForm('bpConfig') + ->setProcessConfig($bp) + ->setStorage($this->storage()) + ->setSuccessUrl($url) + ->handleRequest() + ); } /** diff --git a/application/views/scripts/process/config.phtml b/application/views/scripts/process/config.phtml index c788759..3e2cc59 100644 --- a/application/views/scripts/process/config.phtml +++ b/application/views/scripts/process/config.phtml @@ -1,16 +1,2 @@ -
-tabs ?> -

escape($this->title) ?> - icon('doc-text') ?> -

-
- -
-form ?> -
-deleteForm ?> -
-
- +controls->render() ?> +content->render() ?> diff --git a/application/views/scripts/process/source.phtml b/application/views/scripts/process/source.phtml index d4f7323..d5ba6bb 100644 --- a/application/views/scripts/process/source.phtml +++ b/application/views/scripts/process/source.phtml @@ -1,21 +1,9 @@ -
-tabs ?> -

escape($this->title) ?> - icon('download') ?> -showDiff): ?> - icon('doc-text') ?> - - icon('flapping') ?> - -

-
+controls->render() ?>
showDiff): ?>
-diff->renderHtml() ?> +diff->render() ?>