From 9b224ff7cc7b07cc630f33c9b3e6a0e0d8489d77 Mon Sep 17 00:00:00 2001 From: Dorian Merz <merz@ub.uni-leipzig.de> Date: Tue, 19 May 2020 12:20:36 +0200 Subject: [PATCH] refs #17354 [fid_bbi] improved display of tags * on detail view: ** introduce (visually) independent tag section ** remove unnecessary whitespace * only show own tags in favorite list --- module/fid_bbi/src/fid_bbi/Db/Table/Tags.php | 2 +- .../Root/RecordDataFormatterFactory.php | 6 ++-- themes/fid_bbi/scss/compiled.scss | 17 +++++++++++ .../RecordDriver/DefaultRecord/core.phtml | 12 +++++--- .../DefaultRecord/data-tags.phtml | 28 +++++++++++++++++++ .../DefaultRecord/list-entry.phtml | 7 +++-- 6 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 themes/fid_bbi/templates/RecordDriver/DefaultRecord/data-tags.phtml diff --git a/module/fid_bbi/src/fid_bbi/Db/Table/Tags.php b/module/fid_bbi/src/fid_bbi/Db/Table/Tags.php index 69a0511e80f..d25c455f952 100644 --- a/module/fid_bbi/src/fid_bbi/Db/Table/Tags.php +++ b/module/fid_bbi/src/fid_bbi/Db/Table/Tags.php @@ -88,7 +88,7 @@ class Tags extends BaseTags // contrary to the VuFind core approach we want all // TAGS of RECORDS from the list // not only those tagged within the list - $select->where->equalTo('ur.user_id', $userId); + $select->where->equalTo('rt.user_id', $userId); if (null !== $source) { $select->where->equalTo('r.source', $source); diff --git a/module/fid_bbi/src/fid_bbi/View/Helper/Root/RecordDataFormatterFactory.php b/module/fid_bbi/src/fid_bbi/View/Helper/Root/RecordDataFormatterFactory.php index c690ec494a2..0f02f5e9a9e 100644 --- a/module/fid_bbi/src/fid_bbi/View/Helper/Root/RecordDataFormatterFactory.php +++ b/module/fid_bbi/src/fid_bbi/View/Helper/Root/RecordDataFormatterFactory.php @@ -131,7 +131,7 @@ class RecordDataFormatterFactory $spec->setTemplateLine( 'Related Items', 'getAllRecordLinks', 'data-allRecordLinks.phtml' ); - $spec->setTemplateLine('Tags', true, 'data-tags.phtml'); + $spec->setTemplateLine(1, true, 'data-tags.phtml'); return $spec->getArray(); } @@ -364,7 +364,7 @@ class RecordDataFormatterFactory 'useCache' => true ] ); - $spec->setTemplateLine('Tags', true, 'data-tags.phtml'); + $spec->setTemplateLine(2, true, 'data-tags.phtml'); return $spec->getArray(); } @@ -528,7 +528,7 @@ class RecordDataFormatterFactory 'getMegaCollection', 'data-escapeHtml.phtml' ); - $spec->setTemplateLine('Tags', true, 'data-tags.phtml'); + $spec->setTemplateLine(3, true, 'data-tags.phtml'); return $spec->getArray(); } diff --git a/themes/fid_bbi/scss/compiled.scss b/themes/fid_bbi/scss/compiled.scss index 1c41a41030d..3c4fea5ff36 100644 --- a/themes/fid_bbi/scss/compiled.scss +++ b/themes/fid_bbi/scss/compiled.scss @@ -653,4 +653,21 @@ table.tags { .tag-browse-button a { font-size: larger; +} + +// change hover color for tag badge +.tagList.loggedin .tag:not(.selected) .badge:hover { background-color: $brand-primary-light; } + +.tagList .tag { + margin-left: -$padding-base-vertical; + margin-right: $padding-base-vertical; + line-break: unset; +} + +tr.hline { + border-top: 1px solid $brand-primary-light; +} + +.tag-record.pull-right { + margin-left: 1rem; } \ No newline at end of file diff --git a/themes/fid_bbi/templates/RecordDriver/DefaultRecord/core.phtml b/themes/fid_bbi/templates/RecordDriver/DefaultRecord/core.phtml index 9a182819f4b..17cdc4e69a2 100644 --- a/themes/fid_bbi/templates/RecordDriver/DefaultRecord/core.phtml +++ b/themes/fid_bbi/templates/RecordDriver/DefaultRecord/core.phtml @@ -64,10 +64,14 @@ <table class="table table-striped"> <caption class="sr-only"><?=$this->transEsc('Bibliographic Details')?></caption> <?php foreach ($coreFields as $current): ?> - <tr> - <th><?=$this->transEsc($current['label'])?>:</th> - <td><?=$current['value']?></td> - </tr> + <?php if (is_numeric($current['label'])): ?> + <?=$current['value']?> + <?php else: ?> + <tr> + <th><?=$this->transEsc($current['label'])?>:</th> + <td><?=$current['value']?></td> + </tr> + <?php endif; ?> <?php endforeach; ?> </table> <?php endif; ?> diff --git a/themes/fid_bbi/templates/RecordDriver/DefaultRecord/data-tags.phtml b/themes/fid_bbi/templates/RecordDriver/DefaultRecord/data-tags.phtml new file mode 100644 index 00000000000..2aa23e425bb --- /dev/null +++ b/themes/fid_bbi/templates/RecordDriver/DefaultRecord/data-tags.phtml @@ -0,0 +1,28 @@ +<?php + /* + * this is a copy of themes/bootstrap3/templates/RecordDriver/DefaultRecord/data-tags.phtml + * BBI specific changes are: + * * all wrapped in spanned table row + * + * @author: Dorian Merz <merz@ub.uni-leipzig.de> + */ +?> +<?php + if($loggedin = $this->auth()->isLoggedIn()) { + $user_id = $loggedin->id; + $loggedin = true; + } else { + $user_id = false; + } +?> +<?php if ($this->usertags()->getMode() !== 'disabled'): ?> +<tr class="hline"><!--empty row--><td></td><td></td></tr> +<tr><th><?=$this->translate('Tags')?>:</th><td><!--empty cell--></td></tr> +<tr><td colspan="2"> + <?php $tagList = $this->driver->getTags(null, null, 'count', $user_id); ?> + <a class="tag-record btn btn-link pull-right flip" href="<?=$this->recordLink()->getActionUrl($this->driver, 'AddTag')?>" data-lightbox> + <i class="fa fa-plus" aria-hidden="true"></i> <?=$this->transEsc('Add Tag')?> + </a> + <?=$this->context($this)->renderInContext('record/taglist', ['tagList' => $tagList, 'loggedin' => $loggedin]) ?> +</td></tr> +<?php endif; ?> diff --git a/themes/fid_bbi/templates/RecordDriver/DefaultRecord/list-entry.phtml b/themes/fid_bbi/templates/RecordDriver/DefaultRecord/list-entry.phtml index efd3d618374..c0ab6936787 100644 --- a/themes/fid_bbi/templates/RecordDriver/DefaultRecord/list-entry.phtml +++ b/themes/fid_bbi/templates/RecordDriver/DefaultRecord/list-entry.phtml @@ -95,7 +95,7 @@ if ($cover): <?php /*fid_bbi #16050 and #16788*/ $listTags = ($this->usertags()->getMode() !== 'disabled') ? $this->driver->getTags( - null, $user_id, 'tag',$user_id + null, null, 'tag',$user_id ) : array(); ?> @@ -215,7 +215,10 @@ if ($cover): <?php /*fid_bbi #16050*/ if (!empty($listTags)): ?> <strong><?=$this->transEsc('Your Tags')?>:</strong> <?php foreach ($listTags as $tag): ?> - <a href="<?=$this->currentPath() . $results->getUrlQuery()->addFacet('tags', $tag->tag)?>"><?=$this->escapeHtml($tag->tag)?></a> + <?php /* filter for own tags, cf. #17354, DM */?> + <?php if ($tag['is_me'] ?? false): ?> + <a href="<?=$this->currentPath() . $results->getUrlQuery()->addFacet('tags', $tag->tag)?>"><?=$this->escapeHtml($tag->tag)?></a> + <?php endif;?> <?php endforeach; ?> <br/> <?php endif; ?> -- GitLab