Skip to content
Snippets Groups Projects
Commit 739f3c04 authored by efalcy's avatar efalcy
Browse files

dev #72825 : add Loans table configuration

parent 77494966
3 merge requests!2713Dev#72825 contractuel bdp64 afficher la colonne reserve par d autres,!2707Tessadoc lost pass,!2702Dev#72825 contractuel bdp64 afficher la colonne reserve par d autres
Pipeline #4420 failed with stage
in 33 minutes and 41 seconds
......@@ -82,9 +82,19 @@ class Admin_ModulesController extends ZendAfi_Controller_Action {
public function abonneAction() {
if ($this->_getParam('action1') === 'suggestion-achat-add')
return $this->_simpleAction('abonne_suggestion_achat_add');
if ($this->_getParam('action1') === 'prets')
return $this->_forward('abonne-prets');
return $this->_simpleAction('abonne_all');
}
public function abonnePretsAction() {
$this->view->form = ZendAfi_Form_Configuration_Loans::newWith($this->preferences);
$this->view->form->setAction($this->view->url());
if ($this->_request->isPost())
$this->updateEtRetour($this->_request->getPost());
}
public function authAction() {
if ('register' == $this->_getParam('action1'))
......
<?php
echo $this->renderForm($this->form);
<?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_Configuration_Loans extends ZendAfi_Form {
public function init() {
parent::init();
$this
->addElement('text',
'titre',
['label' => $this->_('Titre'),
'size' => $this->_text_size])
->addElement('select',
'boite',
['label' => $this->_('Style de boite'),
'multiOptions' => (new Class_Profil_Templates(
Class_Profil::getCurrentProfil()))->toArray()])
->addElement('dragAndDrop',
'table_composition',
['label' => $this->_('Composition du tableau'),
'value' => null,
'entityfactory' => function($value) {
$pref = new Class_Entity(['Id' => 'table_composition',
'AvailableHeader' => $this->_('Colonnes disponibles'),
'SelectedHeader' => $this->_('Colonnes activées'),
'Available' => $this->_getAvailablesItems($value),
'Selected' => $this->_getSelectedItems($value)]);
return $pref;
}])
->addToDisplaySettingsGroup(['table_composition'])
->addToStyleGroup(['titre',
'boite']);
}
protected function _getSelectedItems($value) {
if (!$value)
return $this->_getDefaultItems();
$selected = [];
foreach($this->_getHeaderCompositionFromString($value) as $id)
$selected[] = $this->_getEntity($id);
return array_filter($selected);
}
protected function _getEntity($id) {
foreach($this->_getAllItems() as $instance)
if($id == $instance->getId())
return $instance;
return null;
}
protected function _getHeaderCompositionFromString($value) {
return explode(';', $value);
}
protected function _getAllItems() {
return array_merge($this->_getDefaultItems(),
$this->_getOptionalItems());
}
protected function _getDefaultItems() {
return [(new Class_Entity())
->setId('loaned_by')
->setLabel($this->_('Emprunté par')),
(new Class_Entity())
->setId('doctype')
->setLabel($this->_('Support')),
(new Class_Entity())
->setId('thumbnail')
->setLabel($this->_('Vignette')),
(new Class_Entity())
->setId('title')
->setLabel($this->_('Titre')),
(new Class_Entity())
->setId('author')
->setLabel($this->_('Auteur')),
(new Class_Entity())
->setId('library')
->setLabel($this->_('Bibliothèque')),
(new Class_Entity())
->setId('return_date')
->setLabel($this->_('Retour prévu'))];
}
protected function _getAvailablesItems($value) {
if(!$value)
return $this->_getOptionalItems();
$settings = $this->_getHeaderCompositionFromString($value);
return (new Storm_Collection($this->_getAllItems()))
->select(function($item) use ($settings)
{
return !in_array($item->getId(), $settings);
})
->getArrayCopy();
}
protected function _getOptionalItems() {
return [(new Class_Entity())
->setId('Informations')
->setLabel($this->_('Informations')),
(new Class_Entity())
->setId('Onhold')
->setLabel($this->_('Déjà réservé par d\'autres'))];
}
}
......@@ -1429,3 +1429,23 @@ class ModulesControllerNoticeApplyToActionPostTestCase
'2')['boite']);
}
}
class ModulesControllerLoansConfiguration extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->dispatch('/admin/modules/abonne/action1/prets',true);
}
/** @test */
public function tableConfigurationShouldBeDrapAndDrop() {
$this->assertXPath('//p[@class="show_drag_and_drop"]',$this->_response->getBody());
}
/** @test */
public function configurationTableShouldHaveSelectedValues() {
}
}
\ No newline at end of file
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