Skip to content

Commit 2904ba3

Browse files
bug fix in template flow as well as placeholder is not working in mobile view
1 parent eef9ee7 commit 2904ba3

File tree

8 files changed

+123
-110
lines changed

8 files changed

+123
-110
lines changed

apps/OpenSign/src/primitives/GetReportDisplay.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ const ReportTable = ({
9191
if (!templateData.error) {
9292
const Doc = templateData;
9393

94-
let placeholdersArr = [];
95-
if (Doc.Placeholders?.length > 0) {
96-
placeholdersArr = Doc.Placeholders;
97-
}
9894
let signers = [];
9995
if (Doc.Signers?.length > 0) {
10096
Doc.Signers?.forEach((x) => {
@@ -107,6 +103,11 @@ const ReportTable = ({
107103
signers.push(obj);
108104
}
109105
});
106+
}
107+
108+
let placeholdersArr = [];
109+
if (Doc.Placeholders?.length > 0) {
110+
placeholdersArr = Doc.Placeholders;
110111
const data = {
111112
Name: Doc.Name,
112113
URL: Doc.URL,

apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js

Lines changed: 108 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import SignPDF from './SignPDF.min.cjs';
22
import fs from 'node:fs';
33
import axios from 'axios';
44
import FormData from 'form-data';
5-
import plainplaceholder from './customSignPdf/plainplaceholder.min.js';
5+
// import plainplaceholder from './customSignPdf/plainplaceholder.min.js';
66
import { plainAddPlaceholder } from 'node-signpdf/dist/helpers/index.js';
77
const serverUrl = process.env.SERVER_URL,
88
APPID = process.env.APP_ID,
@@ -19,20 +19,20 @@ async function uploadFile(a) {
1919
console.log('err ', e), fs.unlinkSync(a);
2020
}
2121
}
22-
async function updateDoc(t, s, r, i, o, n) {
22+
async function updateDoc(t, s, r, i, n, o) {
2323
try {
2424
var d = {
25-
UserPtr: { __type: 'Pointer', className: n, objectId: r },
25+
UserPtr: { __type: 'Pointer', className: o, objectId: r },
2626
SignedUrl: s,
2727
Activity: 'Signed',
2828
ipAddress: i,
2929
};
3030
let e;
31-
var l = (e = o.AuditTrail && 0 < o.AuditTrail.length ? [...o.AuditTrail, d] : [d]).filter(
31+
var l = (e = n.AuditTrail && 0 < n.AuditTrail.length ? [...n.AuditTrail, d] : [d]).filter(
3232
e => 'Signed' === e.Activity
3333
);
3434
let a = !1;
35-
!((o.Signers && 0 < o.Signers.length && l.length !== o.Signers.length) || !(a = !0));
35+
!((n.Signers && 0 < n.Signers.length && l.length !== n.Signers.length) || !(a = !0));
3636
var p = { SignedUrl: s, AuditTrail: e, IsCompleted: a };
3737
await axios.put(serverUrl + '/classes/contracts_Document/' + t, p, {
3838
headers: {
@@ -96,115 +96,135 @@ async function sendCompletedMail(e) {
9696
},
9797
});
9898
}
99-
async function PDF(s, r) {
99+
async function PDF(i, n) {
100100
try {
101-
var i = s.params.sign,
102-
e = s.params.docId,
103-
o = s.params.userId,
104-
n = await axios.get(serverUrl + '/classes/contracts_Document/' + e + '?include=ExtUserPtr', {
105-
headers: {
106-
'Content-Type': 'application/json',
107-
'X-Parse-Application-Id': APPID,
108-
'X-Parse-Master-Key': masterKEY,
109-
},
110-
}),
111-
d = await axios.get(serverUrl + '/users/me', {
101+
i.params.sign;
102+
var e = i.params.docId,
103+
a = i.params.userId,
104+
o = await axios.get(
105+
serverUrl + '/classes/contracts_Document/' + e + '?include=ExtUserPtr,Signers',
106+
{
107+
headers: {
108+
'Content-Type': 'application/json',
109+
'X-Parse-Application-Id': APPID,
110+
'X-Parse-Master-Key': masterKEY,
111+
},
112+
}
113+
),
114+
t = await axios.get(serverUrl + '/users/me', {
112115
headers: {
113116
'X-Parse-Application-Id': APPID,
114-
'X-Parse-Session-Token': s.headers.sessiontoken,
117+
'X-Parse-Session-Token': i.headers.sessiontoken,
115118
},
116119
});
117-
if (!d.data || !d.data.objectId) return { status: 'error', message: 'this user not allowed!' };
120+
if (!t.data || !t.data.objectId) return { status: 'error', message: 'this user not allowed!' };
118121
{
119-
var l,
122+
var d,
123+
l,
120124
p,
121-
c,
122-
m = JSON.stringify({ objectId: o });
123-
let a, t;
124-
t = o
125-
? (l = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + m, {
125+
c = JSON.stringify({ objectId: a });
126+
let s, r;
127+
r = a
128+
? (d = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + c, {
126129
headers: {
127130
'X-Parse-Application-Id': APPID,
128-
'X-Parse-Session-Token': s.headers.sessiontoken,
131+
'X-Parse-Session-Token': i.headers.sessiontoken,
129132
},
130-
})).data && 0 < l.data.results.length
131-
? ((a = l), 'contracts_Contactbook')
132-
: ((a = await axios.get(serverUrl + '/classes/contracts_Users?where=' + m, {
133-
headers: {
134-
'X-Parse-Application-Id': APPID,
135-
'X-Parse-Master-Key': masterKEY,
136-
},
133+
})).data && 0 < d.data.results.length
134+
? ((s = d), 'contracts_Contactbook')
135+
: ((s = await axios.get(serverUrl + '/classes/contracts_Users?where=' + c, {
136+
headers: { 'X-Parse-Application-Id': APPID, 'X-Parse-Master-Key': masterKEY },
137137
})),
138138
'contracts_Users')
139-
: ((p = JSON.stringify({
140-
UserId: { __type: 'Pointer', className: '_User', objectId: d.data.objectId },
139+
: ((l = JSON.stringify({
140+
UserId: { __type: 'Pointer', className: '_User', objectId: t.data.objectId },
141141
})),
142-
(c = await axios.get(serverUrl + '/classes/contracts_Users?where=' + p, {
143-
headers: {
144-
'X-Parse-Application-Id': APPID,
145-
'X-Parse-Master-Key': masterKEY,
146-
},
147-
})).data && 0 < c.data.results.length
148-
? ((a = c), 'contracts_Users')
149-
: ((a = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + p, {
142+
(p = await axios.get(serverUrl + '/classes/contracts_Users?where=' + l, {
143+
headers: { 'X-Parse-Application-Id': APPID, 'X-Parse-Master-Key': masterKEY },
144+
})).data && 0 < p.data.results.length
145+
? ((s = p), 'contracts_Users')
146+
: ((s = await axios.get(serverUrl + '/classes/contracts_Contactbook?where=' + l, {
150147
headers: {
151148
'X-Parse-Application-Id': APPID,
152-
'X-Parse-Session-Token': s.headers.sessiontoken,
149+
'X-Parse-Session-Token': i.headers.sessiontoken,
153150
},
154151
})),
155152
'contracts_Contactbook'));
156-
var g = a.data.results[0].Name,
157-
h = a.data.results[0].Email;
158-
if (!s.params.pdfFile) return { status: 'error', message: 'pdf file not present!' };
153+
var m = s.data.results[0].Name,
154+
g = s.data.results[0].Email;
155+
if (!i.params.pdfFile) return { status: 'error', message: 'pdf file not present!' };
159156
{
160-
let e = Buffer.from(s.params.pdfFile, 'base64');
157+
let e = Buffer.from(i.params.pdfFile, 'base64');
161158
var u = process.env.PFX_BASE64,
162-
f = Buffer.from(u, 'base64');
163-
e = i
164-
? plainplaceholder({
165-
pdfBuffer: e,
166-
reason: 'Digitally signed by Open sign for ' + g + ' <' + h + '>',
167-
location: 'test location',
168-
signatureLength: 1e4,
169-
sign: i,
170-
})
171-
: plainAddPlaceholder({
172-
pdfBuffer: e,
173-
reason: 'Digitally signed by Open sign for ' + g + ' <' + h + '>',
174-
location: 'test location',
175-
signatureLength: 1e4,
176-
});
177-
var y = await new SignPDF(e, f).signPDF(),
178-
v = `./exports/exported_file_${Math.floor(5e3 * Math.random())}.pdf`,
179-
P = (fs.writeFileSync(v, y), await uploadFile(v));
180-
if (P && P.imageUrl) {
181-
const r = await updateDoc(
182-
s.params.docId,
183-
P.imageUrl,
184-
a.data.results[0].objectId,
185-
s.headers['x-real-ip'],
186-
n.data,
187-
t
159+
h = Buffer.from(u, 'base64'),
160+
f = {
161+
UserPtr: { __type: 'Pointer', className: r, objectId: s.data.results[0].objectId },
162+
SignedUrl: '',
163+
Activity: 'Signed',
164+
ipAddress: i.headers['x-real-ip'],
165+
};
166+
let a;
167+
var y = (a =
168+
o.data.AuditTrail && 0 < o.data.AuditTrail.length
169+
? [...o.data.AuditTrail, f]
170+
: [f]).filter(e => 'Signed' === e.Activity);
171+
let t = !1;
172+
!(
173+
(o.data.Signers && 0 < o.data.Signers.length && y.length !== o.data.Signers.length) ||
174+
!(t = !0)
175+
);
176+
var v,
177+
P,
178+
x = `./exports/exported_file_${Math.floor(5e3 * Math.random())}.pdf`,
179+
A =
180+
(t
181+
? ((v = o.data.Signers?.map(e => e.Name + ' <' + e.Email + '>')),
182+
(e =
183+
v && 0 < v.length
184+
? plainAddPlaceholder({
185+
pdfBuffer: e,
186+
reason: 'Digitally signed by Open sign for ' + v?.join(', '),
187+
location: 'location',
188+
signatureLength: 1e4,
189+
})
190+
: plainAddPlaceholder({
191+
pdfBuffer: e,
192+
reason: 'Digitally signed by Open sign for ' + m + ' <' + g + '>',
193+
location: 'location',
194+
signatureLength: 1e4,
195+
})),
196+
(P = await new SignPDF(e, h).signPDF()),
197+
fs.writeFileSync(x, P))
198+
: fs.writeFileSync(x, e),
199+
await uploadFile(x));
200+
if (A && A.imageUrl) {
201+
const n = await updateDoc(
202+
i.params.docId,
203+
A.imageUrl,
204+
s.data.results[0].objectId,
205+
i.headers['x-real-ip'],
206+
o.data,
207+
r
188208
);
189209
return (
190210
sendMail({
191-
url: P.imageUrl,
192-
sender: { Mail: n.data.ExtUserPtr.Email, Name: n.data.ExtUserPtr.Name },
193-
pdfName: n.data.Name,
194-
receiver: h,
211+
url: A.imageUrl,
212+
sender: { Mail: o.data.ExtUserPtr.Email, Name: o.data.ExtUserPtr.Name },
213+
pdfName: o.data.Name,
214+
receiver: g,
195215
}),
196-
r &&
197-
r.isCompleted &&
216+
n &&
217+
n.isCompleted &&
198218
sendCompletedMail({
199-
url: P.imageUrl,
200-
sender: { Mail: n.data.ExtUserPtr.Email, Name: 'Open sign' },
201-
pdfName: n.data.Name,
202-
receiver: n.data.ExtUserPtr.Email,
219+
url: A.imageUrl,
220+
sender: { Mail: o.data.ExtUserPtr.Email, Name: 'Open sign' },
221+
pdfName: o.data.Name,
222+
receiver: o.data.ExtUserPtr.Email,
203223
}),
204-
fs.unlinkSync(v),
205-
console.log('New Signed PDF created called: ' + v),
206-
'success' === r.message
207-
? { status: 'success', data: P.imageUrl }
224+
fs.unlinkSync(x),
225+
console.log('New Signed PDF created called: ' + x),
226+
'success' === n.message
227+
? { status: 'success', data: A.imageUrl }
208228
: { status: 'error', message: 'please provide required parameters!' }
209229
);
210230
}
-170 KB
Binary file not shown.

microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,8 @@ const TemplatePlaceholder = () => {
834834
// save Role in entry in signerList and user
835835
const handleAddRole = (e) => {
836836
e.preventDefault();
837+
setSignerObjId('')
838+
setContractName('')
837839
const count = signersdata.length > 0 ? signersdata.length + 1 : 1;
838840
const Id = randomId();
839841
const index = signersdata.length;
@@ -861,7 +863,7 @@ const TemplatePlaceholder = () => {
861863
const index = signersdata.findIndex((x) => x.Id === Id);
862864
if (index === signersdata.length - 1) {
863865
setUniqueId(updateSigner[updateSigner.length - 1]?.Id || "");
864-
setIsSelectId(0);
866+
setIsSelectId(index - 1|| 0);
865867
} else {
866868
setUniqueId(updateSigner[index]?.Id || "");
867869
setIsSelectId(index);

microfrontends/SignDocuments/src/Component/placeHolderSign.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,18 +317,12 @@ function PlaceHolderSign() {
317317

318318
//function for setting position after drop signature button over pdf
319319
const addPositionOfSignature = (item, monitor) => {
320-
if (isMobile) {
321-
if (selectedEmail) {
322-
getSignerPos(item, monitor);
323-
} else {
324-
setIsShowEmail(true);
325-
}
326-
} else {
327-
getSignerPos(item, monitor);
328-
}
320+
getSignerPos(item, monitor);
329321
};
330322

331323
const getSignerPos = (item, monitor) => {
324+
setSignerObjId('')
325+
setContractName('')
332326
if (uniqueId) {
333327
const signer = signersdata.find((x) => x.Id === uniqueId);
334328
if (signer) {

microfrontends/SignDocuments/src/premitives/RecipientList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ const RecipientList = (props) => {
8080
: nonHoverStyle(ind)
8181
}
8282
onClick={() => {
83-
props.setSignerObjId(obj?.objectId);
83+
props.setSignerObjId(obj?.objectId || "");
8484
props.setIsSelectId(ind);
85-
props.setContractName(obj?.className);
85+
props.setContractName(obj?.className || "");
8686
props.setUniqueId(obj.Id);
8787
props.setRoleName(obj.Role);
8888
if(props.handleModal){

microfrontends/SignDocuments/src/premitives/TourContentWithBtn.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ export default function TourContentWithBtn({ message, isChecked }) {
1212
return (
1313
<div>
1414
<p>{message}</p>
15-
<label style={{ textAlign: "center", display: "flex" }}>
15+
<label style={{ textAlign: "center", display: "flex", "justifyContent":'center' }}>
1616
<input
1717
type="checkbox"
1818
style={{ marginRight: 3 }}
1919
checked={isCheck}
2020
onChange={handleCheck}
2121
/>{" "}
22-
<span>Don't show</span>
22+
<span style={{color:"#787878", fontSize: 12}}>Don't show this again</span>
2323
</label>
2424
</div>
2525
);

microfrontends/SignDocuments/src/utils/Utils.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -765,13 +765,9 @@ export const handleImageResize = (
765765
export const handleSignYourselfImageResize = (
766766
ref,
767767
key,
768-
direction,
769-
position,
770768
xyPostion,
771769
index,
772770
setXyPostion,
773-
pdfOriginalWidth,
774-
containerWH
775771
) => {
776772
const updateFilter = xyPostion[index].pos.filter(
777773
(data) => data.key === key && data.Width && data.Height

0 commit comments

Comments
 (0)