From a40b455c50b356ebf349943f7455ce7c0c3b5064 Mon Sep 17 00:00:00 2001 From: Remko Date: Tue, 13 Aug 2024 11:38:53 +0200 Subject: [PATCH] fixed api issues and publish --- .../attachment/CopyAttachmentDialog.vue | 11 ++-- .../attachment/DeleteAttachmentDialog.vue | 56 ++++++++--------- .../attachment/DepublishAttachmentDialog.vue | 18 +++--- .../attachment/PublishAttachmentDialog.vue | 38 +++++------ src/modals/attachment/AddAttachmentModal.vue | 63 +++++++++---------- src/modals/attachment/EditAttachmentModal.vue | 5 +- src/store/modules/publication.js | 26 -------- src/views/publications/PublicationDetail.vue | 23 ++++--- 8 files changed, 101 insertions(+), 139 deletions(-) diff --git a/src/dialogs/attachment/CopyAttachmentDialog.vue b/src/dialogs/attachment/CopyAttachmentDialog.vue index f1d4eb4f..3931f851 100644 --- a/src/dialogs/attachment/CopyAttachmentDialog.vue +++ b/src/dialogs/attachment/CopyAttachmentDialog.vue @@ -86,14 +86,11 @@ export default { .then((response) => { this.loading = false this.succes = true - // Lets refresh the attachment list - response.json().then((data) => { - publicationStore.setAttachmentItem(data) - }) - if (publicationStore.publicationItem?.id) { - publicationStore.getPublicationAttachments(publicationStore.publicationItem.id) - // @todo update the publication item + + if (publicationStore.publicationItem) { + publicationStore.getPublicationAttachments(publicationStore.publicationItem) } + // Wait for the user to read the feedback then close the model const self = this setTimeout(function() { diff --git a/src/dialogs/attachment/DeleteAttachmentDialog.vue b/src/dialogs/attachment/DeleteAttachmentDialog.vue index f85bb7cf..fe2eb88b 100644 --- a/src/dialogs/attachment/DeleteAttachmentDialog.vue +++ b/src/dialogs/attachment/DeleteAttachmentDialog.vue @@ -83,39 +83,37 @@ export default { this.loading = false this.succes = true // Lets refresh the attachment list - if (publicationStore.publicationItem?.id) { - publicationStore.getPublicationAttachments(publicationStore.publicationItem.id) - // @todo update the publication item - } - - this.filterdAttachments = publicationStore.publicationItem.attachments.filter((attachment) => { return parseInt(attachment) !== parseInt(publicationStore.attachmentItem.id) }) + if (publicationStore.publicationItem) { + publicationStore.getPublicationAttachments(publicationStore.publicationItem) + this.filterdAttachments = publicationStore.publicationItem.attachments.filter((attachment) => { return parseInt(attachment) !== parseInt(publicationStore.attachmentItem.id) }) - fetch( - `/index.php/apps/opencatalogi/api/publications/${publicationStore.publicationItem.id}`, - { - method: 'PUT', - headers: { - 'Content-Type': 'application/json', + fetch( + `/index.php/apps/opencatalogi/api/publications/${publicationStore.publicationItem.id}`, + { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + ...publicationStore.publicationItem, + attachments: [...this.filterdAttachments], + }), }, - body: JSON.stringify({ - ...publicationStore.publicationItem, - attachments: [...this.filterdAttachments], - }), - }, - ) - .then((response) => { - this.loading = false + ) + .then((response) => { + this.loading = false - // Lets refresh the publicationList - publicationStore.refreshPublicationList() - response.json().then((data) => { - publicationStore.setPublicationItem(data) + // Lets refresh the publicationList + publicationStore.refreshPublicationList() + response.json().then((data) => { + publicationStore.setPublicationItem(data) + }) }) - }) - .catch((err) => { - this.error = err - this.loading = false - }) + .catch((err) => { + this.error = err + this.loading = false + }) + } // Wait for the user to read the feedback then close the model const self = this diff --git a/src/dialogs/attachment/DepublishAttachmentDialog.vue b/src/dialogs/attachment/DepublishAttachmentDialog.vue index bf0a2ff1..71f90eb5 100644 --- a/src/dialogs/attachment/DepublishAttachmentDialog.vue +++ b/src/dialogs/attachment/DepublishAttachmentDialog.vue @@ -30,7 +30,7 @@ import { publicationStore, navigationStore } from '../../store/store.js' v-if="!succes" :disabled="loading" type="primary" - @click="CopyAttachment()"> + @click="depublishAttachment()"> Eigenschap toevoegen - + @@ -215,14 +215,14 @@ import { catalogiStore, metadataStore, navigationStore, publicationStore } from :bold="false" :active="publicationStore.attachmentId === attachment.id" :force-display-actions="true" - :details="attachment?.status"> + :details="(attachment?.published && attachment?.published <= now.toISOString()) ? 'Gepubliseerd' : 'Niet gepubliseerd'"> @@ -242,13 +242,13 @@ import { catalogiStore, metadataStore, navigationStore, publicationStore } from Download - + Publiceren - + @@ -416,6 +416,7 @@ export default { attachments: [], catalogi: [], metadata: [], + now: new Date(), prive: false, loading: false, catalogiLoading: false, @@ -478,7 +479,7 @@ export default { // this.oldZaakId = id this.fetchCatalogi(data.catalogi) this.fetchMetaData(data.metaData) - publicationStore.getPublicationAttachmentsById(data) + publicationStore.getPublicationAttachments(data) // this.loading = false }) }) @@ -523,6 +524,10 @@ export default { if (loading) { this.metaDataLoading = false } }) }, + addAttachment() { + publicationStore.setAttachmentItem([]) + navigationStore.setModal('AddAttachment') + }, deletePublication() { publicationStore.setPublicationItem(this.publication) navigationStore.setModal('deletePublication')