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

Development to main #158

Merged
merged 2 commits into from
Dec 11, 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
2 changes: 2 additions & 0 deletions src/entities/listing/listing.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const mockListingsData = (): TListing[] => [
tooi: 'string',
rsin: 'string',
pki: 'string',
image: 'string',
},
},
{
Expand All @@ -52,6 +53,7 @@ export const mockListingsData = (): TListing[] => [
tooi: 'string',
rsin: 'string',
pki: 'string',
image: 'string',
},
},
{
Expand Down
3 changes: 3 additions & 0 deletions src/entities/organization/organization.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const mockOrganizationData = (): TOrganization[] => [
tooi: '7843432',
rsin: '827342654',
pki: '543573424',
image: '',
},
{
id: '2',
Expand All @@ -21,6 +22,7 @@ export const mockOrganizationData = (): TOrganization[] => [
tooi: '',
rsin: '',
pki: '',
image: '',
},
{ // invalid data
id: '3',
Expand All @@ -31,6 +33,7 @@ export const mockOrganizationData = (): TOrganization[] => [
tooi: '5435',
rsin: '54',
pki: '6565',
image: '',
},
]

Expand Down
3 changes: 3 additions & 0 deletions src/entities/organization/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class Organization implements TOrganization {
public tooi: string
public rsin: string
public pki: string
public image: string

constructor(data: TOrganization) {
this.hydrate(data)
Expand All @@ -26,6 +27,7 @@ export class Organization implements TOrganization {
this.tooi = data?.tooi || ''
this.rsin = data?.rsin || ''
this.pki = data?.pki || ''
this.image = data?.image || ''
}

/* istanbul ignore next */
Expand All @@ -42,6 +44,7 @@ export class Organization implements TOrganization {
tooi: z.string().regex(/^\d{1,}$/, 'is niet een geldige TOOI nummer').or(z.literal('')),
rsin: z.string().regex(/^\d{9}$/, 'is niet een geldige RSIN nummer').or(z.literal('')),
pki: z.string().regex(/^\d{1,}$/, 'is niet een geldige PKI nummer').or(z.literal('')),
image: z.string(),
})

const result = schema.safeParse({
Expand Down
1 change: 1 addition & 0 deletions src/entities/organization/organization.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export type TOrganization = {
tooi: string
rsin: string
pki: string
image: string
}
2 changes: 2 additions & 0 deletions src/entities/publication/publication.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const mockPublicationsData = (): TPublication[] => [
publicationType: '4',
published: '2024-09-04T12:36:39Z',
modified: '2024-09-04T12:36:39Z',
organization: '1',
featured: true,
data: {
key: 'anyvalue',
Expand Down Expand Up @@ -60,6 +61,7 @@ export const mockPublicationsData = (): TPublication[] => [
published: '2024-09-04T12:36:39Z',
modified: '2024-09-04T12:36:39Z',
featured: true,
organization: '1',
data: {
type: '',
},
Expand Down
3 changes: 3 additions & 0 deletions src/entities/publication/publication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class Publication implements TPublication {
public attachments: number[]
public attachmentCount: number
public themes: string[]
public organization: string
public data: Record<string, unknown>

public anonymization: {
Expand Down Expand Up @@ -60,6 +61,7 @@ export class Publication implements TPublication {
this.description = data.description || ''
this.reference = data.reference || ''
this.image = data.image || ''
this.organization = data.organization || ''
this.category = data.category || ''
this.portal = data.portal || ''
this.featured = (typeof data.featured === 'boolean' && data.featured)
Expand Down Expand Up @@ -113,6 +115,7 @@ export class Publication implements TPublication {
portal: z.string().url('is niet een url').or(z.literal('')),
featured: z.boolean(),
schema: z.string(),
organization: z.string(),
status: z.enum(['Concept', 'Published', 'Withdrawn', 'Archived', 'Revised', 'Rejected']),
attachments: z.union([z.string(), z.number()]).array(),
attachmentCount: z.number(),
Expand Down
1 change: 1 addition & 0 deletions src/entities/publication/publication.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type TPublication = {
status: 'Concept' | 'Published' | 'Withdrawn' | 'Archived' | 'Revised' | 'Rejected'
attachments: number[]
attachmentCount: number
organization: string
themes: string[]
data: Record<string, unknown>
anonymization: {
Expand Down
7 changes: 7 additions & 0 deletions src/modals/organization/AddOrganizationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ import { navigationStore, organizationStore } from '../../store/store.js'
:value.sync="organization.pki"
:error="!!inputValidation.fieldErrors?.['pki']"
:helper-text="inputValidation.fieldErrors?.['pki']?.[0]" />
<NcTextField
:disabled="loading"
label="Afbeelding"
:value.sync="organization.image"
:error="!!inputValidation.fieldErrors?.['image']"
:helper-text="inputValidation.fieldErrors?.['image']?.[0]" />
</div>
</div>
<NcButton v-if="success === null"
Expand Down Expand Up @@ -115,6 +121,7 @@ export default {
tooi: '',
rsin: '',
pki: '',
image: '',
},

errorCode: '',
Expand Down
7 changes: 7 additions & 0 deletions src/modals/organization/EditOrganizationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ import { navigationStore, organizationStore } from '../../store/store.js'
:value.sync="organization.pki"
:error="!!inputValidation.fieldErrors?.['pki']"
:helper-text="inputValidation.fieldErrors?.['pki']?.[0]" />
<NcTextField
:disabled="loading"
label="Afbeelding"
:value.sync="organization.image"
:error="!!inputValidation.fieldErrors?.['image']"
:helper-text="inputValidation.fieldErrors?.['image']?.[0]" />
</div>
</div>
<NcButton v-if="success === null"
Expand Down Expand Up @@ -115,6 +121,7 @@ export default {
tooi: '',
rsin: '',
pki: '',
image: '',
},
loading: false,
success: null,
Expand Down
34 changes: 33 additions & 1 deletion src/modals/publication/AddPublicationModal.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { publicationTypeStore, navigationStore, publicationStore, catalogiStore } from '../../store/store.js'
import { publicationTypeStore, navigationStore, publicationStore, catalogiStore, organizationStore } from '../../store/store.js'
</script>

<template>
Expand Down Expand Up @@ -164,6 +164,11 @@ import { publicationTypeStore, navigationStore, publicationStore, catalogiStore
:value.sync="publication.license"
:error="!!inputValidation.fieldErrors?.['license']"
:helper-text="inputValidation.fieldErrors?.['license']?.[0]" />
<NcSelect v-bind="organizations"
v-model="organizations.value"
input-label="Organisatie"
:loading="organizationsLoading"
:disabled="loading" />
</div>
</div>
</div>
Expand Down Expand Up @@ -222,6 +227,10 @@ export default {
image: '',
data: {},
},
organizations: {
value: [],
options: [],
},
catalogiList: [], // this is the entire dataset of catalogi
catalogi: {},
publicationTypeList: [], // this is the entire dataset of publication types
Expand Down Expand Up @@ -270,6 +279,7 @@ export default {
catalog: this.catalogi.value?.id,
publicationType: this.publicationType?.value?.id,
published: this.publication.published !== '' ? new Date(this.publication.published).toISOString() : new Date().toISOString(),
organization: this.organizations.value?.id,
})

const result = testClass.validate()
Expand Down Expand Up @@ -300,6 +310,7 @@ export default {

this.fetchCatalogi()
this.fetchPublicationType()
this.fetchOrganizations()
this.hasUpdated = true
}
},
Expand Down Expand Up @@ -346,6 +357,26 @@ export default {
this.publicationTypeLoading = false
})
},
fetchOrganizations() {
this.organizationsLoading = true

organizationStore.getAllOrganization()
.then(({ response, data }) => {

this.organizations = {
options: data.map((organization) => ({
id: organization.id,
label: organization.title,
})),
}

this.organizationsLoading = false
})
.catch((err) => {
console.error(err)
this.organizationsLoading = false
})
},
isJsonString(str) {
try {
JSON.parse(str)
Expand All @@ -363,6 +394,7 @@ export default {
catalog: this.catalogi?.value?.id,
publicationType: this.publicationType?.value?.id,
published: this.publication.published !== '' ? new Date(this.publication.published).toISOString() : new Date().toISOString(),
organization: this.organizations.value?.id,
})

publicationStore.addPublication(publicationItem)
Expand Down
45 changes: 44 additions & 1 deletion src/modals/publication/EditPublicationModal.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import { navigationStore, publicationStore } from '../../store/store.js'
import { navigationStore, publicationStore, organizationStore } from '../../store/store.js'
</script>
<template>
<NcDialog v-if="navigationStore.modal === 'editPublication'"
Expand Down Expand Up @@ -70,6 +70,11 @@ import { navigationStore, publicationStore } from '../../store/store.js'
:value.sync="publicationItem.license"
:error="!!inputValidation.fieldErrors?.['license']"
:helper-text="inputValidation.fieldErrors?.['license']?.[0]" />
<NcSelect v-bind="organizations"
v-model="organizations.value"
input-label="Organisatie"
:loading="organizationsLoading"
:disabled="loading" />
</div>
<template #actions>
<NcButton
Expand Down Expand Up @@ -111,6 +116,7 @@ import {
NcNoteCard,
NcTextArea,
NcTextField,
NcSelect,
} from '@nextcloud/vue'
import ContentSaveOutline from 'vue-material-design-icons/ContentSaveOutline.vue'
import Cancel from 'vue-material-design-icons/Cancel.vue'
Expand All @@ -128,6 +134,7 @@ export default {
NcButton,
NcLoadingIcon,
NcNoteCard,
NcSelect,
// Icons
ContentSaveOutline,
Cancel,
Expand Down Expand Up @@ -158,6 +165,10 @@ export default {
value: [],
options: [],
},
organizations: {
value: [],
options: [],
},
loading: false,
success: null,
error: false,
Expand All @@ -177,6 +188,8 @@ export default {
},
publicationType: this.publicationItem.publicationType.id ?? this.publicationItem.publicationType,
published: this.publicationItem.published !== '' ? new Date(this.publicationItem.published).toISOString() : new Date().toISOString(),
organization: this.organizations.value?.id,

})

const result = testClass.validate()
Expand All @@ -195,11 +208,13 @@ export default {
updated() {
if (navigationStore.modal === 'editPublication' && this.hasUpdated) {
if (this.publicationItem.id === publicationStore.publicationItem.id) return
this.fetchOrganizations()
this.hasUpdated = false
}
if (navigationStore.modal === 'editPublication' && !this.hasUpdated) {
publicationStore.publicationItem && (this.publicationItem = publicationStore.publicationItem)
this.fetchData(publicationStore.publicationItem.id)
this.fetchOrganizations()
this.hasUpdated = true
}
},
Expand All @@ -220,6 +235,33 @@ export default {
this.loading = false
})
},
fetchOrganizations() {
this.organizationsLoading = true

organizationStore.getAllOrganization()
.then(({ response, data }) => {
const selectedOrganization = data.filter((org) => org?.id.toString() === publicationStore.publicationItem?.organization.toString())[0] || null

this.organizations = {
options: data.map((organization) => ({
id: organization.id,
label: organization.title,
})),
value: selectedOrganization
? {
id: selectedOrganization?.id,
label: selectedOrganization?.title,
}
: null,
}

this.organizationsLoading = false
})
.catch((err) => {
console.error(err)
this.organizationsLoading = false
})
},
updatePublication() {
this.loading = true

Expand All @@ -232,6 +274,7 @@ export default {
},
publicationType: this.publicationItem.publicationType.id ?? this.publicationItem.publicationType,
published: this.publicationItem.published !== '' ? new Date(this.publicationItem.published).toISOString() : new Date().toISOString(),
organization: this.organizations.value?.id,
})

publicationStore.editPublication(publicationItem)
Expand Down
4 changes: 4 additions & 0 deletions src/views/organizations/OrganizationDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ import { navigationStore, organizationStore } from '../../store/store.js'
<b>Beschrijving:</b>
<span>{{ organization.description }}</span>
</div>
<div>
<b>Afbeelding:</b>
<span>{{ organization.image }}</span>
</div>
</div>
</div>
</div>
Expand Down
Loading
Loading