From f6fb865cf48bca4191701f8970f26c25950e6cdc Mon Sep 17 00:00:00 2001 From: Chris Hallberg <crhallberg@gmail.com> Date: Tue, 8 Dec 2015 13:05:28 -0500 Subject: [PATCH] More complete list url in record save success messages. --- .../src/VuFind/Controller/AbstractRecord.php | 10 +++++++++- .../src/VuFind/Controller/CartController.php | 2 +- themes/bootstrap3/js/lightbox.js | 19 ++++++++++++++++--- themes/bootstrap3/js/record.js | 6 ++++-- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/module/VuFind/src/VuFind/Controller/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php index 6b9f6f49d63..920a80fcf0e 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php +++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php @@ -281,7 +281,15 @@ class AbstractRecord extends AbstractBase $driver->saveToFavorites($post, $user); // Display a success status message: - $this->flashMessenger()->addMessage('bulk_save_success', 'success'); + $list = $this->params()->fromPost('list'); + $listUrl = $this->url()->fromRoute('userList', ['id' => $list]); + $message = [ + 'html' => true, + 'msg' => $this->translate('bulk_save_success') . '. ' + . '<a href="' . $listUrl . '" class="gotolist">' + . $this->translate('go_to_list') . '</a>.' + ]; + $this->flashMessenger()->addMessage($message, 'success'); // redirect to followup url saved in saveAction if ($url = $this->getFollowupUrl()) { diff --git a/module/VuFind/src/VuFind/Controller/CartController.php b/module/VuFind/src/VuFind/Controller/CartController.php index 555440a412e..20edff9892a 100644 --- a/module/VuFind/src/VuFind/Controller/CartController.php +++ b/module/VuFind/src/VuFind/Controller/CartController.php @@ -390,7 +390,7 @@ class CartController extends AbstractBase $message = [ 'html' => true, 'msg' => $this->translate('bulk_save_success') . '. ' - . '<a href="' . $listUrl . '">' + . '<a href="' . $listUrl . '" class="gotolist">' . $this->translate('go_to_list') . '</a>.' ]; $this->flashMessenger()->addMessage($message, 'success'); diff --git a/themes/bootstrap3/js/lightbox.js b/themes/bootstrap3/js/lightbox.js index 3085d266afd..dc31bcdc167 100644 --- a/themes/bootstrap3/js/lightbox.js +++ b/themes/bootstrap3/js/lightbox.js @@ -405,6 +405,19 @@ var Lightbox = { } }; +function getListUrlFromHTML(html) { + var fakePage = $('<div>'+html+'</div>') + var listUrl = fakePage.find('a.gotolist').attr('href'); + if (typeof listUrl === 'undefined') { + var listID = fakePage.find('[name="listID"]'); + listUrl = VuFind.getPath() + '/MyResearch/MyList/'+listID.val(); + } + var message = VuFind.translate('bulk_save_success'); + if (listUrl) { + message += '. <a href="'+listUrl+'" class="gotolist">' + VuFind.translate('go_to_list') + '</a>.'; + } + return message; +} /** * This is where you add click events to open the lightbox. * We do it here so that non-JS users still have a good time. @@ -442,10 +455,10 @@ $(document).ready(function() { location.reload(); }); Lightbox.addFormCallback('bulkSave', function(html) { - var listID = $('<div>'+html+'</div>').find('[name="listID"]'); - var listUrl = VuFind.getPath() + '/MyResearch/MyList/'+listID.val(); Lightbox.addCloseAction(refreshPageForLogin); - Lightbox.success(VuFind.translate('bulk_save_success') + '. <a href="'+listUrl+'">' + VuFind.translate('go_to_list') + '</a>.'); + // go to list link + var msg = getListUrlFromHTML(html); + Lightbox.success(msg); }); Lightbox.addFormCallback('bulkRecord', function(html) { Lightbox.close(); diff --git a/themes/bootstrap3/js/record.js b/themes/bootstrap3/js/record.js index 540c983fe7a..22591bca9d5 100644 --- a/themes/bootstrap3/js/record.js +++ b/themes/bootstrap3/js/record.js @@ -319,10 +319,12 @@ function recordDocReady() { Lightbox.addFormCallback('placeStorageRetrievalRequest', function() { document.location.href = VuFind.getPath() + '/MyResearch/StorageRetrievalRequests'; }); - Lightbox.addFormCallback('saveRecord', function() { + Lightbox.addFormCallback('saveRecord', function(html) { checkSaveStatuses(); refreshTagList(); - Lightbox.confirm(VuFind.translate('bulk_save_success')); + // go to list link + var msg = getListUrlFromHTML(html); + Lightbox.success(msg); }); Lightbox.addFormCallback('smsRecord', function() { Lightbox.confirm(VuFind.translate('sms_success')); -- GitLab