Skip to content
Snippets Groups Projects
Commit 19ed0e32 authored by Robert Lange's avatar Robert Lange Committed by Dorian Merz
Browse files

refs #17711 [master] improve usability when deleting single favorite and list items

* give user feedback when deleting single favorite by spinner
* remove list items after successful deleting, don't reload page
* show lightbox on error or success => should replace overriden functionality of setting buggy flash messages in performDeleteFavorite
parent c533b5be
No related merge requests found
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
$id = $this->driver->getUniqueId(); $id = $this->driver->getUniqueId();
$source = $this->driver->getSourceIdentifier(); $source = $this->driver->getSourceIdentifier();
if (isset($this->list) && is_object($this->list)) { if (isset($this->list) && is_object($this->list)) {
$list_id = $this->list->id; $list_id = $this->list->id;
$user_id = $this->list->user_id; $user_id = $this->list->user_id;
} else { } else {
$list_id = null; $list_id = null;
$user_id = $this->user ? $this->user->id : null; $user_id = $this->user ? $this->user->id : null;
} }
// finc: next line finc-specific; required to display public favorites lists, #12052, see also below - CK // finc: next line finc-specific; required to display public favorites lists, #12052, see also below - CK
$isEditable = $this->user && $this->user->id === $user_id; $isEditable = $this->user && $this->user->id === $user_id;
...@@ -91,15 +91,15 @@ if ($cover): ...@@ -91,15 +91,15 @@ if ($cover):
<div class="last"> <div class="last">
<?php if (!$this->driver->isCollection()) { <?php if (!$this->driver->isCollection()) {
if ($snippet = $this->driver->getHighlightedSnippet()) { if ($snippet = $this->driver->getHighlightedSnippet()) {
if (!empty($snippet['caption'])) { if (!empty($snippet['caption'])) {
echo '<strong>' . $this->transEsc($snippet['caption']) . ':</strong> '; echo '<strong>' . $this->transEsc($snippet['caption']) . ':</strong> ';
} }
if (!empty($snippet['snippet'])) { if (!empty($snippet['snippet'])) {
echo '<span class="quotestart">&#8220;</span>...' . $this->highlight($snippet['snippet']) . '...<span class="quoteend">&#8221;</span><br/>'; echo '<span class="quotestart">&#8220;</span>...' . $this->highlight($snippet['snippet']) . '...<span class="quoteend">&#8221;</span><br/>';
} }
} }
} ?> } ?>
<?php $listTags = ($this->usertags()->getMode() !== 'disabled') ? $this->driver->getTags( <?php $listTags = ($this->usertags()->getMode() !== 'disabled') ? $this->driver->getTags(
null === $list_id ? true : $list_id, // get tags for all lists if no single list is selected null === $list_id ? true : $list_id, // get tags for all lists if no single list is selected
...@@ -126,7 +126,7 @@ if ($cover): ...@@ -126,7 +126,7 @@ if ($cover):
<strong><?=$this->transEsc('Saved in')?>:</strong> <strong><?=$this->transEsc('Saved in')?>:</strong>
<?php $i = 0; <?php $i = 0;
foreach ($this->lists as $current): ?> foreach ($this->lists as $current): ?>
<a href="<?=$this->url('userList', ['id' => $current->id])?>"><?=$this->escapeHtml($current->title)?></a><?php if($i++ < count($this->lists) - 1): ?>,<?php endif; ?> <a href="<?=$this->url('userList', ['id' => $current->id])?>"><?=$this->escapeHtml($current->title)?></a><?php if ($i++ < count($this->lists) - 1): ?>,<?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
<br/> <br/>
<?php endif; ?> <?php endif; ?>
...@@ -174,8 +174,8 @@ if ($cover): ...@@ -174,8 +174,8 @@ if ($cover):
<?php endif; ?> <?php endif; ?>
<?php if (!is_array($urls)) { <?php if (!is_array($urls)) {
$urls = []; $urls = [];
} }
if (!$this->driver->isCollection()): if (!$this->driver->isCollection()):
foreach ($urls as $current): ?> foreach ($urls as $current): ?>
<a href="<?=$this->escapeHtmlAttr($this->proxyUrl($current['url']))?>" class="fulltext" target="new"><i class="fa fa-external-link" <a href="<?=$this->escapeHtmlAttr($this->proxyUrl($current['url']))?>" class="fulltext" target="new"><i class="fa fa-external-link"
...@@ -211,13 +211,40 @@ if ($cover): ...@@ -211,13 +211,40 @@ if ($cover):
$dLabel = 'delete-label-' . preg_replace('[\W]', '-', $id); $dLabel = 'delete-label-' . preg_replace('[\W]', '-', $id);
?> ?>
<div class="dropdown"> <div class="dropdown">
<i class="fa fa-fw fa-trash-o" aria-hidden="true"></i> <a class="dropdown-toggle" id="<?=$dLabel?>" role="button" data-toggle="dropdown" href="<?=$deleteUrlGet?>"> <i class="fa fa-fw fa-trash-o" aria-hidden="true"></i>
<?=$this->transEsc('Delete')?> <a class="dropdown-toggle" id="<?= $dLabel ?>"
role="button" data-toggle="dropdown"
href="<?= $deleteUrlGet ?>">
<?= $this->transEsc('Delete') ?>
</a> </a>
<ul class="dropdown-menu" role="menu" aria-labelledby="<?=$dLabel?>"> <ul class="dropdown-menu" role="menu" aria-labelledby="<?= $dLabel ?>">
<li> <li>
<a href="javascript:" onClick="$.post('<?=$deleteUrl?>', {'delete':'<?=$this->escapeJs($id)?>','source':'<?=$this->escapeJs($source)?>','confirm':true},function(){location.reload(true)})" title="<?=$this->transEsc('confirm_delete_brief')?>"><?=$this->transEsc('confirm_dialog_yes')?></a></li> <?php /* #17711 give user feedback and dont reload page after deleting */ ?>
<li><a href="javascript:document.getElementById('<?=$dLabel?>').focus();"><?=$this->transEsc('confirm_dialog_no')?></a></li> <a title="<?= $this->transEsc('confirm_delete_brief') ?>" onClick="$.post(
'<?= $deleteUrl ?>',
{
'delete':'<?= $this->escapeJs($id) ?>',
'source':'<?= $this->escapeJs($source) ?>',
'confirm':true
}, function(){
$('input[value=<?=$id?>]').parent().remove(0);
<?php /* reset needed for possible old MyResearchController::mylistAction in instances withot clearMessages */ ?>
<?php if (null === $list_id) :?>
VuFind.lightbox.alert('<?= $this->transEsc('Item removed from favorites')?>', 'success');
<?php else :?>
VuFind.lightbox.alert('<?= $this->transEsc('Item removed from list')?>', 'success');
<?php endif; ?>
}).fail(function(data) {
$('.fa-spinner.fa-spin').removeClass('fa-spinner fa-spin').addClass('fa-trash-o');
VuFind.lightbox.alert(
'<?= $this->transEsc('Delete') . ' ' . $this->transEsc('of') . ' ' . htmlspecialchars($this->record($this->driver)->getTitleHtml()) . ': ' . $this->transEsc('errorcode_error')?>',
'danger'
)
});
$(this).closest('.dropdown').find('.fa-trash-o').removeClass('fa-trash-o').addClass('fa-spinner fa-spin');">
<?= $this->transEsc('confirm_dialog_yes') ?>
</a>
</li>
</ul> </ul>
</div> </div>
......
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