Skip to content
Snippets Groups Projects
Commit f3d34e70 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #12992 refacto custom fields forms

parent cb60d5ff
Branches
Tags
5 merge requests!321Dev#12992 custom fields,!302Dev#12992 Custom Fields,!235Dev#12992 Custom Fields,!223Dev#12992 Custom Fields,!216Dev#12992 Custom Fields
<?php
echo $this->bouton('id=add_meta',
'picto=fonctions_admin.png',
'texte='.$this->_('Retour à la liste des champs'),
'texte='.$this->_('Accéder à la liste des champs personnalisés'),
'url=' . $this->url(['module' => 'admin', 'controller' => 'custom-fields-meta'], null, true),
'largeur=350px;'
);
......
<?php
/**
* Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 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).
*
* AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_Form_Admin_CustomFields extends ZendAfi_Form {
public function init() {
parent::init();
$this->_toggleOptionsList();
$this
->setAttrib('id', 'custom_field')
->setAttrib('action', '')
->addElement('text',
'label',
['label' => $this->_('Libellé du champ'),
'size' => 50,
'required' => true,
'allowEmpty' => false])
->addElement('select',
'field_type',
['label' => $this->_('Type de champ'),
'multioptions' => $this->_getFieldTypes(),
'required' => true,
'allowEmpty' => false])
->addElement('text',
'options_list',
['label' => $this->_('Options pour le type "liste d\'options"'),
'size' => 50,
'placeholder' => $this->_('option 1; option 2; option 3')]);
}
protected function _getFieldTypes() {
return [Class_CustomField_Meta::TEXT_INPUT => $this->_('champ texte'),
Class_CustomField_Meta::TEXT_AREA => $this->_('champ zone de texte'),
Class_CustomField_Meta::SELECT => $this->_("liste d'options")];
}
protected function _toggleOptionsList() {
return Class_ScriptLoader::getInstance()
->addJQueryBackEnd('$("#field_type").change(function(event) {if(this.value=="SELECT") {$("#fieldset-options").removeClass("invisible"); return false} if(!$("#fieldset-options").hasClass("invisible")) {$("#fieldset-options").addClass("invisible"); return false;}});');
}
}
?>
\ No newline at end of file
......@@ -20,7 +20,7 @@
*/
class ZendAfi_Form_Admin_CustomFields_CustomFieldMeta extends ZendAfi_Form {
class ZendAfi_Form_Admin_CustomFields_CustomFieldMeta extends ZendAfi_Form_Admin_CustomFields {
public static function newWith($custom_field_meta_array) {
$form = new self();
$form
......@@ -30,45 +30,5 @@ class ZendAfi_Form_Admin_CustomFields_CustomFieldMeta extends ZendAfi_Form {
'class' => 'invisible']);
return $form;
}
public function init() {
parent::init();
$this->_toggleOptionsList();
$this
->setAttrib('id', 'custom_field')
->setAttrib('action', '')
->addElement('text',
'label',
['label' => $this->_('Libellé du champ'),
'size' => 50,
'required' => false,
'allowEmpty' => true])
->addElement('select',
'field_type',
['label' => $this->_('Type de champ'),
'multioptions' => $this->_getFieldTypes(),
'required' => false,
'allowEmpty' => true])
->addElement('text',
'options_list',
['label' => $this->_('Options pour le type "liste d\'options"'),
'size' => 50,
'placeholder' => $this->_('option 1; option 2; option 3')]);
}
protected function _getFieldTypes() {
return [Class_CustomField_Meta::TEXT_INPUT => $this->_('champ texte'),
Class_CustomField_Meta::TEXT_AREA => $this->_('champ zone de texte'),
Class_CustomField_Meta::SELECT => $this->_("liste d'options")];
}
protected function _toggleOptionsList() {
return Class_ScriptLoader::getInstance()
->addJQueryBackEnd('$("#field_type").change(function(event) {if(this.value=="SELECT") {$("#fieldset-options").removeClass("invisible"); return false} if(!$("#fieldset-options").hasClass("invisible")) {$("#fieldset-options").addClass("invisible"); return false;}});');
}
}
?>
\ No newline at end of file
......@@ -20,56 +20,17 @@
*/
class ZendAfi_Form_Admin_CustomFields_CustomFieldModel extends ZendAfi_Form {
class ZendAfi_Form_Admin_CustomFields_CustomFieldModel extends ZendAfi_Form_Admin_CustomFields {
public static function newWith($custom_field_array) {
$form = new self();
$form
->addElement('hidden', 'model')
->populate($custom_field_array)
->addDisplayGroup(['label', 'field_type', 'model'],'base',['legend' => ''])
->addDisplayGroup(['options_list'], 'options', ['legend' => $form->_('Options'),
'class' => 'invisible']);
return $form;
}
public function init() {
parent::init();
$this->_toggleOptionsList();
$this
->setAttrib('id', 'custom_field')
->setAttrib('action', '')
->addElement('text',
'label',
['label' => $this->_('Libellé du champ'),
'size' => 50,
'required' => true,
'allowEmpty' => false])
->addElement('select',
'field_type',
['label' => $this->_('Type de champ'),
'multioptions' => $this->_getFieldTypes(),
'required' => true,
'allowEmpty' => false])
->addElement('hidden', 'model')
->addElement('text',
'options_list',
['label' => $this->_('Options pour le type "liste d\'options"'),
'size' => 50,
'placeholder' => $this->_('option 1; option 2; option 3')]);
}
protected function _getFieldTypes() {
return [Class_CustomField_Meta::TEXT_INPUT => $this->_('champ texte'),
Class_CustomField_Meta::TEXT_AREA => $this->_('champ zone de texte'),
Class_CustomField_Meta::SELECT => $this->_("liste d'options")];
}
protected function _toggleOptionsList() {
return Class_ScriptLoader::getInstance()
->addJQueryBackEnd('$("#field_type").change(function(event) {if(this.value=="SELECT") {$("#fieldset-options").removeClass("invisible"); return false} if(!$("#fieldset-options").hasClass("invisible")) {$("#fieldset-options").addClass("invisible"); return false;}});');
}
}
?>
\ No newline at end of file
......@@ -126,7 +126,7 @@ class CustomFieldsControllerIndexTest extends CustomFieldControllerTestCase {
/** @test */
public function linkToManageCustomFieldsShouldBePresent() {
$this->assertXPathContentContains('//div[contains(@onclick, "/admin/custom-fields-meta")]//td', 'Retour à la liste des champs');
$this->assertXPathContentContains('//div[contains(@onclick, "/admin/custom-fields-meta")]//td', 'Accéder à la liste des champs personnalisés');
}
}
......
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