Skip to content

Commit

Permalink
Fix for all put Publications, include catalogi & metadata id in body
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoLouwerse committed Aug 12, 2024
1 parent ce4add4 commit 56d0818
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 7 deletions.
6 changes: 6 additions & 0 deletions lib/Controller/PublicationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ public function update(string|int $id, ObjectService $objectService, ElasticSear

}

$this->createPublicationFile(objectService: $objectService, publication: $returnData);

// get post from requests
return new JSONResponse($returnData);
}
Expand Down Expand Up @@ -439,11 +441,15 @@ public function createPublicationFile(ObjectService $objectService, ?array $publ

// Save the uploaded file
$filePath = "Publicaties/$publicationFolder/$filename";
$this->fileService->deleteFile(filePath: $filePath);
$created = $this->fileService->uploadFile(
content: file_get_contents(filename: $filename),
filePath: $filePath
);

// Todo:
// return $this->fileService->createShareLink(path: $filePath);

if ($created === false) {
// return new JSONResponse(data: ['error' => "Failed to upload file. This file: $filePath might already exist"], statusCode: 400);
return false;
Expand Down
9 changes: 8 additions & 1 deletion lib/Templates/publication.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
<p>Referentie: {{ publication.reference }}</p>
<p>Samenvatting: {{ publication.summary }}</p>
<p>Beschrijving: {{ publication.description }}</p>
<table>

<style>
table.tb { border-collapse: collapse; width:300px; }
.tb th, .tb td { padding: 5px; border: solid 1px #777; }
.tb th { background-color: lightblue;}
</style>
<h2>Publicatie Data</h2>
<table class="tb" title="Publicatie Data">
<tr>
<th>Key</th>
<th>Value</th>
Expand Down
3 changes: 3 additions & 0 deletions src/dialogs/publication/ArchivePublicationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export default {
ArchivePublication() {
this.loading = true
publicationStore.publicationItem.status = 'archived'
publicationStore.publicationItem.catalogi = publicationStore.publicationItem?.catalogi?.id?.toString()
publicationStore.publicationItem.metaData = publicationStore.publicationItem?.metaData?.id?.toString()

fetch(
`/index.php/apps/opencatalogi/api/publications/${publicationStore.publicationItem.id}`,
{
Expand Down
3 changes: 3 additions & 0 deletions src/dialogs/publication/DepublishPublicationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export default {
this.loading = true
publicationStore.publicationItem.status = 'retracted'
publicationStore.publicationItem.published = ''
publicationStore.publicationItem.catalogi = publicationStore.publicationItem?.catalogi?.id?.toString()
publicationStore.publicationItem.metaData = publicationStore.publicationItem?.metaData?.id?.toString()

fetch(
`/index.php/apps/opencatalogi/api/publications/${publicationStore.publicationItem.id}`,
{
Expand Down
3 changes: 3 additions & 0 deletions src/dialogs/publication/PublishPublicationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export default {
PublishPublication() {
this.loading = true
publicationStore.publicationItem.status = 'published'
publicationStore.publicationItem.catalogi = publicationStore.publicationItem?.catalogi?.id?.toString()
publicationStore.publicationItem.metaData = publicationStore.publicationItem?.metaData?.id?.toString()

fetch(
`/index.php/apps/opencatalogi/api/publications/${publicationStore.publicationItem.id}`,
{
Expand Down
3 changes: 3 additions & 0 deletions src/dialogs/publicationData/DeletePublicationDataDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export default {
methods: {
DeleteProperty() {
const publication = publicationStore.publicationItem
publication.catalogi = publication.catalogi?.id?.toString()
publication.metaData = publication.metaData?.id?.toString()
delete publication?.data[publicationStore.publicationDataKey]
this.loading = true
Expand Down
2 changes: 2 additions & 0 deletions src/modals/publication/EditPublicationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ export default {
body: JSON.stringify({
...this.publicationItem,
id: this.publicationItem.id.toString(),
catalogi: this.publicationItem.catalogi?.id?.toString(),
metaData: this.publicationItem.metaData?.id?.toString()
}),
},
)
Expand Down
3 changes: 3 additions & 0 deletions src/modals/publicationData/AddPublicationDataModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export default {
const bodyData = publicationStore.publicationItem
bodyData.data[this.key] = this.value
delete bodyData.publicationDate
bodyData.catalogi = bodyData?.catalogi?.id?.toString()
bodyData.metaData = bodyData?.metaData?.id?.toString()
fetch(
`/index.php/apps/opencatalogi/api/publications/${publicationStore.publicationItem.id}`,
{
Expand Down
6 changes: 4 additions & 2 deletions src/modals/publicationData/EditPublicationDataModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ export default {
response.json().then((data) => {
this.publication = data
// this.publication.data = JSON.stringify(data.data)
this.catalogi.value = [data.catalogi]
this.metaData.value = [data.metaData]
this.catalogi.value = [data.catalogi?.id]
this.metaData.value = [data.metaData?.id]
})
this.publicationLoading = false
})
Expand Down Expand Up @@ -183,6 +183,8 @@ export default {
body: JSON.stringify({
...publicationStore.publicationItem,
id: publicationStore.publicationItem.id.toString(),
catalogi: publicationStore.publicationItem?.catalogi?.id?.toString(),
metaData: publicationStore.publicationItem?.metaData?.id?.toString(),
}),
},
)
Expand Down
8 changes: 4 additions & 4 deletions src/views/publications/PublicationDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ export default {
handler(newPublicationItem, oldPublicationItem) {
if (!this.upToDate || JSON.stringify(newPublicationItem) !== JSON.stringify(oldPublicationItem)) {
this.publication = publicationStore.publicationItem
this.fetchCatalogi(publicationStore.publicationItem.catalogi?.id)
this.fetchMetaData(publicationStore.publicationItem.metaData?.id)
this.fetchCatalogi(this.publication.catalogi?.id)
this.fetchMetaData(this.publication.metaData?.id)
publicationStore.publicationItem && this.fetchData(publicationStore.publicationItem.id)
}
},
Expand All @@ -460,8 +460,8 @@ export default {
this.publication = publicationStore.publicationItem
this.fetchCatalogi(publicationStore.publicationItem.catalogi?.id, true)
this.fetchMetaData(publicationStore.publicationItem.metaData?.id, true)
this.fetchCatalogi(this.publication.catalogi?.id, true)
this.fetchMetaData(this.publication.metaData?.id, true)
publicationStore.publicationItem && this.fetchData(publicationStore.publicationItem.id)
},
Expand Down

0 comments on commit 56d0818

Please sign in to comment.