Skip to content

Commit

Permalink
fixed open model variations
Browse files Browse the repository at this point in the history
  • Loading branch information
RalkeyOfficial committed Aug 8, 2024
1 parent ff49c93 commit c9e77fa
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 23 deletions.
51 changes: 29 additions & 22 deletions src/modals/publication/AddPublicationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { navigationStore, publicationStore } from '../../store/store.js'
<NcModal v-if="navigationStore.modal === 'publicationAdd'"
ref="modalRef"
label-id="addPublicationModal"
@close="navigationStore.setModal(false)">
@close="closeModal">
<div class="modal__content">
<h2>Publicatie toevoegen</h2>
<div v-if="success !== null || error">
Expand Down Expand Up @@ -194,14 +194,16 @@ export default {
})
.then((response) => {
response.json().then((data) => {
const selectedCatalogus = data.results.filter((catalogus) => catalogus.id.toString() === navigationStore.selectedCatalogus.toString())[0]
const selectedCatalogus = navigationStore.getTransferData() !== 'ignore selectedCatalogus'
? data.results.filter((catalogus) => catalogus.id.toString() === navigationStore.selectedCatalogus.toString())[0]
: null
this.catalogi = {
options: Object.entries(data.results).map((catalog) => ({
id: catalog[1].id,
label: catalog[1].title,
})),
value: navigationStore.selectedCatalogus
value: selectedCatalogus
? {
id: selectedCatalogus.id,
label: selectedCatalogus.title,
Expand Down Expand Up @@ -271,37 +273,42 @@ export default {
publicationStore.refreshPublicationList()
response.json().then((data) => {
publicationStore.setPublicationItem(data)
navigationStore.setSelectedCatalogus(data?.catalogi)
})
navigationStore.setSelected('publication')
// Wait for the user to read the feedback then close the model
const self = this
setTimeout(function() {
self.success = null
navigationStore.setModal(false)
self.publication = {
title: '',
summary: '',
description: '',
reference: '',
license: '',
featured: false,
portal: '',
category: '',
published: new Date(),
image: '',
data: {},
}
self.catalogi = {}
self.metaData = {}
self.hasUpdated = false
self.closeModal()
}, 2000)
})
.catch((err) => {
this.error = err
this.loading = false
self.hasUpdated = false
this.hasUpdated = false
})
},
closeModal() {
this.success = null
navigationStore.selectedCatalogus && navigationStore.setSelected('publication')
navigationStore.setModal(false)
this.publication = {
title: '',
summary: '',
description: '',
reference: '',
license: '',
featured: false,
portal: '',
category: '',
published: new Date(),
image: '',
data: {},
}
this.catalogi = {}
this.metaData = {}
this.hasUpdated = false
},
},
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/navigation/MainMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { navigationStore, catalogiStore, publicationStore } from '../store/store
<template>
<NcAppNavigation>
<NcAppNavigationList>
<NcAppNavigationNew text="Publicatie Aanmaken" @click="navigationStore.setModal('publicationAdd')">
<NcAppNavigationNew text="Publicatie Aanmaken" @click="navigationStore.setModal('publicationAdd'); navigationStore.setTransferData('ignore selectedCatalogus')">
<template #icon>
<Plus :size="20" />
</template>
Expand Down
10 changes: 10 additions & 0 deletions src/store/modules/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const useNavigationStore = defineStore(
modal: false,
// The currently active dialog
dialog: false,
// Any data needed in various models, dialogs, views which cannot be transferred through normal means or without writing crappy/excessive code
transferData: null,
}),
actions: {
setSelected(selected) {
Expand All @@ -30,6 +32,14 @@ export const useNavigationStore = defineStore(
this.dialog = dialog
console.log('Active dialog set to ' + dialog)
},
setTransferData(data) {
this.transferData = data
},
getTransferData() {
const tempData = this.transferData
this.transferData = null
return tempData
},
},
},
)

0 comments on commit c9e77fa

Please sign in to comment.