diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php index db4e035c64915122ed2887dc6287acde13bb3747..c295995c77c53c9bdfa707b173712d0077afe63d 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php @@ -383,6 +383,8 @@ class FavoritesTest extends \VuFindTest\Unit\MinkTestCase $this->snooze(); $this->fillInLoginForm($page, 'username2', 'test'); $this->submitLoginForm($page); + // Count lists + $listCount = count($page->findAll('css', '.savedLists a')); // Save Record $this->findCss($page, '.save-record')->click(); $this->snooze(); @@ -390,6 +392,11 @@ class FavoritesTest extends \VuFindTest\Unit\MinkTestCase $this->findCss($page, '.modal-body .btn.btn-primary')->click(); $this->snooze(); $this->findCss($page, '.alert.alert-success'); + // Test save status update on modal close + $this->findCss($page, '.modal-body .btn.btn-default')->click(); + $this->snooze(); + $savedLists = $page->findAll('css', '.savedLists a'); + $this->assertEquals($listCount + 1, count($savedLists)); } /** diff --git a/themes/bootstrap3/js/check_save_statuses.js b/themes/bootstrap3/js/check_save_statuses.js index 411b88d8cec72b6ff4d56e2dad5b2fbd1498839f..cf6177ab34f06f6e00603884f638f8aba3a2f14b 100644 --- a/themes/bootstrap3/js/check_save_statuses.js +++ b/themes/bootstrap3/js/check_save_statuses.js @@ -1,4 +1,5 @@ /*global htmlEncode, userIsLoggedIn, VuFind */ +/*exported checkSaveStatuses, checkSaveStatusesCallback */ function checkSaveStatuses(_container) { if (!userIsLoggedIn) { @@ -55,6 +56,11 @@ function checkSaveStatuses(_container) { } } +function checkSaveStatusesCallback() { + // Make sure no event parameter etc. is passed to checkSaveStatuses() + checkSaveStatuses(); +} + $(document).ready(function checkSaveStatusFail() { checkSaveStatuses(); }); diff --git a/themes/bootstrap3/templates/record/save.phtml b/themes/bootstrap3/templates/record/save.phtml index 28ece530e457489749d744e050b66e8e063fd7a3..819859261c2f91e375a91a43312e4d352c5c7f18 100644 --- a/themes/bootstrap3/templates/record/save.phtml +++ b/themes/bootstrap3/templates/record/save.phtml @@ -7,7 +7,7 @@ . '<li>' . $this->recordLink()->getBreadcrumb($this->driver) . '</li> ' . '<li class="active">' . $this->transEsc('Save') . '</li>'; ?> -<form id="edit-save-form" class="form-horizontal" method="post" action="<?=$this->recordLink()->getActionUrl($this->driver, 'Save')?>" name="saveRecord" data-lightbox-onclose="checkSaveStatuses"> +<form id="edit-save-form" class="form-horizontal" method="post" action="<?=$this->recordLink()->getActionUrl($this->driver, 'Save')?>" name="saveRecord" data-lightbox-onclose="checkSaveStatusesCallback"> <h2><?=$this->translate("add_to_favorites_html", ['%%title%%' => $this->escapeHtml($this->driver->getBreadcrumb())]) ?></h2> <input type="hidden" name="submit" value="1" /> <input type="hidden" name="id" value="<?=$this->escapeHtmlAttr($this->driver->getUniqueId()) ?>" />