Skip to content

Commit

Permalink
Merge branch 'development' into feature/DIMOC-178/publication-download
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoLouwerse committed Aug 14, 2024
2 parents 170ddd5 + 2278a80 commit 419a572
Show file tree
Hide file tree
Showing 36 changed files with 1,118 additions and 489 deletions.
31 changes: 31 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,34 @@
color: var(--color-error);
}


/* File drag and drop */

.filesListDragDropNotice{
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: 113px;
margin: 0;
user-select: none;
color: var(--color-text-maxcontrast);
background-color: var(--color-main-background);
border-color: #000;
}

.filesListDragDropNoticeWrapper{
display: flex;
align-items: center;
justify-content: center;
height: 15vh;
max-height: 70%;
padding: 0 5vw;
border: 2px var(--color-border-dark) dashed;
border-radius: var(--border-radius-large);
}

.filesListDragDropNoticeTitle{
margin-left: 16px;
color: inherit;
}
2 changes: 1 addition & 1 deletion docs/developers/feature_flow.puml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ alt Feature-aanvraag goedgekeurd
end note

Ontwikkelingspartij -> Ontwikkelingspartij: Forkt de codebase
Ontwikkelingspartij -> Ontwikkelingspartij: Bouwt de feature
Ontwikkelingspartij -> Ontwikkelingspartij: Bouwt de feature op de fork
Ontwikkelingspartij -> Beheerderspartij: Maakt PR met verwijzing naar het issue-nummer
note right of Beheerderspartij
Code wordt bij voorkeur terug geleverd aan de centrale codebase
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/ElasticSearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function updateObject(string $id, array $object, array $config): array
}
}

