From 1667793693e3a837694bc260a6a892b6e96082e8 Mon Sep 17 00:00:00 2001 From: Patrick Barroca <pbarroca@sandbox.pergame.net> Date: Fri, 15 Jan 2016 17:24:01 +0100 Subject: [PATCH] rel #33379: redmine fix after functional tests --- .../views/scripts/redmine/edit-issue.phtml | 4 +- library/ZendAfi/Form/Admin/Library.php | 14 +--- library/ZendAfi/Form/Redmine/Issue.php | 67 +++++++++---------- library/ZendAfi/View/Helper/RenderForm.php | 5 +- .../admin/controllers/BibControllerTest.php | 17 ----- 5 files changed, 40 insertions(+), 67 deletions(-) diff --git a/application/modules/admin/views/scripts/redmine/edit-issue.phtml b/application/modules/admin/views/scripts/redmine/edit-issue.phtml index 012bd47a3d0..970664867c8 100644 --- a/application/modules/admin/views/scripts/redmine/edit-issue.phtml +++ b/application/modules/admin/views/scripts/redmine/edit-issue.phtml @@ -12,7 +12,9 @@ <table> <tr> <td></td> - <td class="gauche"><pre style="font-family:inherit;font-size:130%"><?php echo $this->issue->getdescription(); ?><pre></td> + <td class="gauche"><pre style="font-family:inherit;font-size:130%;white-space:normal;"> + <?php echo nl2br($this->issue->getdescription()); ?><pre> + </td> </tr> </table> </fieldset> diff --git a/library/ZendAfi/Form/Admin/Library.php b/library/ZendAfi/Form/Admin/Library.php index 5012f702aed..978153d59e2 100644 --- a/library/ZendAfi/Form/Admin/Library.php +++ b/library/ZendAfi/Form/Admin/Library.php @@ -217,22 +217,12 @@ class ZendAfi_Form_Admin_Library extends ZendAfi_Form { 'renderPassword' => true, 'autocomplete' => 'off']) - ->addElement('text', - 'redmine_status', - ['label' => $this->_('Tester la configuration')]) - ->addDisplayGroup(['redmine_login', 'redmine_password', - 'redmine_api_key', - 'redmine_status'], + 'redmine_api_key'], 'redmine', ['legend' => $this->_('Configuration du compte Redmine')]); - $this->getElement('redmine_status') - ->addDecorator('Redmine', ['view' => $this->getView(), - 'library' => $this->getView()->bib]); - return $this; } -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/library/ZendAfi/Form/Redmine/Issue.php b/library/ZendAfi/Form/Redmine/Issue.php index 1ef1451c87c..d431b4140c5 100644 --- a/library/ZendAfi/Form/Redmine/Issue.php +++ b/library/ZendAfi/Form/Redmine/Issue.php @@ -31,8 +31,7 @@ class ZendAfi_Form_Redmine_Issue extends ZendAfi_Form { return (new static()) ->initIssue($issue) ->initMultiOptions($service) - ->initHeader() - ->initDescription(); + ->initInputs(); } @@ -56,25 +55,45 @@ class ZendAfi_Form_Redmine_Issue extends ZendAfi_Form { } - protected function initHeader() { - $inputs = ['customer', 'status_id', 'priority', 'module', 'contact']; - + protected function initInputs() { if (!$this->_issue->getid()) { - array_unshift($inputs, 'subject'); $this ->addElement('text', 'subject', ['label' => $this->_('Sujet'), - 'size' => 50, + 'size' => 70, + 'required' => true, + 'allowEmpty' => false]) + + ->addElement('textarea', + 'description', + ['label' => $this->_('Description'), + 'rows' => 10, + 'cols' => 70, 'required' => true, - 'allowEmpty' => false]); + 'allowEmpty' => false, + 'value' => $this->getDefaultDescription()]) + + ->addDisplayGroup(['subject', 'description'], + 'common', + ['legend' => '']) + ; } + + if ($this->_issue->getid()) { + $this + ->addElement('textarea', 'notes', ['rows' => 5, 'cols' => 100]) + ->addDisplayGroup(['notes'], 'default', ['legend' => $this->_('Nouvelle note')]); + } + + $this->addStatus() ->addElement('text', 'customer', ['label' => $this->_('Client'), + 'size' => 70, 'value' => $this->_issue->getCustomer() ? $this->_issue->getCustomer() : $this->getDefaultCustomer()]) ->addElement('select', @@ -94,16 +113,13 @@ class ZendAfi_Form_Redmine_Issue extends ZendAfi_Form { ->addElement('textarea', 'contact', ['label' => $this->_('Personne à contacter'), - 'rows' => 2, 'cols' => 50, + 'rows' => 2, 'cols' => 70, 'value' => $this->_issue->getContact() ? $this->_issue->getContact() : $this->getDefaultContact()]) - ->addDisplayGroup($inputs, 'header_group', ['legend' => $this->_('Propriétés')]); - - if ($this->_issue->getid()) { - $this->addElement('textarea', 'notes', ['rows' => 5]); - $this->addDisplayGroup(['notes'], 'default', ['legend' => $this->_('Nouvelle note')]); - } + ->addDisplayGroup(['customer', 'status_id', 'priority', 'module', 'contact'], + 'properties', + ['legend' => $this->_('Propriétés')]); return $this; } @@ -198,27 +214,6 @@ class ZendAfi_Form_Redmine_Issue extends ZendAfi_Form { } - protected function initDescription() { - if ($this->_issue->getid()) - return $this; - - $this - ->addElement('textarea', - 'description', - ['rows' => 10, - 'required' => true, - 'allowEmpty' => false, - 'value' => $this->getDefaultDescription()]) - - ->addDisplayGroup(['description'], - 'description_group', - ['legend' => $this->_('Description')]) - ; - - return $this; - } - - protected function getDefaultDescription() { $datas = [$this->_('Url : ') . Class_Url::rootUrl() . Class_Url::baseUrl(), $this->_('Version : ') . BOKEH_RELEASE_NUMBER . ' (' . BOKEH_VERSION . ')', diff --git a/library/ZendAfi/View/Helper/RenderForm.php b/library/ZendAfi/View/Helper/RenderForm.php index 2e29746ac61..999e83afa07 100644 --- a/library/ZendAfi/View/Helper/RenderForm.php +++ b/library/ZendAfi/View/Helper/RenderForm.php @@ -79,7 +79,10 @@ class ZendAfi_View_Helper_RenderForm extends ZendAfi_View_Helper_BaseHelper { protected function _decoratorsForTableRendering($element) { $newDecorators = []; - $element->onkeypress = 'if (event.keyCode == 13) {this.form.submit();return false;}'; + + if ('formText' == $element->helper) + $element->onkeypress = 'if (event.keyCode == 13) {this.form.submit();return false;}'; + $decorators = $element->getDecorators(); foreach ($decorators as $name => $decorator) { $name = explode('_', $name); diff --git a/tests/application/modules/admin/controllers/BibControllerTest.php b/tests/application/modules/admin/controllers/BibControllerTest.php index 1bd0cefbe88..ce023d58c2b 100644 --- a/tests/application/modules/admin/controllers/BibControllerTest.php +++ b/tests/application/modules/admin/controllers/BibControllerTest.php @@ -1283,23 +1283,6 @@ class BibControllerWithRemineAPITest extends BibControllerWithRedmineAPITestCase public function anchorRedmineShouldBePresent() { $this->assertXPath('//form//a[@name="redmine"]'); } - - /** @test */ - public function anchorTestApiSettingsShouldBePresent() { - $this->assertXPath('//a[contains(@href, "/admin/redmine/test/id_bib/2")][@data-popup="true"][@data-status="/admin/redmine/test/id_bib/2"]', $this->_response->getBody()); - } - - - /** @test */ - public function redmineJSShouldBeLoaded() { - $this->assertXPath('//script[contains(@src, "/opac/js/redmine.js")]'); - } - - - /** @test */ - public function redmineAutoRefreshShouldLoaded() { - $this->assertXPathContentContains('//script', '$("a.redmine_status").autoRefresh();'); - } } -- GitLab