diff --git a/VERSIONS_HOTLINE/132232 b/VERSIONS_HOTLINE/132232 new file mode 100644 index 0000000000000000000000000000000000000000..68df2f0aad53f052f2bc61fe04e1541fe0f9e889 --- /dev/null +++ b/VERSIONS_HOTLINE/132232 @@ -0,0 +1 @@ + - ticket #132232 : Magasin de thèmes : Dans la liste des réservations de l'abonné, les réservations PNB peuvent maintenant être supprimées. \ No newline at end of file diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index 17fdf620b5b9815f65286b6135958836f03a611d..5c72af30655ebfaf0c8a876b84cae631f2c893a9 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -93,10 +93,17 @@ class AbonneController extends ZendAfi_Controller_Action { public function deletePnbHoldAction() { $hold = Class_Hold_Pnb::find($this->_getParam('id')); + if (!$hold){ + $this->_helper->notify($this->_('La réservation recherchée avec l\'identifiant %s n\'a pas été trouvée.', + $this->_getParam('id'))); + $this->_redirectCloseReferer(); + return; + } + $hold->delete(); $this->_helper->notify($this->_('Votre réservation du document %s a bien été supprimée.', $hold->getTitle())); - $this->_redirectToReferer(); + $this->_redirectCloseReferer(); } diff --git a/library/Class/User/CardsOperationDecorator.php b/library/Class/User/CardsOperationDecorator.php index 97359ff7b1d75dbcb32db54587d03a33bd635a18..b4acf4a0d8609d80680164e71e8e8568fadddb03 100644 --- a/library/Class/User/CardsOperationDecorator.php +++ b/library/Class/User/CardsOperationDecorator.php @@ -53,6 +53,11 @@ class Class_User_CardsOperationDecorator { } + public function getOperationId() { + return $this->_operation->getId(); + } + + public function isPNB() { return $this->_operation->isPNB(); } diff --git a/library/ZendAfi/Controller/Action.php b/library/ZendAfi/Controller/Action.php index 52614fdefae1e0d94eed5f1fffafc363afcb2490..4b90ff7c3c4a13c6213249eaedf02224e52fa3ef 100644 --- a/library/ZendAfi/Controller/Action.php +++ b/library/ZendAfi/Controller/Action.php @@ -136,6 +136,11 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { } + protected function _redirectCloseReferer() { + $this->_redirectClose($this->_getReferer()); + } + + public function setResourceDefinition($definitions) { $this->_definitions = $definitions; } diff --git a/library/templates/Intonation/Library/View/Wrapper/PNBHold.php b/library/templates/Intonation/Library/View/Wrapper/PNBHold.php index b646d06f7aa29ba4dd34dd4f7850b4e27fbed42d..235c4bb1e1dbd85dda79e4f2f67559a99d578d3c 100644 --- a/library/templates/Intonation/Library/View/Wrapper/PNBHold.php +++ b/library/templates/Intonation/Library/View/Wrapper/PNBHold.php @@ -55,12 +55,17 @@ class Intonation_Library_View_Wrapper_PNBHold extends Intonation_Library_View_Wr return [ new Intonation_Library_Link(['Url' => $this->_view->url(['controller' => 'abonne', 'action' => 'delete-pnb-hold', - 'id' => $this->_model->getId()]), + 'id' => $this->_getModelId()]), 'Text' => $this->_('Supprimer'), 'Image' => $this->getIco('delete', 'utils'), 'Title' => $this->_('Supprimer la réservation du document %s', $this->_model->getTitre()), + 'Popup' => true, 'Confirm' => $this->_('Confirmez-vous la suppression de la réservation du document %s ? ', $this->_model->getTitre())])]; } + + private function _getModelId() { + return $this->_model->getOperationId(); + } } \ No newline at end of file diff --git a/tests/scenarios/PnbDilicom/PnbDilicomDisplayTest.php b/tests/scenarios/PnbDilicom/PnbDilicomDisplayTest.php index 26f1426021af6f814708aeba9e79f76aee98bd18..8cb1743bd088049c82fea3e4db497e304e13c220 100644 --- a/tests/scenarios/PnbDilicom/PnbDilicomDisplayTest.php +++ b/tests/scenarios/PnbDilicom/PnbDilicomDisplayTest.php @@ -1635,7 +1635,7 @@ class PnbDilicomDisplayAbonneDeletePnbHoldTest extends PnbDilicomDisplayBibNumer /** @test */ - public function deleteHoldPNBWithUserSixAndIdOneShouldDeleteIt() { + public function deleteHoldPNBWithIdOneShouldDeleteIt() { $this->dispatch('/abonne/delete-pnb-hold/id/1'); $this->assertNull(Class_Hold_Pnb::find(1)); } @@ -1646,4 +1646,11 @@ class PnbDilicomDisplayAbonneDeletePnbHoldTest extends PnbDilicomDisplayBibNumer $this->dispatch('/abonne/delete-pnb-hold/id/1'); $this->assertFlashMessengerContentContains('Votre réservation du document Totem et Thora a bien été supprimée.'); } + + /** @test */ + public function whenDeletePnbHoldCalledWithInexistantIdShouldDisplayError() { + $this->dispatch('/abonne/delete-pnb-hold/id/42'); + $this->assertFlashMessengerContentContains('La réservation recherchée avec l\'identifiant 42 n\'a pas été trouvée.'); + + } } diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index 02f33a536737506ba2af1bc936601f8220e0ee44..e5e106b6ed78bcb2f14c2a7aff680ec18884c1c7 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -1407,7 +1407,7 @@ class TemplatesAbonneWithPNBHoldsTest extends AbstractControllerTestCase { /** @test */ public function actionDeleteHoldShouldPresent() { - $this->assertXPathContentContains('//div//a[@href="/abonne/delete-pnb-hold/id/6_1"][@class="card-link"]', 'Supprimer'); + $this->assertXPathContentContains('//div//a[@href="/abonne/delete-pnb-hold/id/1"][@class="card-link"]', 'Supprimer'); } }