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()">
@@ -67,10 +67,9 @@ export default {
}
},
methods: {
- CopyAttachment() {
+ depublishAttachment() {
this.loading = true
- publicationStore.attachmentItem.status = 'retracted'
- publicationStore.attachmentItem.published = ''
+ publicationStore.attachmentItem.published = null
fetch(
`/index.php/apps/opencatalogi/api/attachments/${publicationStore.attachmentItem.id}`,
{
@@ -84,14 +83,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/PublishAttachmentDialog.vue b/src/dialogs/attachment/PublishAttachmentDialog.vue
index 7b5a1a31..92c0fa25 100644
--- a/src/dialogs/attachment/PublishAttachmentDialog.vue
+++ b/src/dialogs/attachment/PublishAttachmentDialog.vue
@@ -69,7 +69,6 @@ export default {
methods: {
PublishAttachment() {
this.loading = true
- publicationStore.attachmentItem.status = 'published'
fetch(
`/index.php/apps/opencatalogi/api/attachments/${publicationStore.attachmentItem.id}`,
{
@@ -79,27 +78,22 @@ export default {
},
body: JSON.stringify(publicationStore.attachmentItem),
},
- )
- .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
- }
- publicationStore.getConceptAttachments()
- // Wait for the user to read the feedback then close the model
- const self = this
- setTimeout(function() {
- self.succes = false
- publicationStore.setAttachmentItem(false)
- navigationStore.setDialog(false)
- }, 2000)
- })
+ ).then((response) => {
+ this.loading = false
+ this.succes = true
+
+ if (publicationStore.publicationItem) {
+ publicationStore.getPublicationAttachments(publicationStore.publicationItem)
+ }
+
+ // Wait for the user to read the feedback then close the model
+ const self = this
+ setTimeout(function() {
+ self.succes = false
+ publicationStore.setAttachmentItem(false)
+ navigationStore.setDialog(false)
+ }, 2000)
+ })
.catch((err) => {
this.error = err
this.loading = false
diff --git a/src/modals/attachment/AddAttachmentModal.vue b/src/modals/attachment/AddAttachmentModal.vue
index 118f0591..0f4fc0fc 100644
--- a/src/modals/attachment/AddAttachmentModal.vue
+++ b/src/modals/attachment/AddAttachmentModal.vue
@@ -87,7 +87,7 @@ import Plus from 'vue-material-design-icons/Plus.vue'
import axios from 'axios'
-const { files, open: openFileUpload, reset } = useFileDialog()
+const { files, open: openFileUpload, reset } = useFileDialog({ multiple: false })
export default {
name: 'AddAttachmentModal',
@@ -126,6 +126,7 @@ export default {
axios.post('/index.php/apps/opencatalogi/api/attachments', {
...(publicationStore.attachmentItem),
+ published: null,
_file: files.value ? files.value[0] : '',
}, {
headers: {
@@ -140,40 +141,38 @@ export default {
this.success = true
reset()
// Lets refresh the attachment list
- if (publicationStore.publicationItem?.id) {
- publicationStore.getPublicationAttachments(publicationStore.publicationItem.id)
- // @todo update the publication item
- }
-
- fetch(
- `/index.php/apps/opencatalogi/api/publications/${publicationStore.publicationItem.id}`,
- {
- method: 'PUT',
- headers: {
- 'Content-Type': 'application/json',
+ if (publicationStore.publicationItem) {
+ publicationStore.getPublicationAttachments(publicationStore.publicationItem)
+
+ fetch(
+ `/index.php/apps/opencatalogi/api/publications/${publicationStore.publicationItem.id}`,
+ {
+ method: 'PUT',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ ...publicationStore.publicationItem,
+ attachments: [...publicationStore.publicationItem.attachments, response.data.id],
+ }),
},
- body: JSON.stringify({
- ...publicationStore.publicationItem,
- attachments: [...publicationStore.publicationItem.attachments, response.data.id],
- }),
- },
- )
- .then((response) => {
- this.loading = false
-
- // Lets refresh the publicationList
- publicationStore.refreshPublicationList()
- response.json().then((data) => {
- publicationStore.setPublicationItem(data)
- })
+ )
+ .then((response) => {
+ this.loading = false
- })
- .catch((err) => {
- this.error = err
- this.loading = false
- })
- // store.refreshCatalogiList()
+ // Lets refresh the publicationList
+ publicationStore.refreshPublicationList()
+ response.json().then((data) => {
+ publicationStore.setPublicationItem(data)
+ })
+ })
+ .catch((err) => {
+ this.error = err
+ this.loading = false
+ })
+ // store.refreshCatalogiList()
+ }
publicationStore.setAttachmentItem(response)
// Wait for the user to read the feedback then close the model
diff --git a/src/modals/attachment/EditAttachmentModal.vue b/src/modals/attachment/EditAttachmentModal.vue
index 69f6e310..c64464f3 100644
--- a/src/modals/attachment/EditAttachmentModal.vue
+++ b/src/modals/attachment/EditAttachmentModal.vue
@@ -100,9 +100,8 @@ export default {
this.loading = false
this.success = response.ok
// Lets refresh the catalogiList
- if (publicationStore.publicationItem?.id) {
- publicationStore.getPublicationAttachments(publicationStore.publicationItem.id)
- // @todo update the publication item
+ if (publicationStore.publicationItem) {
+ publicationStore.getPublicationAttachments(publicationStore.publicationItem)
}
response.json().then((data) => {
publicationStore.setAttachmentItem(data)
diff --git a/src/store/modules/publication.js b/src/store/modules/publication.js
index 709b2734..1c577416 100644
--- a/src/store/modules/publication.js
+++ b/src/store/modules/publication.js
@@ -75,32 +75,6 @@ export const usePublicationStore = defineStore(
)
},
getPublicationAttachments(publication) { // @todo this might belong in a service?
- fetch(
- '/index.php/apps/opencatalogi/api/attachments',
- {
- method: 'GET',
- },
- )
- .then(
- (response) => {
- response.json().then(
- (data) => {
- this.publicationAttachments = data.results.map(
- (attachmentItem) => new Attachment(attachmentItem),
- )
- 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`,
{
diff --git a/src/views/publications/PublicationDetail.vue b/src/views/publications/PublicationDetail.vue
index 5d7eeed7..ab788f03 100644
--- a/src/views/publications/PublicationDetail.vue
+++ b/src/views/publications/PublicationDetail.vue
@@ -67,7 +67,7 @@ import { catalogiStore, metadataStore, navigationStore, publicationStore } from
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')