diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php index 28edaa96a3090f3517e48cb7c355627599b5acdc..0bc2b07bad2ede7378ad3efa52a0e63f809be958 100644 --- a/module/VuFind/src/VuFind/Controller/MyResearchController.php +++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php @@ -828,6 +828,10 @@ class MyResearchController extends AbstractBase $view = $this->createViewModel(); $view->cancelResults = $cancelStatus ? $this->holds()->cancelHolds($catalog, $patron) : array(); + // If we need to confirm + if (!is_array($view->cancelResults)) { + return $view->cancelResults; + } // By default, assume we will not need to display a cancel form: $view->cancelForm = false; diff --git a/module/VuFind/src/VuFind/Controller/Plugin/Holds.php b/module/VuFind/src/VuFind/Controller/Plugin/Holds.php index 763a86fb5ba150d1f2a44827ccfe07adaf421f65..be520567aee3ba278967c65d5b92aa6218cd1e46 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/Holds.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/Holds.php @@ -163,6 +163,33 @@ class Holds extends AbstractPlugin } if (!empty($details)) { + // Confirm? + if ($params->fromPost('confirm') === "0") { + if ($params->fromPost('cancelAll') !== null) { + return $this->getController()->confirm( + 'hold_cancel_all', + $this->getController()->url()->fromRoute('myresearch-holds'), + $this->getController()->url()->fromRoute('myresearch-holds'), + 'confirm_hold_cancel_all_text', + array( + 'cancelAll' => 1, + 'cancelAllIDS' => $params->fromPost('cancelAllIDS') + ) + ); + } else { + return $this->getController()->confirm( + 'hold_cancel_selected', + $this->getController()->url()->fromRoute('myresearch-holds'), + $this->getController()->url()->fromRoute('myresearch-holds'), + 'confirm_hold_cancel_selected_text', + array( + 'cancelSelected' => 1, + 'cancelSelectedIDS' => $params->fromPost('cancelSelectedIDS') + ) + ); + } + } + foreach ($details as $info) { // If the user input contains a value not found in the session // whitelist, something has been tampered with -- abort the process. diff --git a/themes/blueprint/js/common.js b/themes/blueprint/js/common.js index 4deba021d6aa8dde47bb7afaca9bc3defe2823b9..4d3d5112c8c265a75bb1126a017f47f3a27b59ed 100644 --- a/themes/blueprint/js/common.js +++ b/themes/blueprint/js/common.js @@ -373,6 +373,28 @@ $(document).ready(function(){ $(this.className.replace('facet_', '#narrowGroupHidden_')).toggleClass('open'); }); + // Support holds cancel list buttons: + function cancelHolds(type) { + var ids = $('[name="'+type+'IDS[]"]'); + var cancelIDS = []; + for(var i=0;i<ids.length;i++) { + cancelIDS.push(ids[i].value); + } + var postParams = { + 'confirm': 0, + type: 1, + type+'IDS': cancelIDS + }; + getLightbox('MyResearch', 'Holds', '', '', '', 'MyResearch', 'Holds', '', postParams); + return false; + } + $('.holdCancel').unbind('click').click(function(){ + return cancelHolds('cancelSelected'); + }); + $('.holdCancelAll').unbind('click').click(function(){ + return cancelHolds('cancelAll'); + }); + //ContextHelp contextHelp.init(); contextHelp.contextHelpSys.load(); diff --git a/themes/blueprint/templates/myresearch/holds.phtml b/themes/blueprint/templates/myresearch/holds.phtml index 549e939ac257a8f3f093c09288214c8f48c9317e..f7884fd1a1691b9a410e9574d457b768c4d5a0f1 100644 --- a/themes/blueprint/templates/myresearch/holds.phtml +++ b/themes/blueprint/templates/myresearch/holds.phtml @@ -15,10 +15,11 @@ <? if (!empty($this->recordList)): ?> <? if ($this->cancelForm): ?> <form name="cancelForm" action="" method="post" id="cancelHold"> + <input type="hidden" id="cancelConfirm" name="confirm" value="0"/> <div class="toolbar"> <ul> - <li><input type="submit" class="button holdCancel" name="cancelSelected" value="<?=$this->translate("hold_cancel_selected") ?>" onClick="return confirm('<?=$this->translate("confirm_hold_cancel_selected_text") ?>')" /></li> - <li><input type="submit" class="button holdCancelAll" name="cancelAll" value="<?=$this->translate("hold_cancel_all") ?>" onClick="return confirm('<?=$this->translate("confirm_hold_cancel_all_text") ?>')" /></li> + <li><input type="submit" class="button holdCancel" name="cancelSelected" value="<?=$this->translate("hold_cancel_selected") ?>"/></li> + <li><input type="submit" class="button holdCancelAll" name="cancelAll" value="<?=$this->translate("hold_cancel_all") ?>"/></li> </ul> </div> <div class="clearer"></div> diff --git a/themes/bootstrap/templates/confirm/confirm.phtml b/themes/bootstrap/templates/confirm/confirm.phtml index b7937fb608c37dd92bdc9baad7687d75b00686ed..7a75187831b97304a637a71c5c6010d871fed244 100644 --- a/themes/bootstrap/templates/confirm/confirm.phtml +++ b/themes/bootstrap/templates/confirm/confirm.phtml @@ -1,3 +1,4 @@ +<? $this->headTitle($this->title) ?> <div class="alignleft"> <h3><?=$this->transEsc($this->title) ?></h3> @@ -18,7 +19,7 @@ <? endif;?> <input class="btn btn-primary" type="submit" name="confirm" value="<?=$this->transEsc('confirm_dialog_yes') ?>" /> </form> - <form class="pad"action="<?=$this->escapeHtml($this->cancel) ?>" method="post"> + <form class="pad" action="<?=$this->escapeHtml($this->cancel) ?>" method="post"> <input class="btn" type="submit" name="cancel" value="<?=$this->transEsc('confirm_dialog_no') ?>" /> </form> <div class="clearer"></div> diff --git a/themes/bootstrap/templates/myresearch/holds.phtml b/themes/bootstrap/templates/myresearch/holds.phtml index 68c23400a79d6e8269aad64d1f6eb3102ebdf8c1..71bbd71dd83382848dc3d457faeb26a849c7c429 100644 --- a/themes/bootstrap/templates/myresearch/holds.phtml +++ b/themes/bootstrap/templates/myresearch/holds.phtml @@ -14,10 +14,25 @@ <? if (!empty($this->recordList)): ?> <? if ($this->cancelForm): ?> - <form name="cancelForm" action="" method="post" id="cancelHold"> - <input type="submit" class="btn" name="cancelSelected" value="<?=$this->translate("hold_cancel_selected") ?>" onClick="return confirm('<?=$this->translate("confirm_hold_cancel_selected_text") ?>')" /> - <input type="submit" class="btn" name="cancelAll" value="<?=$this->translate("hold_cancel_all") ?>" onClick="return confirm('<?=$this->translate("confirm_hold_cancel_all_text") ?>')" /> - <hr/> + <form name="cancelForm" class="inline" action="" method="post" id="cancelHold"> + <input type="hidden" id="submitType" name="cancelSelected" value="1"/> + <input type="hidden" id="cancelConfirm" name="confirm" value="0"/> + <div class="btn-group"> + <input id="cancelSelected" name="cancelSelected" type="submit" value="<?=$this->translate("hold_cancel_selected") ?>" class="btn dropdown-toggle" data-toggle="dropdown"/> + <ul class="dropdown-menu"> + <li class="disabled"><a><?=$this->translate("confirm_hold_cancel_selected_text") ?></a></li> + <li><a href="#" onClick="$('#cancelConfirm').val(1);$('#submitType').attr('name','cancelSelected');$(this).parents('form').submit()"><?=$this->translate("Yes") ?></a></li> + <li><a href="#">Cancel</a></li> + </ul> + </div> + <div class="btn-group"> + <input id="cancelAll" name="cancelAll" type="submit" value="<?=$this->translate("hold_cancel_all") ?>" class="btn dropdown-toggle" data-toggle="dropdown"/> + <ul class="dropdown-menu"> + <li class="disabled"><a><?=$this->translate("confirm_hold_cancel_all_text") ?></a></li> + <li><a href="#" onClick="$('#cancelConfirm').val(1);$('#submitType').attr('name','cancelAll');$(this).parents('form').submit()"><?=$this->translate("Yes") ?></a></li> + <li><a href="#">Cancel</a></li> + </ul> + </div> <? endif; ?> <? $iteration = 0; ?>