public function parseFilter(string $name, array $filter): array
public function parseFilter(string $name, array|string $filter): array
{

if(is_array($filter) === false) {
Expand Down
95 changes: 95 additions & 0 deletions src/composables/UseFileSelection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { useDropZone, useFileDialog } from '@vueuse/core'
import { ref, computed } from 'vue'
import { publicationStore } from './../store/store.js'

/**
* File selection composable
* @param options
*
* Special thanks to Github user adamreisnz for creating most of this file
* https://github.com/adamreisnz
* https://github.com/vueuse/vueuse/issues/4085
*
*/
export function useFileSelection(options) {

// Extract options
const {
dropzone,
allowMultiple,
allowedFileTypes,
onFileDrop,
} = options

// Data types computed ref
const dataTypes = computed(() => {
if (allowedFileTypes?.value) {
if (!Array.isArray(allowedFileTypes.value)) {
return [allowedFileTypes.value]

Check failure on line 28 in src/composables/UseFileSelection.js

View workflow job for this annotation

GitHub Actions / build

Multi-line function call not indented correctly; expected 8 spaces but found 12
}
return allowedFileTypes.value
}
return null
})

Check failure on line 34 in src/composables/UseFileSelection.js

View workflow job for this annotation

GitHub Actions / build

Multi-line function call not indented correctly; expected 8 spaces but found 12
// Accept string computed ref
const accept = computed(() => {
if (Array.isArray(dataTypes.value)) {
return dataTypes.value.join(',')
}
return '*'
})

Check failure on line 41 in src/composables/UseFileSelection.js

View workflow job for this annotation

GitHub Actions / build

Multi-line function call not indented correctly; expected 8 spaces but found 12

// Handling of files drop
const onDrop = files => {

Check failure on line 44 in src/composables/UseFileSelection.js

View workflow job for this annotation

GitHub Actions / build

Multi-line function call not indented correctly; expected 8 spaces but found 12
if (!files || files.length === 0) {
return
}
if (files instanceof FileList) {
files = Array.from(files)
}
if (files.length > 1 && !allowMultiple.value) {
files = [files[0]]
}
filesList.value = files
onFileDrop && onFileDrop()
}

const reset = () => {
filesList.value = null
}

// const onLeave = () => {
// let timer
// document.addEventListener('mousemove', () => {
// clearTimeout(timer)
// timer = setTimeout(isOverDropZone.value = false, 300)
// })
// }

const setFiles = (files) => {
filesList.value = files
publicationStore.setAttachmentFile(null)
}

// Setup dropzone and file dialog composables
const { isOverDropZone } = useDropZone(dropzone, { dataTypes, onDrop })
const { onChange, open } = useFileDialog({
accept: accept.value,
multiple: allowMultiple?.value,
})

const filesList = ref(null)

// Use onChange handler
onChange(fileList => onDrop(fileList))

// Expose interface
return {
isOverDropZone,
openFileUpload: open,
files: filesList,
reset,
setFiles,
}
}
11 changes: 4 additions & 7 deletions src/dialogs/attachment/CopyAttachmentDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,11 @@ export default {
.then((response) => {
this.loading = false
this.succes = true
// Lets refresh the attachment list
response.json().then((data) => {
publicationStore.setAttachmentItem(data)
})
if (publicationStore.publicationItem?.id) {
publicationStore.getPublicationAttachments(publicationStore.publicationItem.id)
// @todo update the publication item
if (publicationStore.publicationItem) {
publicationStore.getPublicationAttachments(publicationStore.publicationItem)
}
// Wait for the user to read the feedback then close the model
const self = this
setTimeout(function() {
Expand Down
36 changes: 32 additions & 4 deletions src/dialogs/attachment/DeleteAttachmentDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default {
},
data() {
return {
filterdAttachments: [],
loading: false,
succes: false,
error: false,
Expand All @@ -83,10 +83,38 @@ export default {
this.loading = false
this.succes = true
// Lets refresh the attachment list
if (publicationStore.publicationItem?.id) {
publicationStore.getPublicationAttachments(publicationStore.publicationItem.id)
// @todo update the publication item
if (publicationStore.publicationItem) {
publicationStore.getPublicationAttachments(publicationStore.publicationItem)
this.filterdAttachments = publicationStore.publicationItem.attachments.filter((attachment) => { return parseInt(attachment) !== parseInt(publicationStore.attachmentItem.id) })
fetch(
`/index.php/apps/opencatalogi/api/publications/${publicationStore.publicationItem.id}`,
{
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
...publicationStore.publicationItem,
attachments: [...this.filterdAttachments],
}),
},
)
.then((response) => {
this.loading = false
// Lets refresh the publicationList
publicationStore.refreshPublicationList()
response.json().then((data) => {
publicationStore.setPublicationItem(data)
})
})
.catch((err) => {
this.error = err
this.loading = false
})
}
// Wait for the user to read the feedback then close the model
const self = this
setTimeout(function() {
Expand Down
18 changes: 7 additions & 11 deletions src/dialogs/attachment/DepublishAttachmentDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { publicationStore, navigationStore } from '../../store/store.js'
v-if="!succes"
:disabled="loading"
type="primary"
@click="CopyAttachment()">
@click="depublishAttachment()">
<template #icon>
<NcLoadingIcon v-if="loading" :size="20" />
<PublishOff v-if="!loading" :size="20" />
Expand Down Expand Up @@ -67,10 +67,9 @@ export default {
}
},
methods: {
CopyAttachment() {
depublishAttachment() {
this.loading = true
publicationStore.attachmentItem.status = 'retracted'
publicationStore.attachmentItem.published = ''
publicationStore.attachmentItem.published = null
fetch(
`/index.php/apps/opencatalogi/api/attachments/${publicationStore.attachmentItem.id}`,
{
Expand All @@ -84,14 +83,11 @@ export default {
.then((response) => {
this.loading = false
this.succes = true
// Lets refresh the attachment list
response.json().then((data) => {
publicationStore.setAttachmentItem(data)
})
if (publicationStore.publicationItem?.id) {
publicationStore.getPublicationAttachments(publicationStore.publicationItem.id)
// @todo update the publication item
if (publicationStore.publicationItem) {
publicationStore.getPublicationAttachments(publicationStore.publicationItem)
}
// Wait for the user to read the feedback then close the model
const self = this
setTimeout(function() {
Expand Down
38 changes: 16 additions & 22 deletions src/dialogs/attachment/PublishAttachmentDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export default {
methods: {
PublishAttachment() {
this.loading = true
publicationStore.attachmentItem.status = 'published'
fetch(
`/index.php/apps/opencatalogi/api/attachments/${publicationStore.attachmentItem.id}`,
{
Expand All @@ -79,27 +78,22 @@ export default {
},
body: JSON.stringify(publicationStore.attachmentItem),
},
)
.then((response) => {
this.loading = false
this.succes = true
// Lets refresh the attachment list
response.json().then((data) => {
publicationStore.setAttachmentItem(data)
})
if (publicationStore.publicationItem?.id) {
publicationStore.getPublicationAttachments(publicationStore.publicationItem.id)
// @todo update the publication item
}
publicationStore.getConceptAttachments()
// Wait for the user to read the feedback then close the model
const self = this
setTimeout(function() {
self.succes = false
publicationStore.setAttachmentItem(false)
navigationStore.setDialog(false)
}, 2000)
})
).then((response) => {
this.loading = false
this.succes = true
if (publicationStore.publicationItem) {
publicationStore.getPublicationAttachments(publicationStore.publicationItem)
}
// Wait for the user to read the feedback then close the model
const self = this
setTimeout(function() {
self.succes = false
publicationStore.setAttachmentItem(false)
navigationStore.setDialog(false)
}, 2000)
})
.catch((err) => {
this.error = err
this.loading = false
Expand Down
19 changes: 19 additions & 0 deletions src/entities/metadata/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ export class Metadata implements TMetadata {
valuation: 'n',
class: 1,
}

// convert null's to the respective default value from predefined list of props
Object.keys(this.properties).forEach(obj => {
const defaultPropertiesProps = {
minimum: 0,
maximum: 0,
multipleOf: 0,
minItems: 0,
maxItems: 0,
minLength: 0,
maxLength: 0,
} as Pick<TMetadata['properties'][0], 'minimum' | 'maximum' | 'multipleOf' | 'minItems' | 'maxItems' | 'minLength' | 'maxLength'>

Object.keys(defaultPropertiesProps).forEach((key: keyof typeof defaultPropertiesProps) => {
if (this.properties[obj][key] === null) {
this.properties[obj][key] = defaultPropertiesProps[key]
}
})
})
}

/* istanbul ignore next */
Expand Down
6 changes: 3 additions & 3 deletions src/entities/publication/publication.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ export const mockPublicationsData = (): TPublication[] => [
key: 'anyvalue',
streetNumber: 1,
object: {
blabla: 'bla'
},
array: ['appel', 'peer', 0, [], {}]
blabla: 'bla',
},
array: ['appel', 'peer', 0, [], {}],
},
attachments: [],
attachmentCount: 1,
Expand Down
6 changes: 5 additions & 1 deletion src/modals/Modals.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<script setup>
import { publicationStore } from './../store/store.js'
</script>

<template>
<!-- Placeholder Div -->
<div>
<AddAttachmentModal />
<AddAttachmentModal :drop-files="publicationStore.attachmentFile" />
<EditAttachmentModal />
<AddPublicationModal />
<EditPublicationModal />
Expand Down
Loading

0 comments on commit 419a572

Please sign in to comment.