Skip to content

Commit

Permalink
Merge pull request #2453 from LibreSign/backport/2452/stable28
Browse files Browse the repository at this point in the history
[stable28] Open sign in modal
  • Loading branch information
vitormattos authored Mar 6, 2024
2 parents be0bcdb + 873e7d7 commit 5ef74f2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
1 change: 1 addition & 0 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public function index(): TemplateResponse {

$policy = new ContentSecurityPolicy();
$policy->allowEvalScript(true);
$policy->addAllowedFrameDomain('\'self\'');
$response->setContentSecurityPolicy($policy);

return $response;
Expand Down
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
<FileSignIcon :size="20" />
</template>
</NcAppNavigationItem>
<NcAppNavigationItem id="sign-files"
:to="{ name: 'signFiles' }"
<NcAppNavigationItem id="timeline"
:to="{ name: 'timeline' }"
:name="t('libresign', 'Files')"
@click="unselectFile">
<template #icon>
Expand Down
29 changes: 23 additions & 6 deletions src/Components/Request/RequestSignature.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<div v-else
id="request-signature-list-signers">
<NcButton v-if="canRequestSign && !filesStore.isFullSigned()"
:type="dataSigners.length === 0 ? 'primary' : 'secondary'"
@click="addSigner">
{{ t('libresign', 'Add signer') }}
</NcButton>
Expand All @@ -30,11 +31,8 @@
</template>
</Signers>
<div class="action-buttons">
<NcButton v-if="canSave && !filesStore.isPartialSigned"
:type="{
primary: !canSign,
secondary: canSign
}"
<NcButton v-if="canSave"
:type="canSign ? 'secondary' : 'primary'"
:disabled="hasLoading"
@click="save()">
<template #icon>
Expand All @@ -52,11 +50,15 @@
{{ t('libresign', 'Sign') }}
</NcButton>
<NcButton v-if="filesStore.isFullSigned()"
type="primary"
@click="validationFile()">
{{ t('libresign', 'Validate') }}
</NcButton>
</div>
<VisibleElements />
<NcModal v-if="showSignModal" size="full" @close="closeModal()">
<iframe :src="modalSrc" class="iframe" />
</NcModal>
</div>
</template>
<script>
Expand All @@ -66,6 +68,7 @@ import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
import { getCurrentUser } from '@nextcloud/auth'
import Delete from 'vue-material-design-icons/Delete.vue'
import { showError, showSuccess } from '@nextcloud/dialogs'
Expand All @@ -82,6 +85,7 @@ export default {
NcActionButton,
NcButton,
NcLoadingIcon,
NcModal,
Delete,
Signers,
IdentifySigner,
Expand All @@ -95,6 +99,8 @@ export default {
return {
hasLoading: false,
signerToEdit: {},
modalSrc: '',
showSignModal: false,
canRequestSign: loadState('libresign', 'can_request_sign', false),
}
},
Expand All @@ -105,11 +111,13 @@ export default {
!Object.hasOwn(this.filesStore.getFile(), 'requested_by')
|| this.filesStore.getFile().requested_by.uid === getCurrentUser().uid
)
&& !this.filesStore.isPartialSigned()
&& !this.filesStore.isFullSigned()
&& this.filesStore.getFile()?.signers?.length > 0
},
canSign() {
return !this.filesStore.isFullSigned()
&& this.filesStore.getFile().status > 0
&& this.filesStore.getFile()?.signers?.filter(signer => signer.me).length > 0
},
dataSigners() {
Expand All @@ -129,6 +137,9 @@ export default {
unsubscribe('libresign:edit-signer')
},
methods: {
closeModal() {
this.showSignModal = false
},
validationFile() {
this.$router.push({ name: 'validationFile', params: { uuid: this.filesStore.getFile().uuid } })
},
Expand Down Expand Up @@ -166,7 +177,8 @@ export default {
return accumulator
}, '')
const route = this.$router.resolve({ name: 'SignPDF', params: { uuid } })
window.location.href = route.href
this.modalSrc = route.href
this.showSignModal = true
},
async save() {
this.hasLoading = true
Expand Down Expand Up @@ -227,4 +239,9 @@ export default {
box-sizing: border-box;
grid-gap: 10px;
}
.iframe {
width: 100%;
height: 100%;
}
</style>
2 changes: 1 addition & 1 deletion src/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const router = new Router({
},
{
path: '/f/timeline/sign',
name: 'signFiles',
name: 'timeline',
component: () => import('../views/Timeline/Timeline.vue'),
},
{
Expand Down
5 changes: 3 additions & 2 deletions src/store/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ export const useFilesStore = defineStore('files', {
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
return this.files[this.selectedNodeId].signers.length > 0
&& 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 5ef74f2

Please sign in to comment.