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

Chore/make possible choose the page #3983

Merged
merged 3 commits into from
Nov 18, 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
1 change: 1 addition & 0 deletions .github/workflows/owasp-dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on: pull_request

jobs:
dependency-check:
if: false # temporary disabled
runs-on: ubuntu-latest
steps:
- name: Check out code
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"@fontsource/dancing-script": "^5.1.0",
"@libresign/vue-pdf-editor": "^1.3.7",
"@libresign/vue-pdf-editor": "^1.4.4",
"@marionebl/option": "^1.0.8",
"@mdi/js": "^7.4.47",
"@mdi/svg": "^7.4.47",
Expand Down
4 changes: 4 additions & 0 deletions src/Components/PdfEditor/PdfEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
:origin-width="object.originWidth"
:origin-height="object.originHeight"
:page-scale="pagesScale"
:canvas-width="object.canvasWidth"
:canvas-height="object.canvasHeight"
@onUpdate="$refs.vuePdfEditor.updateObject(object.id, $event)"
@onDelete="onDeleteSigner(object)" />
</template>
Expand Down Expand Up @@ -78,6 +80,8 @@ export default {
originHeight: signer.element.coordinates.height,
x: signer.element.coordinates.llx,
y: signer.element.coordinates.ury,
canvasWidth: signer.element.coordinates.canvasWidth,
canvasHeight: signer.element.coordinates.canvasHeight,
}
this.$refs.vuePdfEditor.allObjects = this.$refs.vuePdfEditor.allObjects.map((objects, pIndex) => {
if (pIndex === signer.element.coordinates.page - 1) {
Expand Down
10 changes: 9 additions & 1 deletion src/Components/PdfEditor/Signature.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:style="{
width: `${width + dw}px`,
height: `${Math.round((width + dw) / ratio)}px`,
transform: `translate(${x + dx}px, ${y + dy}px)`,
transform: translateCoordinates(),
}">
<div class="signature absolute w-full h-full"
:class="[
Expand Down Expand Up @@ -93,6 +93,14 @@ export default {
type: Number,
default: 1,
},
canvasWidth: {
type: Number,
default: 1,
},
canvasHeight: {
type: Number,
default: 1,
},
fixSize: {
type: Boolean,
default: false,
Expand Down
70 changes: 60 additions & 10 deletions src/Components/Request/VisibleElements.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@
{{ statusLabel }}
</Chip>
</h2>
<p>
<small>
{{ t('libresign', 'Click the page to add visible signature, then select a signer to set their signature position') }}
</small>
</p>
<ul class="view-sign-detail__sidebar">
<li v-if="signerSelected"
:class="{ tip: signerSelected }">
{{ t('libresign', 'Click on the place you want to add.') }}
<NcButton type="primary"
@click="stopAddSigner">
{{ t('libresign', 'Cancel') }}
</NcButton>
</li>
<Signer v-for="(signer, key) in document.signers"
:key="key"
:ref="'li-' + key"
:current-signer="key"
:class="{ disabled: signerSelected }"
:signer="signer"
event="libresign:visible-elements-select-signer">
<slot v-bind="{signer}" slot="actions" name="actions" />
Expand All @@ -33,6 +38,7 @@
<NcButton v-if="canSave"
:type="typeOfRequestButton"
:wide="true"
:class="{ disabled: signerSelected }"
@click="showConfirm = true">
{{ t('libresign', 'Request') }}
</NcButton>
Expand Down Expand Up @@ -122,6 +128,7 @@ export default {
showConfirm: false,
loading: false,
errorConfirmRequest: '',
signerSelected: null,
}
},
computed: {
Expand Down Expand Up @@ -207,16 +214,42 @@ export default {
this.filesStore.loading = false
},
onSelectSigner(signer) {
signer.element = {
this.signerSelected = signer
const canvasList = this.$refs.pdfEditor.$refs.vuePdfEditor.$refs.pdfBody.querySelectorAll('canvas')
canvasList.forEach((canvas) => {
canvas.addEventListener('click', this.doSelectSigner)
})
},
doSelectSigner(event) {
const canvasList = this.$refs.pdfEditor.$refs.vuePdfEditor.$refs.pdfBody.querySelectorAll('canvas')
const page = Array.from(canvasList).indexOf(event.target)
this.addSignerToPosition(event, page)
this.stopAddSigner()
},
addSignerToPosition(event, page) {
const measurement = this.$refs.pdfEditor.$refs.vuePdfEditor.$refs['page' + page][0].getCanvasMeasurement()
const rect = event.target.getBoundingClientRect()
const x = event.clientX - rect.left
const y = event.clientY - rect.top
this.signerSelected.element = {
coordinates: {
page: this.$refs.pdfEditor.$refs.vuePdfEditor.selectedPageIndex + 1,
llx: 100,
ury: 100,
page: page + 1,
llx: x - SignatureImageDimensions.width / 2,
ury: y - SignatureImageDimensions.height / 2,
height: SignatureImageDimensions.height,
width: SignatureImageDimensions.width,
canvasWidth: measurement.canvasWidth,
canvasHeight: measurement.canvasHeight,
},
}
this.$refs.pdfEditor.addSigner(signer)
this.$refs.pdfEditor.addSigner(this.signerSelected)
},
stopAddSigner() {
const canvasList = this.$refs.pdfEditor.$refs.vuePdfEditor.$refs.pdfBody.querySelectorAll('canvas')
canvasList.forEach((canvas) => {
canvas.removeEventListener('click', this.doSelectSigner)
})
this.signerSelected = null
},
async onDeleteSigner(object) {
if (!object.signer.element.elementId) {
Expand Down Expand Up @@ -314,6 +347,23 @@ export default {
margin: 3px 3px 1em 3px;
}
}
.disabled {
pointer-events: none;
visibility: hidden;
}
.tip {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin-top: 1px;
margin-bottom: 1px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
}
}
</style>
38 changes: 18 additions & 20 deletions src/Components/Signers/Signer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<div>
<NcListItem :name="signer.displayName"
:force-display-actions="true"
@click="signerClickAction">
<template #icon>
<NcAvatar :size="44" :display-name="signer.displayName" />
</template>
<template #subname>
<Bullet v-for="method in identifyMethodsNames" :key="method" :name="method" />
</template>
<NcActions>
<slot v-if="$slots.actions" slot="actions" name="actions" />
</NcActions>
<template #indicator>
<CheckboxBlankCircle :size="16"
:fill-color="statusColor"
:title="statusText" />
</template>
</NcListItem>
</div>
<NcListItem :name="signer.displayName"
:force-display-actions="true"
@click="signerClickAction">
<template #icon>
<NcAvatar :size="44" :display-name="signer.displayName" />
</template>
<template #subname>
<Bullet v-for="method in identifyMethodsNames" :key="method" :name="method" />
</template>
<NcActions>
<slot v-if="$slots.actions" slot="actions" name="actions" />
</NcActions>
<template #indicator>
<CheckboxBlankCircle :size="16"
:fill-color="statusColor"
:title="statusText" />
</template>
</NcListItem>
</template>
<script>
import CheckboxBlankCircle from 'vue-material-design-icons/CheckboxBlankCircle.vue'
Expand Down
Loading