Skip to content
Snippets Groups Projects
Commit c1b97f03 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

hotline #59422 : ability to disable onchange behavior on default admin buttons

parent 716ceb62
Branches
Tags
4 merge requests!2334Master,!2124Master,!2123Hotline master,!2120hotline #59422 : ability to disable onchange behavior on default admin buttons
Pipeline #1208 passed with stage
in 17 minutes and 41 seconds
- ticket #59422 : Administration : Le formulaire d'ajout de batch peut être envoyé sans modifications
\ No newline at end of file
......@@ -34,11 +34,9 @@ class ZendAfi_Controller_Plugin_ResourceDefinition_Batch extends ZendAfi_Control
'actions' => ['add' => ['title' => $this->_('Nouvelle Tâche')],
'index' => ['title' => $this->_('Tâches')]],
'display_groups' => ['ajout_tache' => ['legend' => 'Ajouter une tâche',
'elements' => ['type' => ['element' => 'select',
'options' => ['multiOptions' => Class_Batch::getAvailableType(),
'required' => true]] ]]],
'after_add' => function() {$this->_redirect('/admin/batch');}
'after_add' => function() {$this->_redirect('/admin/batch');},
'form_class_name' => 'ZendAfi_Form_Admin_Batch'
];
}
}
......
<?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_Form_Admin_Batch extends ZendAfi_Form {
public function init() {
parent::init();
$this
->setAttrib('data-disable-onchange', 'true')
->addElement('select', 'type',
['multiOptions' => Class_Batch::getAvailableType(),
'required' => true])
->addDisplayGroup(['type'], 'ajout_tache', []);
}
}
......@@ -22,10 +22,11 @@
class ZendAfi_View_Helper_Admin_Button_Cancel extends ZendAfi_View_Helper_Button_Cancel {
protected function _getDefaultAttribs() {
return array_merge(parent::_getDefaultAttribs(),
['class' => 'undo',
'disabled' => 'disabled']);
$attribs = ['class' => 'undo'];
if (!$this->view->disable_onchange)
$attribs['disabled'] = 'disabled';
return array_merge(parent::_getDefaultAttribs(), $attribs);
}
......
......@@ -22,9 +22,11 @@
class ZendAfi_View_Helper_Admin_Button_Continue extends ZendAfi_View_Helper_Button_Continue {
protected function _getDefaultAttribs() {
return array_merge(parent::_getDefaultAttribs(),
['class' => 'continue',
'disabled' => 'disabled']);
$attribs = ['class' => 'continue'];
if (!$this->view->disable_onchange)
$attribs['disabled'] = 'disabled';
return array_merge(parent::_getDefaultAttribs(), $attribs);
}
......
......@@ -22,9 +22,11 @@
class ZendAfi_View_Helper_Admin_Button_Submit extends ZendAfi_View_Helper_Button_Submit {
protected function _getDefaultAttribs() {
return array_merge(parent::_getDefaultAttribs(),
['class' => 'validate',
'disabled' => 'disabled']);
$attribs = ['class' => 'validate'];
if (!$this->view->disable_onchange)
$attribs['disabled'] = 'disabled';
return array_merge(parent::_getDefaultAttribs(), $attribs);
}
......
......@@ -21,7 +21,7 @@
class ZendAfi_View_Helper_Admin_RenderForm extends ZendAfi_View_Helper_RenderForm {
public function renderForm($form, $buttons = []) {
if(!$form)
if (!$form)
return '';
if (!$form->getAttrib('class'))
......@@ -30,6 +30,9 @@ class ZendAfi_View_Helper_Admin_RenderForm extends ZendAfi_View_Helper_RenderFor
if (!$form->getId())
$form->setAttrib('id', md5(implode($form->getElementsNames())));
if ('true' == $form->getAttrib('data-disable-onchange'))
$this->view->disable_onchange = true;
$this->_tabify($form);
$this->_customizeRendering();
......@@ -54,10 +57,10 @@ class ZendAfi_View_Helper_Admin_RenderForm extends ZendAfi_View_Helper_RenderFor
protected function _cloneButtons($form) {
if($this->view->isPopup())
if ($this->view->isPopup())
return '';
if(1 >= count($form->getDisplayGroups()))
if (1 >= count($form->getDisplayGroups()))
return $this;
Class_ScriptLoader::getInstance()
......@@ -68,12 +71,12 @@ class ZendAfi_View_Helper_Admin_RenderForm extends ZendAfi_View_Helper_RenderFor
protected function _renderDefaultButtons($form, $buttons = []) {
if($this->view->isPopup())
if ($this->view->isPopup())
$buttons = array_merge([$this->view->Button_Continue()],
$buttons);
return $this->_tag('div',
implode($buttons),
['class' => 'admin-buttons']);
}
}
?>
\ No newline at end of file
......@@ -131,6 +131,12 @@ class BatchControllerAddTest extends BatchControllerTestCase {
? $this->assertXPath($path, $this->_response->getBody())
: $this->assertNotXPath($path, $this->_response->getBody());
}
/** @test */
public function submitButtonShouldNotBeDisabled() {
$this->assertNotXPath('//button[contains(@class, "validate")][@disabled]');
}
}
......
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