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

[stable29] fix: structure of array and store loading #2638

Merged
merged 1 commit into from
Apr 1, 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
5 changes: 4 additions & 1 deletion src/Components/Request/RequestSignature.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import IdentifySigner from './IdentifySigner.vue'
import VisibleElements from './VisibleElements.vue'
import { loadState } from '@nextcloud/initial-state'
import { useFilesStore } from '../../store/files.js'
import { useSignStore } from '../../store/sign.js'

export default {
name: 'RequestSignature',
Expand All @@ -93,7 +94,8 @@ export default {
},
setup() {
const filesStore = useFilesStore()
return { filesStore }
const signStore = useSignStore()
return { filesStore, signStore }
},
data() {
return {
Expand Down Expand Up @@ -194,6 +196,7 @@ export default {
}
return accumulator
}, '')
this.signStore.document = this.filesStore.getFile()
const route = this.$router.resolve({ name: 'SignPDF', params: { uuid } })
this.modalSrc = route.href
this.showSignModal = true
Expand Down
17 changes: 8 additions & 9 deletions src/store/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ import { loadState } from '@nextcloud/initial-state'
export const useSignStore = defineStore('sign', {
state: () => ({
errors: [],
pdf: '',
uuid: '',
document: {
filename: '',
name: '',
description: '',
status: '',
statusText: '',
fileId: 0,
url: '',
uuid: '',
signers: [],
visibleElements: [],
},
Expand All @@ -41,14 +40,14 @@ export const useSignStore = defineStore('sign', {
actions: {
initFromState() {
this.errors = loadState('libresign', 'errors', [])
this.pdf = loadState('libresign', 'pdf')
this.uuid = loadState('libresign', 'uuid', null)
const pdf = loadState('libresign', 'pdf', [])
this.document = {
filename: loadState('libresign', 'filename'),
description: loadState('libresign', 'description'),
name: loadState('libresign', 'filename'),
description: loadState('libresign', 'description', ''),
status: loadState('libresign', 'status'),
statusText: loadState('libresign', 'statusText'),
fileId: loadState('libresign', 'fileId', 0),
url: pdf.url,
uuid: loadState('libresign', 'uuid', null),
signers: loadState('libresign', 'signers', []),
visibleElements: loadState('libresign', 'visibleElements', []),
}
Expand Down
14 changes: 8 additions & 6 deletions src/views/SignPDF/SignPDF.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<header>
<img class="pdf-icon" :src="PDFIcon">
<h1>
{{ signStore.document.filename }}
{{ signStore.document.name }}
<br>
<Chip>
{{ signStore.document.statusText }}
Expand Down Expand Up @@ -34,7 +34,7 @@
ref="pdfEditor"
width="100%"
height="100%"
:file-src="signStore.pdf.url"
:file-src="signStore.document.url"
:read-only="true"
@pdf-editor:end-init="updateSigners" />
</NcAppContent>
Expand Down Expand Up @@ -86,11 +86,13 @@ export default {
},
},
mounted() {
this.signStore.initFromState()
this.mounted = true
if (!this.signStore.uuid) {
this.signStore.uuid = this.$route.params.uuid
if (this.signStore.document.uuid.length === 0) {
this.signStore.initFromState()
if (!this.signStore.document.uuid) {
this.signStore.document.uuid = this.$route.params.uuid
}
}
this.mounted = true
showErrors(this.signStore.errors)
},
methods: {
Expand Down