Skip to content

Commit

Permalink
Merge pull request #2451 from LibreSign/backport/2448/stable28
Browse files Browse the repository at this point in the history
[stable28] Add sign button when have more than one signer
  • Loading branch information
vitormattos authored Mar 6, 2024
2 parents 8fa55ae + 8af28df commit be0bcdb
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 27 deletions.
63 changes: 38 additions & 25 deletions src/Components/Request/RequestSignature.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</div>
<div v-else
id="request-signature-list-signers">
<NcButton v-if="canRequestSign && !filesStore.isSigned()"
<NcButton v-if="canRequestSign && !filesStore.isFullSigned()"
@click="addSigner">
{{ t('libresign', 'Add signer') }}
</NcButton>
Expand All @@ -29,28 +29,33 @@
</NcActionButton>
</template>
</Signers>
<NcButton v-if="canSave"
type="primary"
:disabled="hasLoading"
@click="save()">
<template #icon>
<NcLoadingIcon v-if="hasLoading" :size="20" />
</template>
{{ t('libresign', 'Next') }}
</NcButton>
<NcButton v-else-if="canSign"
type="primary"
:disabled="hasLoading"
@click="sign()">
<template #icon>
<NcLoadingIcon v-if="hasLoading" :size="20" />
</template>
{{ t('libresign', 'Sign') }}
</NcButton>
<NcButton v-if="filesStore.isSigned()"
@click="validationFile()">
{{ t('libresign', 'Validate') }}
</NcButton>
<div class="action-buttons">
<NcButton v-if="canSave && !filesStore.isPartialSigned"
:type="{
primary: !canSign,
secondary: canSign
}"
:disabled="hasLoading"
@click="save()">
<template #icon>
<NcLoadingIcon v-if="hasLoading" :size="20" />
</template>
{{ t('libresign', 'Next') }}
</NcButton>
<NcButton v-if="canSign"
type="primary"
:disabled="hasLoading"
@click="sign()">
<template #icon>
<NcLoadingIcon v-if="hasLoading" :size="20" />
</template>
{{ t('libresign', 'Sign') }}
</NcButton>
<NcButton v-if="filesStore.isFullSigned()"
@click="validationFile()">
{{ t('libresign', 'Validate') }}
</NcButton>
</div>
<VisibleElements />
</div>
</template>
Expand Down Expand Up @@ -100,11 +105,11 @@ export default {
!Object.hasOwn(this.filesStore.getFile(), 'requested_by')
|| this.filesStore.getFile().requested_by.uid === getCurrentUser().uid
)
&& !this.filesStore.isSigned()
&& !this.filesStore.isFullSigned()
&& this.filesStore.getFile()?.signers?.length > 0
},
canSign() {
return !this.filesStore.isSigned()
return !this.filesStore.isFullSigned()
&& this.filesStore.getFile()?.signers?.filter(signer => signer.me).length > 0
},
dataSigners() {
Expand Down Expand Up @@ -215,3 +220,11 @@ export default {
},
}
</script>
<style lang="scss" scoped>
.action-buttons{
display: flex;
box-sizing: border-box;
grid-gap: 10px;
}
</style>
15 changes: 13 additions & 2 deletions src/store/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,25 @@ export const useFilesStore = defineStore('files', {
disableIdentifySigner() {
this.identifyingSigner = false
},
isSigned() {
isPartialSigned() {
if (this.selectedNodeId === 0) {
return false
}
if (!Object.hasOwn(this.getFile(), 'signers')) {
return false
}
return this.files[this.selectedNodeId].signers.filter(signer => signer.signed?.length > 0).length > 0
return this.files[this.selectedNodeId].signers
.filter(signer => signer.signed?.length > 0).length > 0
},
isFullSigned() {
if (this.selectedNodeId === 0) {
return false
}
if (!Object.hasOwn(this.getFile(), 'signers')) {
return false
}
return this.files[this.selectedNodeId].signers
.filter(signer => signer.signed?.length > 0).length === this.files[this.selectedNodeId].signers.length
},
getSubtitle() {
if (this.selectedNodeId === 0) {
Expand Down

0 comments on commit be0bcdb

Please sign in to comment.