Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.10] Fixes references empty heading #471

Merged
merged 4 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading