-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4eac87d
commit 87c7eed
Showing
7 changed files
with
197 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,5 @@ export type TCatalogi = { | |
rsin: string | ||
pki: string | ||
} | ||
metadata: string[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
<script setup> | ||
import { catalogiStore, navigationStore } from '../../store/store.js' | ||
</script> | ||
|
||
<template> | ||
<NcModal v-if="navigationStore.modal === 'addCatalogiMetadata'" | ||
ref="modalRef" | ||
label-id="addCatalogModal" | ||
@close="closeModal"> | ||
<div class="modal__content"> | ||
<h2>Metadata toevoegen aan Catalogus</h2> | ||
<div v-if="success !== null || error"> | ||
<NcNoteCard v-if="success" type="success"> | ||
<p>Catalogus succesvol toegevoegd</p> | ||
</NcNoteCard> | ||
<NcNoteCard v-if="!success" type="error"> | ||
<p>Er is iets fout gegaan bij het toevoegen van catalogus</p> | ||
</NcNoteCard> | ||
<NcNoteCard v-if="error" type="error"> | ||
<p>{{ error }}</p> | ||
</NcNoteCard> | ||
</div> | ||
<div v-if="success === null" class="form-group"> | ||
<NcSelect v-bind="metaData" | ||
v-model="metaData.value" | ||
input-label="MetaData" | ||
:loading="metaDataLoading" | ||
required /> | ||
</div> | ||
<NcButton v-if="success === null" | ||
:disabled="!catalogi.title || loading" | ||
type="primary" | ||
@click="addCatalogMetadata"> | ||
<template #icon> | ||
<NcLoadingIcon v-if="loading" :size="20" /> | ||
<Plus v-if="!loading" :size="20" /> | ||
</template> | ||
Toevoegen | ||
</NcButton> | ||
</div> | ||
</NcModal> | ||
</template> | ||
|
||
<script> | ||
import { NcButton, NcModal, NcLoadingIcon, NcNoteCard, NcSelect } from '@nextcloud/vue' | ||
import Plus from 'vue-material-design-icons/Plus.vue' | ||
export default { | ||
name: 'AddCatalogiMetadata', | ||
components: { | ||
NcModal, | ||
NcButton, | ||
NcLoadingIcon, | ||
NcNoteCard, | ||
NcSelect, | ||
// Icons | ||
Plus, | ||
}, | ||
data() { | ||
return { | ||
catalogiItem: { | ||
title: '', | ||
summary: '', | ||
description: '', | ||
listed: false, | ||
}, | ||
metaData: {}, | ||
metaDataLoading: false, | ||
loading: false, | ||
success: null, | ||
error: false, | ||
errorCode: '', | ||
} | ||
}, | ||
mounted() { | ||
// catalogiStore.catalogiItem can be false, so only assign catalogiStore.catalogiItem to catalogiItem if its NOT false | ||
catalogiStore.catalogiItem && (this.catalogiItem = catalogiStore.catalogiItem) | ||
}, | ||
updated() { | ||
if (navigationStore.modal === 'addCatalogiMetadata' && this.hasUpdated) { | ||
if (this.catalogiItem.id === catalogiStore.catalogiItem.id) return | ||
this.hasUpdated = false | ||
} | ||
if (navigationStore.modal === 'addCatalogiMetadata' && !this.hasUpdated) { | ||
catalogiStore.catalogiItem && (this.catalogiItem = catalogiStore.catalogiItem) | ||
this.fetchData(catalogiStore.catalogiItem.id) | ||
this.fetchMetaData(catalogiStore.catalogiItem?.metadata || []) | ||
this.hasUpdated = true | ||
} | ||
}, | ||
methods: { | ||
closeModal() { | ||
navigationStore.setModal(false) | ||
this.catalogi = { | ||
title: '', | ||
summary: '', | ||
description: '', | ||
listed: false, | ||
} | ||
}, | ||
fetchMetaData(metadataList) { | ||
this.metaDataLoading = true | ||
fetch('/index.php/apps/opencatalogi/api/metadata', { | ||
method: 'GET', | ||
}) | ||
.then((response) => { | ||
response.json().then((data) => { | ||
const filteredData = data.results.filter((meta) => !metadataList.includes(meta?.id)) | ||
this.metaData = { | ||
options: filteredData.map((metaData) => ({ | ||
id: metaData.id, | ||
label: metaData.title, | ||
})), | ||
} | ||
}) | ||
this.metaDataLoading = false | ||
}) | ||
.catch((err) => { | ||
console.error(err) | ||
this.metaDataLoading = false | ||
}) | ||
}, | ||
addCatalogMetadata() { | ||
this.loading = true | ||
this.error = false | ||
fetch( | ||
`/index.php/apps/opencatalogi/api/catalogi/${this.catalogi.id}`, | ||
{ | ||
method: 'PUT', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
...this.catalogi, | ||
metadata: this.catalogi.metadata.push(this.metaData.value.id), | ||
}), | ||
}, | ||
) | ||
.then((response) => { | ||
this.loading = false | ||
this.success = response.ok | ||
// Lets refresh the catalogiList | ||
catalogiStore.refreshCatalogiList() | ||
response.json().then((data) => { | ||
catalogiStore.setCatalogiItem(data) | ||
}) | ||
// Wait for the user to read the feedback then close the model | ||
const self = this | ||
setTimeout(function() { | ||
self.success = null | ||
self.closeModal() | ||
}, 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> |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.