Skip to content

Commit

Permalink
Updated api call
Browse files Browse the repository at this point in the history
  • Loading branch information
remko48 committed Aug 12, 2024
1 parent 156e756 commit a574f93
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/Db/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public function jsonSerialize(): array
'hash' => $this->hash,
'anonymization' => $this->anonymization,
'language' => $this->language,
'modified' => $this->modified->format('c'),
'published' => $this->published->format('c'),
'modified' => $this->modified?->format('c'),
'published' => $this->published?->format('c'),
'license' => $this->license,
];

Expand Down
32 changes: 28 additions & 4 deletions src/store/modules/publication.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,35 @@ export const usePublicationStore = defineStore(
(response) => {
response.json().then(
(data) => {
this.publicationAttachments = Object.values(data.results.map(
this.publicationAttachments = data.results.map(
(attachmentItem) => new Attachment(attachmentItem),
)).filter((attachment) => {
return publication.attachments?.includes(parseInt(attachment.id))
})
)
return data
},
)
},
)
.catch(
(err) => {
console.error(err)
return err
},
)
},
getPublicationAttachmentsById(publication) { // @todo this might belong in a service?
fetch(
`/index.php/apps/opencatalogi/api/publications/${publication.id}/attachments`,
{
method: 'GET',
},
)
.then(
(response) => {
response.json().then(
(data) => {
this.publicationAttachments = data.results.map(
(attachmentItem) => new Attachment(attachmentItem),
)
return data
},
)
Expand Down
3 changes: 2 additions & 1 deletion src/views/publications/PublicationDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ export default {
data() {
return {
publication: [],
attachments: [],
catalogi: [],
metadata: [],
prive: false,
Expand Down Expand Up @@ -477,7 +478,7 @@ export default {
// this.oldZaakId = id
this.fetchCatalogi(data.catalogi)
this.fetchMetaData(data.metaData)
publicationStore.getPublicationAttachments(data)
publicationStore.getPublicationAttachmentsById(data)
// this.loading = false
})
})
Expand Down

0 comments on commit a574f93

Please sign in to comment.