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

finished upload button #198

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
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
46 changes: 40 additions & 6 deletions src/modals/object/UploadObject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import { objectStore, navigationStore, schemaStore, registerStore } from '../../
</NcNoteCard>

<template #actions>
<NcButton v-if="registers?.value?.id && !schemas?.value?.id"
<NcButton v-if="registers?.value?.id && !schemas?.value?.id && !disableChangeSelectors"
:disabled="loading"
@click="registers.value = null">
<template #icon>
<ArrowLeft :size="20" />
</template>
Back to Register
</NcButton>
<NcButton v-if="registers.value?.id && schemas.value?.id"
<NcButton v-if="registers.value?.id && schemas.value?.id && !disableChangeSelectors"
:disabled="loading"
@click="schemas.value = null">
<template #icon>
Expand Down Expand Up @@ -50,13 +50,13 @@ import { objectStore, navigationStore, schemaStore, registerStore } from '../../
</template>

<div v-if="!success" class="formContainer">
<div v-if="registers?.value?.id && success === null">
<div v-if="registers?.value?.id && success === null && !disableChangeSelectors">
<b>Register:</b> {{ registers.value.label }}
<NcButton @click="registers.value = null">
Edit Register
</NcButton>
</div>
<div v-if="schemas.value?.id && success === null">
<div v-if="schemas.value?.id && success === null && !disableChangeSelectors">
<b>Schema:</b> {{ schemas.value.label }}
<NcButton @click="schemas.value = null">
Edit Schema
Expand Down Expand Up @@ -139,6 +139,34 @@ export default {
Cancel,
Upload,
},
props: {
/**
* When registerId is set, the modal will open with the register already selected
*/
registerId: {
type: String,
required: false,
default: null,
},
/**
* When schemaId is set, the modal will open with the schema already selected
*/
schemaId: {
type: String,
required: false,
default: null,
},
/**
* When disableChangeSelectors is set to true, You will not be able to change the selection of Register and Schema once selected.
*
* Pair this with the registerId and schemaId props to open the modal with the selectors already selected.
*/
disableChangeSelectors: {
type: Boolean,
required: false,
default: false,
},
},
data() {
return {
object: '{}',
Expand Down Expand Up @@ -184,14 +212,16 @@ export default {

schemaStore.refreshSchemaList()
.then(() => {
const selectedSchema = schemaStore.schemaList.find((schema) => schema.id === this.schemaId)

this.schemas = {
multiple: false,
closeOnSelect: true,
options: schemaStore.schemaList.map((schema) => ({
id: schema.id,
label: schema.title,
})),
value: null,
value: selectedSchema,
}
})
.finally(() => {
Expand All @@ -203,14 +233,16 @@ export default {

registerStore.refreshRegisterList()
.then(() => {
const selectedRegister = registerStore.registerList.find((register) => register.id === this.registerId)

this.registers = {
multiple: false,
closeOnSelect: true,
options: registerStore.registerList.map((register) => ({
id: register.id,
label: register.title,
})),
value: null,
value: selectedRegister,
}
})
.finally(() => {
Expand All @@ -219,6 +251,7 @@ export default {
},
closeModal() {
navigationStore.setModal(false)
this.$emit('on-close')
this.success = null
this.loading = false
this.error = false
Expand All @@ -243,6 +276,7 @@ export default {
.then(({ response }) => {
this.success = response.ok
this.error = false
this.$emit('on-success')
response.ok && setTimeout(this.closeModal, 2000)
}).catch((error) => {
this.success = false
Expand Down
96 changes: 57 additions & 39 deletions src/sidebars/search/SearchSideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,60 @@ import { searchStore, registerStore, schemaStore } from '../../store/store.js'
</script>

<template>
<NcAppSidebar
name="Zoek opdracht"
subtitle="baldie"
subname="Binnen het federatieve netwerk">
<NcAppSidebarTab id="search-tab" name="Zoeken" :order="1">
<template #icon>
<Magnify :size="20" />
</template>
<NcSelect v-bind="registerOptions"
v-model="selectedRegister"
input-label="Registratie"
:loading="registerLoading" />
<NcSelect v-bind="schemaOptions"
v-model="selectedSchema"
input-label="Schema"
:loading="schemaLoading"
:disabled="!selectedRegister?.id" />
</NcAppSidebarTab>
<div>
<NcAppSidebar
name="Zoek opdracht"
subtitle="baldie"
subname="Binnen het federatieve netwerk">
<NcAppSidebarTab id="search-tab" name="Zoeken" :order="1">
<template #icon>
<Magnify :size="20" />
</template>
<NcSelect v-bind="registerOptions"
v-model="selectedRegister"
input-label="Registratie"
:loading="registerLoading" />
<NcSelect v-bind="schemaOptions"
v-model="selectedSchema"
input-label="Schema"
:loading="schemaLoading"
:disabled="!selectedRegister?.id" />
</NcAppSidebarTab>

<NcAppSidebarTab id="upload-tab" name="Upload" :order="2">
<template #icon>
<Upload :size="20" />
</template>
<NcButton type="primary">
Upload
</NcButton>
</NcAppSidebarTab>
<NcAppSidebarTab id="upload-tab" name="Upload" :order="2">
<template #icon>
<Upload :size="20" />
</template>
<NcButton :disabled="!selectedRegister?.id && !selectedSchema?.id" type="primary" @click="uploadObjectModal = true">
Upload
</NcButton>
</NcAppSidebarTab>

<NcAppSidebarTab id="download-tab" name="Download" :order="3">
<template #icon>
<Download :size="20" />
</template>
<NcButton type="primary">
Download
</NcButton>
</NcAppSidebarTab>
</NcAppSidebar>
<NcAppSidebarTab id="download-tab" name="Download" :order="3">
<template #icon>
<Download :size="20" />
</template>
<NcButton :disabled="true" type="primary">
Download
</NcButton>
</NcAppSidebarTab>
</NcAppSidebar>

<UploadObject v-if="uploadObjectModal"
:register-id="selectedRegister?.id"
:schema-id="selectedSchema?.id"
:disable-change-selectors="true"
@on-close="uploadObjectModal = false"
@on-success="searchObjects" />
</div>
</template>
<script>

import { NcAppSidebar, NcAppSidebarTab, NcSelect, NcButton } from '@nextcloud/vue'
import Magnify from 'vue-material-design-icons/Magnify.vue'
import Upload from 'vue-material-design-icons/Upload.vue'
import Download from 'vue-material-design-icons/Download.vue'
import UploadObject from '../../modals/object/UploadObject.vue'

export default {
name: 'SearchSideBar',
Expand All @@ -62,6 +72,7 @@ export default {
selectedRegister: null,
schemaLoading: false,
selectedSchema: null,
uploadObjectModal: false,
}
},
computed: {
Expand Down Expand Up @@ -97,10 +108,7 @@ export default {
// when selectedSchema changes, search for objects with the selected register and schema as filters
selectedSchema(newValue) {
if (newValue?.id) {
searchStore.searchObjects({
register: this.selectedRegister?.id,
schema: this.selectedSchema?.id,
})
this.searchObjects()
}
},
},
Expand All @@ -110,5 +118,15 @@ export default {
registerStore.refreshRegisterList().finally(() => (this.registerLoading = false))
schemaStore.refreshSchemaList().finally(() => (this.schemaLoading = false))
},
methods: {
searchObjects() {
if (!this.selectedRegister?.id || !this.selectedSchema?.id) return

searchStore.searchObjects({
register: this.selectedRegister?.id,
schema: this.selectedSchema?.id,
})
},
},
}
</script>