Skip to content
Snippets Groups Projects
Commit 28c8bc9e authored by Ere Maijala's avatar Ere Maijala Committed by Robert Lange
Browse files

Standardise use of data-clear-account-cache attribute. (#1576)

- Removes the special case for library card selection and adds support for clearing all caches with an empty attribute also with links and select fields.
parent 802dc3f4
No related merge requests found
...@@ -31,7 +31,7 @@ VuFind.register('account', function Account() { ...@@ -31,7 +31,7 @@ VuFind.register('account', function Account() {
// Clearing save forces AJAX update next page load // Clearing save forces AJAX update next page load
var clearCache = function clearCache(name) { var clearCache = function clearCache(name) {
if (typeof name === "undefined") { if (typeof name === "undefined" || name === '') {
for (var sub in _submodules) { for (var sub in _submodules) {
if (Object.prototype.hasOwnProperty.call(_submodules, sub)) { if (Object.prototype.hasOwnProperty.call(_submodules, sub)) {
clearCache(sub); clearCache(sub);
...@@ -122,11 +122,14 @@ VuFind.register('account', function Account() { ...@@ -122,11 +122,14 @@ VuFind.register('account', function Account() {
var init = function init() { var init = function init() {
// Update information when certain actions are performed // Update information when certain actions are performed
$("[data-clear-account-cache]").submit(function dataClearCache() { $("form[data-clear-account-cache]").submit(function dataClearCacheForm() {
clearCache($(this).attr("data-clear-account-cache")); clearCache($(this).attr("data-clear-account-cache"));
}); });
$("#library_card").change(function clearChangeLibraryCard() { $("a[data-clear-account-cache]").click(function dataClearCacheLink() {
clearCache(/* all */); clearCache($(this).attr("data-clear-account-cache"));
});
$("select[data-clear-account-cache]").change(function dataClearCacheSelect() {
clearCache($(this).attr("data-clear-account-cache"));
}); });
}; };
......
<?php if ($this->user): ?> <?php if ($this->user): ?>
<?php $cards = $this->user->getLibraryCards(); if ($cards->count() > 1): ?> <?php $cards = $this->user->getLibraryCards(); if ($cards->count() > 1): ?>
<form class="form-inline" action="<?=$this->url('librarycards-selectcard')?>" method="get"> <form class="form-inline" action="<?=$this->url('librarycards-selectcard')?>" method="get" data-clear-account-cache>
<label for="library_card"><?=$this->transEsc('Library Card')?></label> <label for="library_card"><?=$this->transEsc('Library Card')?></label>
<select id="library_card" name="cardID" class="jumpMenu form-control"> <select id="library_card" name="cardID" class="jumpMenu form-control">
<?php if (null === $this->user->cat_username): ?> <?php if (null === $this->user->cat_username): ?>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment