Skip to content

Commit

Permalink
Merge pull request #101 from ConductionNL/feature/DIMOC-327/publicati…
Browse files Browse the repository at this point in the history
…onType-id

feature/DIMOC-327/publicationType-id
  • Loading branch information
remko48 authored Oct 15, 2024
2 parents 3514d72 + 352f7f6 commit 64fdd93
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default {
methods: {
deleteCatalogiPublicationType() {
const publicationTypeArray = catalogiStore.catalogiItem?.publicationTypes
.filter((source) => source !== (publicationTypeStore.publicationTypeItem?.source || publicationTypeStore.publicationTypeItem?.id))
.filter((id) => id !== publicationTypeStore.publicationTypeItem?.id)
const catalogiItem = new Catalogi({
...catalogiStore.catalogiItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default {
publicationTypeStore.getAllPublicationTypes()
.then(({ response, data }) => {
const filteredData = data.filter((publicationType) =>
!publicationTypeList.includes(publicationType?.source || publicationType?.id),
!publicationTypeList.includes(publicationType?.id),
)
this.publicationTypes = {
Expand All @@ -146,7 +146,7 @@ export default {
this.loading = true
this.error = false
this.catalogiItem.publicationTypes.push(this.publicationTypes.value.source !== '' ? this.publicationTypes.value.source : this.publicationTypes.value.id)
this.catalogiItem.publicationTypes.push(this.publicationTypes.value.id)
const newCatalogiItem = new Catalogi({
...this.catalogiItem,
Expand Down
10 changes: 3 additions & 7 deletions src/modals/publication/AddPublicationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export default {
// step 2: get the full publication types from the publicationTypeIds
const filteredPublicationType = this.publicationTypeList
.filter((publicationType) => {
const publicationTypeId = publicationType.source || publicationType.id
const publicationTypeId = publicationType.id
return selectedCatalogus.publicationTypes.includes(publicationTypeId.toString())
})
Expand All @@ -268,9 +268,7 @@ export default {
const testClass = new Publication({
...this.publication,
catalog: this.catalogi.value?.id,
publicationType: this.publicationType?.value?.source !== ''
? this.publicationType?.value?.source
: this.publicationType?.value?.id,
publicationType: this.publicationType?.value?.id,
published: this.publication.published !== '' ? new Date(this.publication.published).toISOString() : new Date().toISOString(),
})
Expand Down Expand Up @@ -363,9 +361,7 @@ export default {
const publicationItem = new Publication({
...this.publication,
catalog: this.catalogi?.value?.id,
publicationType: this.publicationType?.value?.source !== ''
? this.publicationType?.value?.source
: this.publicationType?.value?.id,
publicationType: this.publicationType?.value?.id,
published: this.publication.published !== '' ? new Date(this.publication.published).toISOString() : new Date().toISOString(),
})
Expand Down
3 changes: 2 additions & 1 deletion src/modals/publicationData/EditPublicationDataModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ export default {
console.log('activePublicationType', this.publicationTypeList)

// get the publication type linked to this publication
const activePublicationType = this.publicationTypeList.find((publicationType) => publicationType.source === this.publication.publicationType)
const activePublicationType = this.publicationTypeList.find((publicationType) => publicationType.id.toString() === this.publication.publicationType.toString(),
)
// get all the properties as an array of values (key is not needed as the comparison is done by title)
const publicationTypeProperties = Object.values(activePublicationType.properties)
// get the publication type properties with the same title as the publicationDataKey
Expand Down
16 changes: 8 additions & 8 deletions src/views/catalogi/CatalogiDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,26 @@ import { catalogiStore, publicationTypeStore, navigationStore, organizationStore
<BTabs content-class="mt-3" justified>
<BTab title="Publicatietypes">
<div v-if="catalogiStore.catalogiItem?.publicationTypes.length > 0 && !publicationTypeLoading">
<NcListItem v-for="(url, i) in catalogiStore.catalogiItem?.publicationTypes"
:key="url + i"
:name="filteredPublicationType(url)?.title || 'loading...'"
<NcListItem v-for="(id, i) in catalogiStore.catalogiItem?.publicationTypes"
:key="id + i"
:name="filteredPublicationType(id)?.title || 'loading...'"
:bold="false"
:force-display-actions="true">
<template #icon>
<FileTreeOutline disable-menu
:size="44" />
</template>
<template #subname>
{{ filteredPublicationType(url)?.description }}
{{ filteredPublicationType(id)?.description }}
</template>
<template #actions>
<NcActionButton @click="publicationTypeStore.setPublicationTypeItem(filteredPublicationType(url)); navigationStore.setSelected('publicationType')">
<NcActionButton @click="publicationTypeStore.setPublicationTypeItem(filteredPublicationType(id)); navigationStore.setSelected('publicationType')">
<template #icon>
<OpenInApp :size="20" />
</template>
Bekijk publicatietype
</NcActionButton>
<NcActionButton @click="publicationTypeStore.setPublicationTypeItem(filteredPublicationType(url)); navigationStore.setDialog('deleteCatalogiPublicationType')">
<NcActionButton @click="publicationTypeStore.setPublicationTypeItem(filteredPublicationType(id)); navigationStore.setDialog('deleteCatalogiPublicationType')">
<template #icon>
<Delete :size="20" />
</template>
Expand Down Expand Up @@ -237,10 +237,10 @@ export default {
if (loading) { this.organizationLoading = false }
})
},
filteredPublicationType(source) {
filteredPublicationType(id) {
if (this.publicationTypeLoading) return null
return publicationTypeStore.publicationTypeList.filter((publicationType) => {
return publicationType?.source ? publicationType?.source === source : publicationType?.id === source
return publicationType?.id === id
})[0]
},
goToOrganization() {
Expand Down
2 changes: 1 addition & 1 deletion src/views/publications/PublicationDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ import { ref } from 'vue'
{{ value }}
</template>
<template #actions>
<NcActionButton :disabled="true" @click="editPublicationDataItem(key)">
<NcActionButton @click="editPublicationDataItem(key)">
<template #icon>
<Pencil :size="20" />
</template>
Expand Down

0 comments on commit 64fdd93

Please sign in to comment.