Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

End of sprint functionality #135

Merged
merged 19 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/dialogs/Dialogs.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<script setup>
import { navigationStore } from '../store/store.js'
</script>

<template>
<!-- Placeholder div -->
<div>
Expand All @@ -15,6 +19,7 @@
<DeletePublicationDialog />
<DeletePublicationDataDialog />
<CopyPublicationDialog />
<DeletePublicationThemeDialog v-if="navigationStore.dialog === 'deletePublicationThemeDialog'" />
<PublishPublicationDialog />
<DepublishPublicationDialog />
<DeleteCatalogDialog />
Expand Down Expand Up @@ -49,6 +54,7 @@ import DeletePublicationDialog from './publication/DeletePublicationDialog.vue'
import DepublishPublicationDialog from './publication/DepublishPublicationDialog.vue'
import PublishPublicationDialog from './publication/PublishPublicationDialog.vue'
import DeletePublicationDataDialog from './publicationData/DeletePublicationDataDialog.vue'
import DeletePublicationThemeDialog from './publicationTheme/DeletePublicationThemeDialog.vue'
import CopyThemeDialog from './theme/CopyThemeDialog.vue'
import DeleteThemeDialog from './theme/DeleteThemeDialog.vue'
import DownloadPublicationDialog from './publication/DownloadPublicationDialog.vue'
Expand All @@ -70,6 +76,7 @@ export default {
DeletePublicationDialog,
CopyPublicationDialog,
DeletePublicationDataDialog,
DeletePublicationThemeDialog,
PublishPublicationDialog,
DepublishPublicationDialog,
ArchivePublicationDialog,
Expand Down
115 changes: 115 additions & 0 deletions src/dialogs/publicationTheme/DeletePublicationThemeDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<script setup>
import { navigationStore, publicationStore, themeStore } from '../../store/store.js'
</script>

<template>
<NcDialog name="Publicatie thema verwijderen"
:can-close="false">
<div v-if="success !== null || error">
<NcNoteCard v-if="success" type="success">
<p>Publicatie thema succesvol verwijderd</p>
</NcNoteCard>
<NcNoteCard v-if="!success" type="error">
<p>Er is iets fout gegaan bij het verwijderen van Publicatie thema</p>
</NcNoteCard>
<NcNoteCard v-if="error" type="error">
<p>{{ error }}</p>
</NcNoteCard>
</div>
<p v-if="success === null">
Wil je <b>{{ themeStore.themeItem?.title }}</b> verwijderen van de publicatie <b>{{ publicationStore.publicationItem.title }}</b>?
</p>
<template #actions>
<NcButton :disabled="loading" icon="" @click="navigationStore.setDialog(false)">
<template #icon>
<Cancel :size="20" />
</template>
{{ success !== null ? 'Sluiten' : 'Annuleer' }}
</NcButton>
<NcButton
v-if="success === null"
:disabled="loading"
icon="Delete"
type="error"
@click="DeleteTheme()">
<template #icon>
<NcLoadingIcon v-if="loading" :size="20" />
<Delete v-if="!loading" :size="20" />
</template>
Verwijderen
</NcButton>
</template>
</NcDialog>
</template>

<script>
import { NcButton, NcDialog, NcNoteCard, NcLoadingIcon } from '@nextcloud/vue'

import Cancel from 'vue-material-design-icons/Cancel.vue'
import Delete from 'vue-material-design-icons/Delete.vue'
import { Publication } from '../../entities/index.js'

export default {
name: 'DeletePublicationThemeDialog',
components: {
NcDialog,
NcButton,
NcNoteCard,
NcLoadingIcon,
// Icons
Cancel,
Delete,
},
data() {
return {
loading: false,
success: null,
error: false,
}
},
methods: {
DeleteTheme() {
this.loading = true

const publicationClone = { ...publicationStore.publicationItem }
publicationClone.themes = publicationClone.themes.filter(themeId => themeId !== themeStore.themeItem.id)

const publicationItem = new Publication({
...publicationClone,
})

publicationStore.editPublication(publicationItem)
.then(({ response }) => {
this.loading = false
this.success = response.ok

// Wait for the user to read the feedback then close the model
setTimeout(() => {
navigationStore.setDialog(false)
}, 2000)
})
.catch((err) => {
this.error = err
this.loading = false
})
},
},
}
</script>

<style>
.modal__content {
margin: var(--OC-margin-50);
text-align: center;
}

.zaakDetailsContainer {
margin-block-start: var(--OC-margin-20);
margin-inline-start: var(--OC-margin-20);
margin-inline-end: var(--OC-margin-20);
}

.success {
color: green;
}
</style>
12 changes: 6 additions & 6 deletions src/entities/publication/publication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,29 @@ export class Publication implements TPublication {
this.themes = data.themes || []
this.data = (!Array.isArray(data.data) && data.data) || {}

this.anonymization = data.anonymization || {
this.anonymization = (!Array.isArray(data.anonymization) && data.anonymization) || {
anonymized: false,
results: '',
}

this.language = data.language || {
this.language = (!Array.isArray(data.language) && data.language) || {
code: '',
level: '',
}

this.published = data.published || ''
this.modified = data.modified || ''
this.license = data.license || ''
this.archive = data.archive || {
this.archive = (!Array.isArray(data.archive) && data.archive) || {
date: '',
}

this.geo = data.geo || {
this.geo = (!Array.isArray(data.geo) && data.geo) || {
type: 'Point',
coordinates: [0, 0],
}

this.catalog = data.catalog || {}
this.catalog = (!Array.isArray(data.catalog) && data.catalog) || {}
this.publicationType = (data.publicationType ?? data.publicationType) || ''
}

Expand All @@ -116,7 +116,7 @@ export class Publication implements TPublication {
status: z.enum(['Concept', 'Published', 'Withdrawn', 'Archived', 'Revised', 'Rejected']),
attachments: z.union([z.string(), z.number()]).array(),
attachmentCount: z.number(),
themes: z.string().array(),
themes: z.array(z.union([z.string(), z.number()])),
data: z.record(z.string(), z.any()),
anonymization: z.object({
anonymized: z.boolean(),
Expand Down
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
Loading