Commit a676d984 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline #70867 refacto buttons view helpers

parent ca9b41f5
- ticket #70867 : Ressources numériques Dilicom : amélioration des boutons d'emprunt ou de consultation d'un document PNB.
\ No newline at end of file
......@@ -28,8 +28,8 @@ class ZendAfi_View_Helper_Admin_Button_Back extends ZendAfi_View_Helper_Button_B
}
protected function _getDefaultButton($attribs) {
return parent::_getDefaultButton($attribs)
protected function _getDefaultButton() {
return parent::_getDefaultButton()
->setImage($this->view->tagImg(Class_Admin_Skin::current()
->getIconUrl('buttons',
'back')));
......
......@@ -30,8 +30,8 @@ class ZendAfi_View_Helper_Admin_Button_Cancel extends ZendAfi_View_Helper_Button
}
protected function _getDefaultButton($attribs) {
return parent::_getDefaultButton($attribs)
protected function _getDefaultButton() {
return parent::_getDefaultButton()
->setImage($this->view->tagImg(Class_Admin_Skin::current()
->getIconUrl('buttons',
'remove')))
......
......@@ -30,8 +30,8 @@ class ZendAfi_View_Helper_Admin_Button_Continue extends ZendAfi_View_Helper_Butt
}
protected function _getDefaultButton($attribs) {
return parent::_getDefaultButton($attribs)
protected function _getDefaultButton() {
return parent::_getDefaultButton()
->setImage($this->view->tagImg(Class_Admin_Skin::current()
->getIconUrl('buttons',
'validate')))
......
......@@ -28,10 +28,10 @@ class ZendAfi_View_Helper_Admin_Button_New extends ZendAfi_View_Helper_Button_Ne
}
protected function _getDefaultButton($attribs) {
return parent::_getDefaultButton($attribs)
protected function _getDefaultButton() {
return parent::_getDefaultButton()
->setImage($this->view->tagImg(Class_Admin_Skin::current()
->getIconUrl('buttons',
'add')));
'add')));
}
}
\ No newline at end of file
......@@ -30,8 +30,8 @@ class ZendAfi_View_Helper_Admin_Button_Submit extends ZendAfi_View_Helper_Button
}
protected function _getDefaultButton($attribs) {
return parent::_getDefaultButton($attribs)
protected function _getDefaultButton() {
return parent::_getDefaultButton()
->setImage($this->view->tagImg(Class_Admin_Skin::current()
->getIconUrl('buttons',
'validate')))
......
......@@ -20,32 +20,27 @@
*/
class ZendAfi_View_Helper_Button_Back extends ZendAfi_View_Helper_BaseHelper {
class ZendAfi_View_Helper_Button_Back extends ZendAfi_View_Helper_Button_Helper {
public function Button_Back($settings = null) {
$button = $this->_getDefaultButton($this->_getDefaultAttribs());
if($settings)
$button->updateAttributes($settings->toArray());
return $this->view->button($button);
return $this->render($settings);
}
protected function _getDefaultAttribs() {
$attribs = ['class' => 'bouton back'];
$defaults_attribs = ['class' => 'bouton back'];
if($this->view->isPopup())
$attribs['onclick'] = 'opacDialogClose();';
$defaults_attribs['onclick'] = 'opacDialogClose();';
return $attribs;
return $defaults_attribs;
}
protected function _getDefaultButton($attribs) {
protected function _getDefaultButton() {
return (new Class_Entity())
->setUrl($this->view->url(['action' => 'index',
'render' => null]))
->setAttribs($attribs)
->setAttribs($this->_getDefaultAttribs())
->setText($this->view->isPopup() ? $this->_('Fermer') : $this->_('Retour'))
->setOnFormChange(sprintf('$("button.back").attr("onclick", "if(confirm(\'%s\')) { eval($(this).attr(\'data-script\')); }");',
$this->_('Le formulaire a été modifié. Etes vous sûr de vouloir partir ?')));
......
......@@ -20,15 +20,10 @@
*/
class ZendAfi_View_Helper_Button_Cancel extends ZendAfi_View_Helper_BaseHelper {
class ZendAfi_View_Helper_Button_Cancel extends ZendAfi_View_Helper_Button_Helper {
public function Button_Cancel($settings = null) {
$button = $this->_getDefaultButton($this->_getDefaultAttribs());
if($settings)
$button->updateAttributes($settings->toArray());
return $this->view->button($button);
return $this->render($settings);
}
......@@ -43,10 +38,10 @@ class ZendAfi_View_Helper_Button_Cancel extends ZendAfi_View_Helper_BaseHelper {
}
protected function _getDefaultButton($attribs) {
protected function _getDefaultButton() {
return (new Class_Entity())
->setText($this->_('Annuler'))
->setAttribs($attribs)
->setAttribs($this->_getDefaultAttribs())
->setUrl($this->view->url(['render' => null]));
}
}
\ No newline at end of file
......@@ -22,17 +22,12 @@
class ZendAfi_View_Helper_Button_Continue extends ZendAfi_View_Helper_Button_Submit {
public function Button_Continue($settings = null) {
$button = $this->_getDefaultButton($this->_getDefaultAttribs());
if($settings)
$button->updateAttributes($settings->toArray());
return $this->view->button($button);
return $this->render($settings);
}
protected function _getDefaultButton($attribs) {
return parent::_getDefaultButton($attribs)
protected function _getDefaultButton() {
return parent::_getDefaultButton()
->setText($this->_('Valider et continuer'));
}
......
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_View_Helper_Button_Helper extends ZendAfi_View_Helper_BaseHelper {
public function render($settings) {
$button = $this->_getDefaultButton();
if(!$settings)
return $this->view->button($button);
if(!$settings->getAttribs()) {
$button->updateAttributes($settings->toArray());
return $this->view->button($button);
}
$settings->setAttribs(array_merge($button->getAttribs(),
$settings->getAttribs()));
$button->updateAttributes($settings->toArray());
return $this->view->button($button);
}
}
\ No newline at end of file
......@@ -20,14 +20,9 @@
*/
class ZendAfi_View_Helper_Button_New extends ZendAfi_View_Helper_BaseHelper {
class ZendAfi_View_Helper_Button_New extends ZendAfi_View_Helper_Button_Helper {
public function Button_New($settings = null) {
$button = $this->_getDefaultButton($this->_getDefaultAttribs());
if($settings)
$button->updateAttributes($settings->toArray());
return $this->view->button($button);
return $this->render($settings);
}
......@@ -41,9 +36,9 @@ class ZendAfi_View_Helper_Button_New extends ZendAfi_View_Helper_BaseHelper {
}
protected function _getDefaultButton($attribs) {
protected function _getDefaultButton() {
return (new Class_Entity())
->setAttribs($attribs)
->setAttribs($this->_getDefaultAttribs())
->setUrl($this->view->url(['action' => 'add',
'render' => null]));
}
......
......@@ -20,14 +20,9 @@
*/
class ZendAfi_View_Helper_Button_Submit extends ZendAfi_View_Helper_BaseHelper {
class ZendAfi_View_Helper_Button_Submit extends ZendAfi_View_Helper_Button_Helper {
public function Button_Submit($settings = null) {
$button = $this->_getDefaultButton($this->_getDefaultAttribs());
if($settings)
$button->updateAttributes($settings->toArray());
return $this->view->button($button);
return $this->render($settings);
}
......@@ -51,10 +46,10 @@ class ZendAfi_View_Helper_Button_Submit extends ZendAfi_View_Helper_BaseHelper {
}
protected function _getDefaultButton($attribs) {
protected function _getDefaultButton() {
return (new Class_Entity())
->setText($this->_('Valider'))
->setUrl('')
->setAttribs($attribs);
->setAttribs($this->_getDefaultAttribs());
}
}
\ No newline at end of file
......@@ -210,7 +210,7 @@ class Admin_NewsletterControllerIndexActionTest extends Admin_NewsletterControll
public function testAddLink() {
$this->assertXPath("//button[contains(@onclick, '/admin/newsletter/add')]");
$this->assertXPath("//button[@class='new admin-button'][contains(@onclick, '/admin/newsletter/add')]");
}
}
......
......@@ -580,6 +580,14 @@ class WidgetsPopupMenuTest extends WidgetsSimpleTestCase {
}
/** @test */
public function validateButtonShouldBePresent() {
$this->_xpath->assertXPathContentContains($this->_json['content'],
'//button[@class="validate admin-button"]',
'Valider');
}
/** @test */
public function continueButtonShouldHadParamStylesReloadToFormActionOnClick() {
$this->_xpath->assertXPath($this->_json['content'],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment