Skip to content

Commit

Permalink
Merge pull request #132 from ConductionNL/feature/DIMOC-346/widget-lo…
Browse files Browse the repository at this point in the history
…ading-fix

widget loading fix
  • Loading branch information
Sudo-Thijn authored Nov 6, 2024
2 parents b294cf2 + 02bbbf2 commit 0d52bef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
28 changes: 12 additions & 16 deletions src/store/modules/publication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,22 +395,18 @@ export const usePublicationStore = defineStore('publication', {
return err
})
},
getConceptAttachments() { // @todo this might belong in a service?
fetch('/index.php/apps/opencatalogi/api/attachments?status=Concept',
{
method: 'GET',
},
)
.then((response) => {
response.json().then((data) => {
this.conceptAttachments = data.results.map((attachmentItem: TAttachment) => new Attachment(attachmentItem))
return data
})
})
.catch((err) => {
console.error(err)
return err
})
async getConceptAttachments() { // @todo this might belong in a service?
const response = await fetch('/index.php/apps/opencatalogi/api/attachments?status=Concept', {
method: 'GET',
})

const data = (await response.json()).results

const entities = data.map((attachmentItem: TAttachment) => new Attachment(attachmentItem))

this.conceptAttachments = entities

return { response, data, entities }
},
setPublicationDataKey(publicationDataKey: string) {
this.publicationDataKey = publicationDataKey
Expand Down
20 changes: 4 additions & 16 deletions src/views/widgets/UnpublishedAttachmentsWidget.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<script setup>
import { navigationStore, publicationStore } from '../../store/store.js'
import { publicationStore } from '../../store/store.js'
</script>

<template>
<NcDashboardWidget :items="items"
:loading="loading"
:item-menu="itemMenu"
@show="onShow">
:item-menu="itemMenu">
<template #empty-content>
<NcEmptyContent :title="t('opencatalogi', 'Geen concept bijlagen gevonden')">
<template #icon>
Expand Down Expand Up @@ -44,15 +43,9 @@ export default {
data() {
return {
loading: false,
itemMenu: {
show: {
text: 'Publicatie bekijken',
icon: 'icon-open-in-app',
},
},
itemMenu: {},
}
},
computed: {
items() {
return publicationStore.conceptAttachments.map((attachment) => ({
Expand All @@ -66,16 +59,11 @@ export default {
mounted() {
this.fetchData()
},
methods: {
onShow(item) {
navigationStore.setSelected('publication'); navigationStore.setSelectedCatalogus(item.id)
window.open('/index.php/apps/opencatalogi', '_self')
},
fetchData() {
this.loading = true
publicationStore.getConceptAttachments()
.then(({ response, data }) => {
.then(() => {
this.loading = false
})
},
Expand Down

0 comments on commit 0d52bef

Please sign in to comment.