Skip to content

Commit

Permalink
[0.10] Fixes references empty heading (#471)
Browse files Browse the repository at this point in the history
* fix empty headings in references tab

* Fixed not references text not showing

* simplify final reference check

---------

Signed-off-by: Vinzenz Rosenkranz <vinzenz.rosenkranz@uni-tuebingen.de>
Co-authored-by: Severino <severin.opel@hotmail.com>
  • Loading branch information
v1r0x and Severino authored Mar 27, 2024
1 parent 0a3e55b commit 2b14d94
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 54 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ All notable changes to this project will be documented in this file.
- Do not send notifications on moving an entity
- Deleting all notifications
- Button style in notifcation panel
- Remove headings without content from _References_ tab in Main View

### Changed
- _Entity tree_ sorting is now accessible through ...-menu
Expand Down
120 changes: 66 additions & 54 deletions resources/js/components/MainView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
v-dcan="'entity_read'"
:class="`h-100 d-flex flex-column col-md-${state.columnPref.left}`"
>
<entity-tree
class="col px-0 h-100"
/>
<entity-tree class="col px-0 h-100" />
</div>
<div
v-if="state.columnPref.center > 0"
Expand Down Expand Up @@ -38,8 +36,8 @@
>
<router-link
class="nav-link"
:class="{active: state.tab == plugin.key}"
:to="{ query: { tab: plugin.key }}"
:class="{ active: state.tab == plugin.key }"
:to="{ query: { tab: plugin.key } }"
append
>
<i
Expand All @@ -52,7 +50,7 @@
<a
href="#"
class="nav-link"
:class="{active: state.tab == 'references', disabled: !state.entity.id}"
:class="{ active: state.tab == 'references', disabled: !state.entity.id }"
@click.prevent="setTab('references')"
>
<i class="fas fa-fw fa-bookmark" /> {{ t('main.entity.references.title') }}
Expand All @@ -61,9 +59,7 @@
</ul>
<div class="mt-2 col px-0 overflow-hidden">
<keep-alive>
<component
:is="state.tabComponent"
/>
<component :is="state.tabComponent" />
</keep-alive>
<div
v-show="isTab('references') && !!state.entity.id"
Expand All @@ -75,55 +71,63 @@
>
{{ t('main.entity.references.empty') }}
</p>
<div
<template
v-for="(referenceGroup, key) in state.entity.references"
v-else
:key="key"
class="reference-group"
>
<h5 class="mb-1 fw-medium">
<a
href="#"
class="text-decoration-none"
@click.prevent="showMetadataForReferenceGroup(referenceGroup)"
>
{{ translateConcept(key) }}
</a>
</h5>
<div class="list-group ps-2 w-90">
<a
v-for="(reference, i) in referenceGroup"
:key="i"
class="list-group-item list-group-item-action d-flex flex-row"
>
<div class="flex-grow-1">
<blockquote class="blockquote fs-09">
<p class="text-muted">
{{ reference.description }}
</p>
</blockquote>
<figcaption class="blockquote-footer fw-medium mb-0 d-flex gap-1">
<span>
{{ reference.bibliography.author }} in <cite :title="reference.bibliography.title">
{{ reference.bibliography.title }} ,{{ reference.bibliography.year }}
</cite>
<div
v-if="referenceGroup.length > 0"
class="reference-group"
>
<h5 class="mb-2 fw-medium">
<a
href="#"
class="text-decoration-none"
@click.prevent="showMetadataForReferenceGroup(referenceGroup)"
>
{{ translateConcept(key) }}
</a>
</h5>
<div class="list-group w-90">
<div
v-for="(reference, i) in referenceGroup"
:key="i"
class="list-group-item pt-0"
>
<header class="text-end">
<span class="text-muted fw-light small">
{{ date(reference.updated_at) }}
</span>
<a
href="#"
@click.prevent="openLiteratureInfo(reference)"
>
<i class="fas fa-fw fa-info-circle" />
</a>
</figcaption>
</div>
<div>
<span class="text-muted fw-light small">
{{ date(reference.updated_at) }}
</span>
</header>
<div>
<blockquote class="blockquote fs-09 mb-4">
<p class="text-muted">
{{ reference.description }}
</p>
</blockquote>
<figcaption class="blockquote-footer fw-medium mb-0 d-flex gap-1">
<span>
{{ reference.bibliography.author }} in <cite
:title="reference.bibliography.title"
>
{{ reference.bibliography.title }} ,{{ reference.bibliography.year
}}
</cite>
<a
href="#"
class="ms-1"
@click.prevent="openLiteratureInfo(reference)"
>
<i class="fas fa-fw fa-info-circle" />
</a>
</span>
</figcaption>
</div>
</div>
</a>
</div>
</div>
</div>
</template>
</div>
</div>
</div>
Expand All @@ -136,7 +140,7 @@
onMounted,
reactive,
} from 'vue';
import {
onBeforeRouteUpdate,
onBeforeRouteLeave,
Expand Down Expand Up @@ -226,7 +230,15 @@
}),
concepts: computed(_ => store.getters.concepts),
entity: computed(_ => store.getters.entity),
hasReferences: computed(_ => !!state.entity.references && Object.keys(state.entity.references).length > 0),
hasReferences: computed(_ => {
const isNotSet = !state.entity.references;
if(isNotSet) return false;
const isEmpty = !Object.keys(state.entity.references).length > 0;
if(isEmpty) return false;
return Object.values(state.entity.references).some(v => v.length > 0);
}),
entityTypes: computed(_ => store.getters.entityTypes),
columnPref: computed(_ => store.getters.preferenceByKey('prefs.columns')),
isDetailLoaded: computed(_ => currentRoute.name == 'entitydetail'),
Expand Down Expand Up @@ -321,5 +333,5 @@
// }
// }
// }
}
};
</script>

0 comments on commit 2b14d94

Please sign in to comment.