diff --git a/FEATURES/104332 b/FEATURES/104332 new file mode 100644 index 0000000000000000000000000000000000000000..c515f4dffe7c7f0a5d01c740ab37af248084c993 --- /dev/null +++ b/FEATURES/104332 @@ -0,0 +1,10 @@ + '104332' => + ['Label' => $this->_('[commande] St Cloud : ajout zone tableau PNB'), + 'Desc' => '', + 'Image' => '', + 'Video' => '', + 'Category' => '', + 'Right' => function($feature_description, $user) {return true;}, + 'Wiki' => '', + 'Test' => '', + 'Date' => '2021-01-14'], \ No newline at end of file diff --git a/VERSIONS_WIP/104332 b/VERSIONS_WIP/104332 new file mode 100644 index 0000000000000000000000000000000000000000..f80b4b1e11acccd5b2cf2b0c5fbf1b4d0ec67093 --- /dev/null +++ b/VERSIONS_WIP/104332 @@ -0,0 +1 @@ + - ticket #104332 : PNB administration : ajout zone genre et sections dans le tableau \ No newline at end of file diff --git a/library/Class/AdminVar.php b/library/Class/AdminVar.php index fa82bfa15922dcb1adea37aa7a784b114b1756a6..792d1686a22bf43dc1b0b1d50982f4de12a4e186 100644 --- a/library/Class/AdminVar.php +++ b/library/Class/AdminVar.php @@ -210,7 +210,9 @@ class Class_AdminVarLoader extends Storm_Model_Loader { 'DILICOM_PNB_HOLD_AVAILABLE_MAIL' => Class_AdminVar_Meta::newEditor($this->_('Email de notification de disponibilité de reservation numérique'), ['value'=>'Bonjour {user_name},<p>Le document <a href="{record_url}">{record_title}</a> vous est réservé pour emprunt jusqu\'au {hold_expiration_date}.</p>']), 'DILICOM_PNB_RECORD_MAX_HOLD_COUNT' => Class_AdminVar_Meta::newDefault($this->_('Nombre maximum de réservations par document numérique'), ['value' => 3]), - 'DILICOM_PNB_PATRON_MAX_HOLD_COUNT' => Class_AdminVar_Meta::newDefault($this->_('Nombre maximum de réservations par utilisateur'), ['value' => 2])]; + 'DILICOM_PNB_PATRON_MAX_HOLD_COUNT' => Class_AdminVar_Meta::newDefault($this->_('Nombre maximum de réservations par utilisateur'), ['value' => 2]), + 'DILICOM_PNB_BOARD_DISPLAY_SECTION' => Class_AdminVar_Meta::newOnOff($this->_('Affichage des sections et genres dans le tableau d\'administration des prêts PNB'))] + ; } diff --git a/library/Class/MultiSelection/AlbumItem.php b/library/Class/MultiSelection/AlbumItem.php new file mode 100644 index 0000000000000000000000000000000000000000..940a1e497d1342a6e1b297bf4cff2ec4501e1d35 --- /dev/null +++ b/library/Class/MultiSelection/AlbumItem.php @@ -0,0 +1,45 @@ +<?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 Class_MultiSelection_AlbumItem extends Class_MultiSelection_Album { + public function getModelIdsFromCategory($id) { + if(!$id) + return []; + + return (new Storm_Model_Collection(Class_Album_Item::getItemsOf($id))) + ->collect('id') + ->getArrayCopy(); + } + + + public function getModels() { + if(!$values = $this->getValues()) + return new Storm_Model_Collection([]); + + return new Storm_Model_Collection(Class_Album_Item::findAll()); + } + + + protected function _getStorage() { + return new Class_MultiSelection_SessionStorage('albumitem'); + } +} \ No newline at end of file diff --git a/library/Class/TableDescription/PNBItems.php b/library/Class/TableDescription/PNBItems.php index 33944e92a1d5c3f4adf5246d83df6f5fc450bd6e..97b134fabb743d190f53fd3996c85c141fd57fe2 100644 --- a/library/Class/TableDescription/PNBItems.php +++ b/library/Class/TableDescription/PNBItems.php @@ -33,14 +33,27 @@ class Class_TableDescription_PNBItems extends Class_TableDescription { }) ->addColumn($this->_('Durée de prêt en jours'), 'duration') ->addColumn($this->_('Nombre de jours restant sur la licence'), 'license_expiration') - ->addColumn($this->_('Date de commande'), 'order_date') - ->addRowAction(['url' => ['module' => 'admin', - 'controller' => 'album', - 'action' => 'edit_album', - 'id' => '%s'], - 'id' => function($model) { return $model->getAlbumId(); }, - 'anchorOptions' => ['data-popup' => 'true'], - 'label' => $this->_('Voir l\'album'), - 'icon' => 'view']); + ->addColumn($this->_('Date de commande'), 'order_date'); + + if (Class_AdminVar::get('DILICOM_PNB_BOARD_DISPLAY_SECTION')) + $this->addColumn($this->_('Genre'), 'genre') + ->addColumn($this->_('Section'), 'section'); + + $this->addRowAction(['url' => ['module' => 'admin', + 'controller' => 'album', + 'action' => 'edit_album', + 'id' => '%s'], + 'id' => function($model) { return $model->getAlbumId(); }, + 'anchorOptions' => ['data-popup' => 'true'], + 'label' => $this->_('Voir l\'album'), + 'icon' => 'view']); + + $multi_selection = new Class_MultiSelection_AlbumItem(); + + foreach( (new ZendAfi_Controller_Plugin_MultiSelection_LeafActions($multi_selection)) + ->getActions() as $action) { + $action['id'] = function($model) { return $model->getAlbumId(); }; + $this->addRowAction($action); + } } } diff --git a/library/Class/TableDescription/PNBItemsRenderer.php b/library/Class/TableDescription/PNBItemsRenderer.php index 69e0e25adab68a89496f0bfc605498b16a9ded7b..3887e7a229ac2ae11a7d066f5cb8c5e76fd7209b 100644 --- a/library/Class/TableDescription/PNBItemsRenderer.php +++ b/library/Class/TableDescription/PNBItemsRenderer.php @@ -52,6 +52,20 @@ class Class_TableDescription_PNBItemsRenderer { } + public function getSection() { + if ($sections = $this->_item->getAlbum()->getSections()) + return implode(', ',Class_CodifSection::labelsOfIds(explode(';',$sections))->getArrayCopy()); + return ''; + } + + + public function getGenre() { + if ($genre = $this->_item->getAlbum()->getGenre()) + return implode(', ',Class_CodifGenre::labelsOfIds(explode(';',$genre))->getArrayCopy()); + return ''; + } + + public function quantityOrInfinite($value) { return $this->isInfinite($value) ? '∞' diff --git a/library/ZendAfi/Controller/Plugin/MultiSelection/Abstract.php b/library/ZendAfi/Controller/Plugin/MultiSelection/Abstract.php index f9bc12403253e6832a0f20673843108de9a0c5f3..9662b83c8a2cbe045ea6dff4988491f52d626900 100644 --- a/library/ZendAfi/Controller/Plugin/MultiSelection/Abstract.php +++ b/library/ZendAfi/Controller/Plugin/MultiSelection/Abstract.php @@ -48,7 +48,7 @@ abstract class ZendAfi_Controller_Plugin_MultiSelection_Abstract extends ZendAfi public function clearModelsSelectionAction() { $this->_multi_selection->clear(); - $this->_redirect($this->_view->absoluteUrl(['action' => 'index'])); + return $this->_redirectToReferer(); } @@ -161,7 +161,8 @@ abstract class ZendAfi_Controller_Plugin_MultiSelection_Abstract extends ZendAfi public function render() { if (('index' == $this->_request->getActionName()) - || ('edit-multiple' == $this->_request->getActionName())) + || ('edit-multiple' == $this->_request->getActionName()) + || ('dilicom' == $this->_request->getActionName())) return $this->_view->Plugin_MultiSelection_Widget($this->_multi_selection); return ''; diff --git a/tests/scenarios/PnbDilicom/PnbDilicomTest.php b/tests/scenarios/PnbDilicom/PnbDilicomTest.php index 4f46447088ce73cc5dc3f9ea564b1eb4e2aecf02..3d172cc4999cf7103efdfb3a72bd114814449347 100644 --- a/tests/scenarios/PnbDilicom/PnbDilicomTest.php +++ b/tests/scenarios/PnbDilicom/PnbDilicomTest.php @@ -2933,10 +2933,18 @@ abstract class PnbDilicomAdminAlbumControllerTestCase extends Admin_AbstractCont ['id' => 23, 'libelle' => 'Heavy Metal']); + $this->fixture('Class_CodifGenre', + ['id' => 24, + 'libelle' => 'Death Metal']); + $this->fixture('Class_CodifSection', ['id' => 33, 'libelle' => 'Espace métal']); + $this->fixture('Class_CodifSection', + ['id' => 34, + 'libelle' => 'Espace musique']); + $fondu = $this->fixture('Class_AlbumCategorie', ['id' => 1301, 'libelle' => 'Fondu']); @@ -2946,8 +2954,8 @@ abstract class PnbDilicomAdminAlbumControllerTestCase extends Admin_AbstractCont 'id_origine' => 'Dilicom-3663608260879', 'titre' => 'Hell is from here to eternity', 'type_doc_id' => Class_TypeDoc::DILICOM, - 'genre' => '23', - 'sections' => '33', + 'genre' => '23;24', + 'sections' => '33;34', 'categorie' => $fondu]) ->addAuthor('Iron Maiden') ->addEditor('EMI') @@ -3034,6 +3042,7 @@ class PnbDilicomAdminAlbumControllerImportDilicomTest extends PnbDilicomAdminAlb public function setUp() { parent::setUp(); + Class_AdminVar::set('DILICOM_PNB_BOARD_DISPLAY_SECTION', true); $this->dispatch('/admin/album/dilicom', true); } @@ -3087,6 +3096,24 @@ class PnbDilicomAdminAlbumControllerImportDilicomTest extends PnbDilicomAdminAlb } + /** @test */ + public function sectionsShouldBeDisplayed() { + $this->assertXPathContentContains('//table//tr/td', 'Heavy Metal, Death Metal'); + } + + + /** @test */ + public function genreShouldBeDisplayed() { + $this->assertXPathContentContains('//table//tr/td', 'Espace métal, Espace musique'); + } + + + /** @test */ + public function multiselectBasketShouldBeDisplayedWithAlbumId() { + $this->assertXPath('//a[contains(@href,"/admin/album/add-model-to-selection/select_id/23")]',$this->_response->getBody()); + } + + /** @test */ public function nbOfHoldsShouldBeSix() { $this->assertXPath('//table//tr[3]/td[text()="6"]');