Skip to content

Commit

Permalink
Merge pull request #2636 from LibreSign/fix/fields-usage-and-names
Browse files Browse the repository at this point in the history
fix: structure of array and store loading
  • Loading branch information
vitormattos authored Apr 1, 2024
2 parents 42656a9 + f12d6bb commit c3be8fc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
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

0 comments on commit c3be8fc

Please sign in to comment.