Skip to content

🔥 The free & Open Source DocuSign alternative

bug fix in template flow as well as placeholder is not working in mobile view

prafull-opensignlabs2904ba30853b
diff --git a/apps/OpenSign/src/primitives/GetReportDisplay.js b/apps/OpenSign/src/primitives/GetReportDisplay.js
index fc8fa414d..c6d5d04ad 100644
--- a/apps/OpenSign/src/primitives/GetReportDisplay.js
+++ b/apps/OpenSign/src/primitives/GetReportDisplay.js
@@ -91,10 +91,6 @@ const ReportTable = ({
if (!templateData.error) {
const Doc = templateData;
- let placeholdersArr = [];
- if (Doc.Placeholders?.length > 0) {
- placeholdersArr = Doc.Placeholders;
- }
let signers = [];
if (Doc.Signers?.length > 0) {
Doc.Signers?.forEach((x) => {
@@ -107,6 +103,11 @@ const ReportTable = ({
signers.push(obj);
}
});
+ }
+
+ let placeholdersArr = [];
+ if (Doc.Placeholders?.length > 0) {
+ placeholdersArr = Doc.Placeholders;
const data = {
Name: Doc.Name,
URL: Doc.URL,
diff --git a/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js b/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js
index 3bbabdad2..36f015c16 100644
--- a/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js
+++ b/apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js
@@ -2,7 +2,7 @@ import SignPDF from './SignPDF.min.cjs';
import fs from 'node:fs';
import axios from 'axios';
import FormData from 'form-data';
-import plainplaceholder from './customSignPdf/plainplaceholder.min.js';
+// import plainplaceholder from './customSignPdf/plainplaceholder.min.js';
import { plainAddPlaceholder } from 'node-signpdf/dist/helpers/index.js';
const serverUrl = process.env.SERVER_URL,
APPID = process.env.APP_ID,
@@ -19,20 +19,20 @@ async function uploadFile(a) {
console.log('err ', e), fs.unlinkSync(a);
}
}
-async function updateDoc(t, s, r, i, o, n) {
+async function updateDoc(t, s, r, i, n, o) {
try {
var d = {
- UserPtr: { __type: 'Pointer', className: n, objectId: r },
+ UserPtr: { __type: 'Pointer', className: o, objectId: r },
SignedUrl: s,
Activity: 'Signed',
ipAddress: i,
};
let e;
- var l = (e = o.AuditTrail && 0 < o.AuditTrail.length ? [...o.AuditTrail, d] : [d]).filter(
+ var l = (e = n.AuditTrail && 0 < n.AuditTrail.length ? [...n.AuditTrail, d] : [d]).filter(
e => 'Signed' === e.Activity
);
let a = !1;
- !((o.Signers && 0 < o.Signers.length && l.length !== o.Signers.length) || !(a = !0));
+ !((n.Signers && 0 < n.Signers.length && l.length !== n.Signers.length) || !(a = !0));
var p = { SignedUrl: s, AuditTrail: e, IsCompleted: a };
await axios.put(serverUrl + '/classes/contracts_Document/' + t, p, {
headers: {
@@ -96,115 +96,135 @@ async function sendCompletedMail(e) {
},
});
}
-async function PDF(s, r) {
+async function PDF(i, n) {
try {
- var i = s.params.sign,
- e = s.params.docId,
- o = s.params.userId,
- n = await axios.get(serverUrl + '/classes/contracts_Document/' + e + '?include=ExtUserPtr', {
- headers: {
- 'Content-Type': 'application/json',
- 'X-Parse-Application-Id': APPID,
- 'X-Parse-Master-Key': masterKEY,
- },
- }),
- d = await axios.get(serverUrl + '/users/me', {
+ i.params.sign;
+ var e = i.params.docId,
+ a = i.params.userId,
+ o = await axios.get(
+ serverUrl + '/classes/contracts_Document/' + e + '?include=ExtUserPtr,Signers',
+ {
+ headers: {
+ 'Content-Type': 'application/json',
+ 'X-Parse-Application-Id': APPID,
+ 'X-Parse-Master-Key': masterKEY,
+ },
+ }
+ ),
+ t = await axios.get(serverUrl + '/users/me', {
headers: {
'X-Parse-Application-Id': APPID,
- 'X-Parse-Session-Token': s.headers.sessiontoken,
+ 'X-Parse-Session-Token': i.headers.sessiontoken,
},
});
- if (!d.data || !d.data.objectId) return { status: 'error', message: 'this user not allowed!' };
+ if (!t.data || !t.data.objectId) return { status: 'error', message: 'this user not allowed!' };
{
- var l,
+ var d,
+ l,
p,
- c,
- m = JSON.stringify({ objectId: o });
- let a, t;
- t = o
- ? (l = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + m, {
+ c = JSON.stringify({ objectId: a });
+ let s, r;
+ r = a
+ ? (d = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + c, {
headers: {
'X-Parse-Application-Id': APPID,
- 'X-Parse-Session-Token': s.headers.sessiontoken,
+ 'X-Parse-Session-Token': i.headers.sessiontoken,
},
- })).data && 0 < l.data.results.length
- ? ((a = l), 'contracts_Contactbook')
- : ((a = await axios.get(serverUrl + '/classes/contracts_Users?where=' + m, {
- headers: {
- 'X-Parse-Application-Id': APPID,
- 'X-Parse-Master-Key': masterKEY,
- },
+ })).data && 0 < d.data.results.length
+ ? ((s = d), 'contracts_Contactbook')
+ : ((s = await axios.get(serverUrl + '/classes/contracts_Users?where=' + c, {
+ headers: { 'X-Parse-Application-Id': APPID, 'X-Parse-Master-Key': masterKEY },
})),
'contracts_Users')
- : ((p = JSON.stringify({
- UserId: { __type: 'Pointer', className: '_User', objectId: d.data.objectId },
+ : ((l = JSON.stringify({
+ UserId: { __type: 'Pointer', className: '_User', objectId: t.data.objectId },
})),
- (c = await axios.get(serverUrl + '/classes/contracts_Users?where=' + p, {
- headers: {
- 'X-Parse-Application-Id': APPID,
- 'X-Parse-Master-Key': masterKEY,
- },
- })).data && 0 < c.data.results.length
- ? ((a = c), 'contracts_Users')
- : ((a = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + p, {
+ (p = await axios.get(serverUrl + '/classes/contracts_Users?where=' + l, {
+ headers: { 'X-Parse-Application-Id': APPID, 'X-Parse-Master-Key': masterKEY },
+ })).data && 0 < p.data.results.length
+ ? ((s = p), 'contracts_Users')
+ : ((s = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + l, {
headers: {
'X-Parse-Application-Id': APPID,
- 'X-Parse-Session-Token': s.headers.sessiontoken,
+ 'X-Parse-Session-Token': i.headers.sessiontoken,
},
})),
'contracts_Contactbook'));
- var g = a.data.results[0].Name,
- h = a.data.results[0].Email;
- if (!s.params.pdfFile) return { status: 'error', message: 'pdf file not present!' };
+ var m = s.data.results[0].Name,
+ g = s.data.results[0].Email;
+ if (!i.params.pdfFile) return { status: 'error', message: 'pdf file not present!' };
{
- let e = Buffer.from(s.params.pdfFile, 'base64');
+ let e = Buffer.from(i.params.pdfFile, 'base64');
var u = process.env.PFX_BASE64,
- f = Buffer.from(u, 'base64');
- e = i
- ? plainplaceholder({
- pdfBuffer: e,
- reason: 'Digitally signed by Open sign for ' + g + ' <' + h + '>',
- location: 'test location',
- signatureLength: 1e4,
- sign: i,
- })
- : plainAddPlaceholder({
- pdfBuffer: e,
- reason: 'Digitally signed by Open sign for ' + g + ' <' + h + '>',
- location: 'test location',
- signatureLength: 1e4,
- });
- var y = await new SignPDF(e, f).signPDF(),
- v = `./exports/exported_file_${Math.floor(5e3 * Math.random())}.pdf`,
- P = (fs.writeFileSync(v, y), await uploadFile(v));
- if (P && P.imageUrl) {
- const r = await updateDoc(
- s.params.docId,
- P.imageUrl,
- a.data.results[0].objectId,
- s.headers['x-real-ip'],
- n.data,
- t
+ h = Buffer.from(u, 'base64'),
+ f = {
+ UserPtr: { __type: 'Pointer', className: r, objectId: s.data.results[0].objectId },
+ SignedUrl: '',
+ Activity: 'Signed',
+ ipAddress: i.headers['x-real-ip'],
+ };
+ let a;
+ var y = (a =
+ o.data.AuditTrail && 0 < o.data.AuditTrail.length
+ ? [...o.data.AuditTrail, f]
+ : [f]).filter(e => 'Signed' === e.Activity);
+ let t = !1;
+ !(
+ (o.data.Signers && 0 < o.data.Signers.length && y.length !== o.data.Signers.length) ||
+ !(t = !0)
+ );
+ var v,
+ P,
+ x = `./exports/exported_file_${Math.floor(5e3 * Math.random())}.pdf`,
+ A =
+ (t
+ ? ((v = o.data.Signers?.map(e => e.Name + ' <' + e.Email + '>')),
+ (e =
+ v && 0 < v.length
+ ? plainAddPlaceholder({
+ pdfBuffer: e,
+ reason: 'Digitally signed by Open sign for ' + v?.join(', '),
+ location: 'location',
+ signatureLength: 1e4,
+ })
+ : plainAddPlaceholder({
+ pdfBuffer: e,
+ reason: 'Digitally signed by Open sign for ' + m + ' <' + g + '>',
+ location: 'location',
+ signatureLength: 1e4,
+ })),
+ (P = await new SignPDF(e, h).signPDF()),
+ fs.writeFileSync(x, P))
+ : fs.writeFileSync(x, e),
+ await uploadFile(x));
+ if (A && A.imageUrl) {
+ const n = await updateDoc(
+ i.params.docId,
+ A.imageUrl,
+ s.data.results[0].objectId,
+ i.headers['x-real-ip'],
+ o.data,
+ r
);
return (
sendMail({
- url: P.imageUrl,
- sender: { Mail: n.data.ExtUserPtr.Email, Name: n.data.ExtUserPtr.Name },
- pdfName: n.data.Name,
- receiver: h,
+ url: A.imageUrl,
+ sender: { Mail: o.data.ExtUserPtr.Email, Name: o.data.ExtUserPtr.Name },
+ pdfName: o.data.Name,
+ receiver: g,
}),
- r &&
- r.isCompleted &&
+ n &&
+ n.isCompleted &&
sendCompletedMail({
- url: P.imageUrl,
- sender: { Mail: n.data.ExtUserPtr.Email, Name: 'Open sign' },
- pdfName: n.data.Name,
- receiver: n.data.ExtUserPtr.Email,
+ url: A.imageUrl,
+ sender: { Mail: o.data.ExtUserPtr.Email, Name: 'Open sign' },
+ pdfName: o.data.Name,
+ receiver: o.data.ExtUserPtr.Email,
}),
- fs.unlinkSync(v),
- console.log('New Signed PDF created called: ' + v),
- 'success' === r.message
- ? { status: 'success', data: P.imageUrl }
+ fs.unlinkSync(x),
+ console.log('New Signed PDF created called: ' + x),
+ 'success' === n.message
+ ? { status: 'success', data: A.imageUrl }
: { status: 'error', message: 'please provide required parameters!' }
);
}
diff --git a/apps/OpenSignServer/exports/exported_file_2928.pdf b/apps/OpenSignServer/exports/exported_file_2928.pdf
deleted file mode 100644
index 1602a4456..000000000
Binary files a/apps/OpenSignServer/exports/exported_file_2928.pdf and /dev/null differ
diff --git a/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js b/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js
index e34e3a07b..28860f5e3 100644
--- a/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js
+++ b/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js
@@ -834,6 +834,8 @@ const TemplatePlaceholder = () => {
// save Role in entry in signerList and user
const handleAddRole = (e) => {
e.preventDefault();
+ setSignerObjId('')
+ setContractName('')
const count = signersdata.length > 0 ? signersdata.length + 1 : 1;
const Id = randomId();
const index = signersdata.length;
@@ -861,7 +863,7 @@ const TemplatePlaceholder = () => {
const index = signersdata.findIndex((x) => x.Id === Id);
if (index === signersdata.length - 1) {
setUniqueId(updateSigner[updateSigner.length - 1]?.Id || "");
- setIsSelectId(0);
+ setIsSelectId(index - 1|| 0);
} else {
setUniqueId(updateSigner[index]?.Id || "");
setIsSelectId(index);
diff --git a/microfrontends/SignDocuments/src/Component/placeHolderSign.js b/microfrontends/SignDocuments/src/Component/placeHolderSign.js
index 53ec8d700..6187f716b 100644
--- a/microfrontends/SignDocuments/src/Component/placeHolderSign.js
+++ b/microfrontends/SignDocuments/src/Component/placeHolderSign.js
@@ -317,18 +317,12 @@ function PlaceHolderSign() {
//function for setting position after drop signature button over pdf
const addPositionOfSignature = (item, monitor) => {
- if (isMobile) {
- if (selectedEmail) {
- getSignerPos(item, monitor);
- } else {
- setIsShowEmail(true);
- }
- } else {
- getSignerPos(item, monitor);
- }
+ getSignerPos(item, monitor);
};
const getSignerPos = (item, monitor) => {
+ setSignerObjId('')
+ setContractName('')
if (uniqueId) {
const signer = signersdata.find((x) => x.Id === uniqueId);
if (signer) {
diff --git a/microfrontends/SignDocuments/src/premitives/RecipientList.js b/microfrontends/SignDocuments/src/premitives/RecipientList.js
index 2198b01e2..9dc74f861 100644
--- a/microfrontends/SignDocuments/src/premitives/RecipientList.js
+++ b/microfrontends/SignDocuments/src/premitives/RecipientList.js
@@ -80,9 +80,9 @@ const RecipientList = (props) => {
: nonHoverStyle(ind)
}
onClick={() => {
- props.setSignerObjId(obj?.objectId);
+ props.setSignerObjId(obj?.objectId || "");
props.setIsSelectId(ind);
- props.setContractName(obj?.className);
+ props.setContractName(obj?.className || "");
props.setUniqueId(obj.Id);
props.setRoleName(obj.Role);
if(props.handleModal){
diff --git a/microfrontends/SignDocuments/src/premitives/TourContentWithBtn.js b/microfrontends/SignDocuments/src/premitives/TourContentWithBtn.js
index 0bc16e810..54295b43d 100644
--- a/microfrontends/SignDocuments/src/premitives/TourContentWithBtn.js
+++ b/microfrontends/SignDocuments/src/premitives/TourContentWithBtn.js
@@ -12,14 +12,14 @@ export default function TourContentWithBtn({ message, isChecked }) {
return (
<div>
<p>{message}</p>
- <label style={{ textAlign: "center", display: "flex" }}>
+ <label style={{ textAlign: "center", display: "flex", "justifyContent":'center' }}>
<input
type="checkbox"
style={{ marginRight: 3 }}
checked={isCheck}
onChange={handleCheck}
/>{" "}
- <span>Don't show</span>
+ <span style={{color:"#787878", fontSize: 12}}>Don't show this again</span>
</label>
</div>
);
diff --git a/microfrontends/SignDocuments/src/utils/Utils.js b/microfrontends/SignDocuments/src/utils/Utils.js
index 803d278d3..573f29eb4 100644
--- a/microfrontends/SignDocuments/src/utils/Utils.js
+++ b/microfrontends/SignDocuments/src/utils/Utils.js
@@ -765,13 +765,9 @@ export const handleImageResize = (
export const handleSignYourselfImageResize = (
ref,
key,
- direction,
- position,
xyPostion,
index,
setXyPostion,
- pdfOriginalWidth,
- containerWH
) => {
const updateFilter = xyPostion[index].pos.filter(
(data) => data.key === key && data.Width && data.Height