Skip to content

Commit c172a7c

Browse files
Merge pull request #598 from OpenSignLabs/tour_message
feat : add recipient button in placeholder flow to add new signers in document signer's list
2 parents 60c1aa2 + 90f3e00 commit c172a7c

File tree

13 files changed

+143
-62
lines changed

13 files changed

+143
-62
lines changed

apps/OpenSign/src/components/pdf/PlaceholderType.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ function PlaceholderType(props) {
3838
"December"
3939
];
4040
const validateExpression = (regexValidation) => {
41-
let regexObject = regexValidation;
42-
if (props.pos?.options.validation.type === "regex") {
43-
regexObject = RegexParser(regexValidation);
44-
}
45-
// new RegExp(regexValidation);
46-
let isValidate = regexObject.test(textValue);
47-
if (!isValidate) {
48-
props?.setValidateAlert(true);
49-
inputRef.current.focus();
41+
if (textValue) {
42+
let regexObject = regexValidation;
43+
if (props.pos?.options.validation.type === "regex") {
44+
regexObject = RegexParser(regexValidation);
45+
}
46+
// new RegExp(regexValidation);
47+
let isValidate = regexObject.test(textValue);
48+
if (!isValidate) {
49+
props?.setValidateAlert(true);
50+
inputRef.current.focus();
51+
}
5052
}
5153
};
5254

apps/OpenSign/src/components/pdf/RecipientList.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ const RecipientList = (props) => {
230230
</span>
231231
</>
232232
)}
233-
{obj.Name && <span className={"useEmail"}>{obj.Role}</span>}
233+
{obj.Name && (
234+
<span className={"useEmail"}>
235+
{obj?.Role || obj?.Email}
236+
</span>
237+
)}
234238
</div>
235239
</div>
236240
{isMobile && props.sendInOrder && (

apps/OpenSign/src/components/pdf/RenderAllPdfPage.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Document, Page } from "react-pdf";
44
import { themeColor } from "../../constant/const";
55

66
function RenderAllPdfPage({
7-
pdfUrl,
87
signPdfUrl,
98
allPages,
109
setAllPages,
@@ -50,8 +49,7 @@ function RenderAllPdfPage({
5049
<Document
5150
loading={"Loading Document.."}
5251
onLoadSuccess={onDocumentLoad}
53-
file={pdfUrl ? pdfUrl : signPdfUrl}
54-
// file="https://api.printnode.com/static/test/pdf/multipage.pdf"
52+
file={signPdfUrl}
5553
>
5654
{Array.from(new Array(allPages), (el, index) => (
5755
<div

apps/OpenSign/src/components/pdf/RenderPdf.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,11 @@ function RenderPdf({
296296
{type && (
297297
<div style={{ fontWeight: "700", fontSize: 11 }}>{type}</div>
298298
)}
299-
<div style={{ color: "black", fontSize: 8, fontWeight: "500" }}>
300-
{`(${Role})`}
301-
</div>
299+
{Role && (
300+
<div style={{ color: "black", fontSize: 8, fontWeight: "500" }}>
301+
{`(${Role})`}
302+
</div>
303+
)}
302304
</>
303305
);
304306
} else {

apps/OpenSign/src/components/pdf/SignerListPlace.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function SignerListPlace(props) {
7171
<div className="signerList">
7272
<RecipientList {...props} />
7373
</div>
74-
{props.handleAddSigner && (
74+
{props.handleAddSigner ? (
7575
<div
7676
data-tut="reactourAddbtn"
7777
className="p-[10px] my-[2px] flex flex-row items-center justify-center border-[1px] border-[#47a3ad] hover:bg-[#47a3ad] text-[#47a3ad] hover:text-white cursor-pointer"
@@ -84,6 +84,19 @@ function SignerListPlace(props) {
8484
<i className="fa-solid fa-plus"></i>
8585
<span style={{ marginLeft: 2 }}>Add role</span>
8686
</div>
87+
) : (
88+
<div
89+
data-tut="reactourAddbtn"
90+
className="p-[10px] my-[2px] flex flex-row items-center justify-center border-[1px] border-[#47a3ad] hover:bg-[#47a3ad] text-[#47a3ad] hover:text-white cursor-pointer"
91+
onClick={() => props.setIsAddSigner(true)}
92+
style={{
93+
opacity: props.isMailSend && "0.5",
94+
pointerEvents: props.isMailSend && "none"
95+
}}
96+
>
97+
<i className="fa-solid fa-plus"></i>
98+
<span style={{ marginLeft: 2 }}>Add recipients</span>
99+
</div>
87100
)}
88101
</div>
89102
);

apps/OpenSign/src/components/pdf/WidgetComponent.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ function WidgetComponent({
3838
sendInOrder,
3939
isTemplateFlow,
4040
setBlockColor,
41-
blockColor
41+
blockColor,
42+
setIsAddSigner
4243
}) {
4344
const [isSignersModal, setIsSignersModal] = useState(false);
4445

@@ -319,7 +320,7 @@ function WidgetComponent({
319320
</span>
320321
</div>
321322
)}
322-
{handleAddSigner && (
323+
{handleAddSigner ? (
323324
<div
324325
data-tut="reactourAddbtn"
325326
style={{
@@ -333,6 +334,20 @@ function WidgetComponent({
333334
<i className="fa-solid fa-plus"></i>
334335
<span style={{ marginLeft: 2 }}>Add role</span>
335336
</div>
337+
) : (
338+
<div
339+
data-tut="reactourAddbtn"
340+
style={{
341+
margin: "5px 0 5px 0",
342+
backgroundColor: themeColor,
343+
color: "white"
344+
}}
345+
className="p-[10px] my-[2px] flex flex-row items-center justify-center border-[1px] border-[#47a3ad] hover:bg-[#47a3ad] text-[#47a3ad] hover:text-white cursor-pointer"
346+
onClick={() => setIsAddSigner(true)}
347+
>
348+
<i className="fa-solid fa-plus"></i>
349+
<span style={{ marginLeft: 2 }}>Add recipients</span>
350+
</div>
336351
)}
337352

338353
<div
@@ -391,7 +406,7 @@ function WidgetComponent({
391406
)}
392407
{isSignersModal && (
393408
<ModalUi
394-
title={"Roles"}
409+
title={title ? title : "Recipients"}
395410
isOpen={isSignersModal}
396411
handleClose={handleModal}
397412
>
@@ -424,7 +439,7 @@ function WidgetComponent({
424439
textAlign: "center"
425440
}}
426441
>
427-
Please add a role
442+
Please add a {title ? title : "recipients"}
428443
</div>
429444
)}
430445
</ModalUi>

apps/OpenSign/src/components/shared/fields/SelectSigners.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,22 @@ const SelectSigners = (props) => {
5353
const contactRes = await contactbook.find();
5454
if (contactRes) {
5555
const res = JSON.parse(JSON.stringify(contactRes));
56-
// console.log("userList ", res);
57-
setUserList(res);
58-
return await res.map((item) => ({
56+
//compareArrays is a function where compare between two array (total signersList and dcument signers list)
57+
//and filter signers from total signer's list which already present in document's signers list
58+
const compareArrays = (res, signerObj) => {
59+
return res.filter(
60+
(item1) =>
61+
!signerObj.find((item2) => item2.objectId === item1.objectId)
62+
);
63+
};
64+
65+
//get update signer's List if signersdata is present
66+
const updateSignersList =
67+
props?.signersData && compareArrays(res, props?.signersData);
68+
69+
const result = updateSignersList ? updateSignersList : res;
70+
setUserList(result);
71+
return await result.map((item) => ({
5972
label: item.Email,
6073
value: item.objectId
6174
}));

apps/OpenSign/src/pages/PdfRequestFiles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ function PdfRequestFiles() {
11731173
</ModalUi>
11741174
{/* this component used to render all pdf pages in left side */}
11751175
<RenderAllPdfPage
1176-
signPdfUrl={pdfDetails[0].URL}
1176+
signPdfUrl={pdfDetails[0] && pdfDetails[0].SignedUrl}
11771177
allPages={allPages}
11781178
setAllPages={setAllPages}
11791179
setPageNumber={setPageNumber}

apps/OpenSign/src/pages/PlaceHolderSign.js

Lines changed: 57 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function PlaceHolderSign() {
6868
const [isSendAlert, setIsSendAlert] = useState({});
6969
const [isSend, setIsSend] = useState(false);
7070
const [copied, setCopied] = useState(false);
71+
const [isAddSigner, setIsAddSigner] = useState(false);
7172
const [isLoading, setIsLoading] = useState({
7273
isLoad: true,
7374
message: "This might take some time"
@@ -350,15 +351,15 @@ function PlaceHolderSign() {
350351
const updatedSigners = documentData[0].Signers.map((x, index) => ({
351352
...x,
352353
Id: randomId(),
353-
Role: "User " + (index + 1),
354+
// Role: "User " + (index + 1),
354355
blockColor: color[index % color.length]
355356
}));
356357
setSignersData(updatedSigners);
357358
setUniqueId(updatedSigners[0].Id);
358359
setBlockColor(updatedSigners[0].blockColor);
359360
}
360361
} else {
361-
setRoleName("User 1");
362+
// setRoleName("User 1");
362363
if (
363364
documentData[0].Placeholders &&
364365
documentData[0].Placeholders.length > 0
@@ -1525,8 +1526,25 @@ function PlaceHolderSign() {
15251526
}
15261527
};
15271528

1529+
//function to add new signer in document signers list
1530+
const handleAddNewRecipients = (data) => {
1531+
const newId = randomId();
1532+
signersdata.push({
1533+
...data,
1534+
className: "contracts_Contactbook",
1535+
Id: newId,
1536+
blockColor: color[signersdata.length]
1537+
});
1538+
setUniqueId(newId);
1539+
setIsSelectId(signersdata.length - 1);
1540+
setBlockColor(color[signersdata.length]);
1541+
setContractName("contracts_Contactbook");
1542+
setSignerObjId(data.objectId);
1543+
};
1544+
15281545
const closePopup = () => {
15291546
setIsAddUser({});
1547+
setIsAddSigner(false);
15301548
};
15311549

15321550
//function for handle ontext change and save again text in delta in Request Email flow
@@ -1546,6 +1564,30 @@ function PlaceHolderSign() {
15461564
style: { fontSize: "13px" }
15471565
}
15481566
];
1567+
1568+
// `handleDeleteUser` function is used to delete record and placeholder when user click on delete which is place next user name in recipients list
1569+
const handleDeleteUser = (Id) => {
1570+
const updateSigner = signersdata
1571+
.filter((x) => x.Id !== Id)
1572+
.map((x, i) => ({ ...x, blockColor: color[i] }));
1573+
setSignersData(updateSigner);
1574+
const updatePlaceholderUser = signerPos
1575+
.filter((x) => x.Id !== Id)
1576+
.map((x, i) => ({ ...x, blockColor: color[i] }));
1577+
const index = signersdata.findIndex((x) => x.Id === Id);
1578+
if (index === signersdata.length - 1) {
1579+
setUniqueId(updateSigner[updateSigner.length - 1]?.Id || "");
1580+
setIsSelectId(index - 1 || 0);
1581+
setBlockColor(color[index - 1 || 0]);
1582+
} else {
1583+
setUniqueId(updateSigner[index]?.Id || "");
1584+
setIsSelectId(index);
1585+
setBlockColor(color[index]);
1586+
}
1587+
1588+
setSignerPos(updatePlaceholderUser);
1589+
setIsMailSend(false);
1590+
};
15491591
return (
15501592
<>
15511593
<Title title={state?.title ? state.title : "New Document"} />
@@ -1712,9 +1754,7 @@ function PlaceHolderSign() {
17121754
"cursor-pointer underline text-blue-700 focus:outline-none"
17131755
}
17141756
onClick={() => {
1715-
isSubscribe ||
1716-
(!isEnableSubscription &&
1717-
setIsCustomize(!isCustomize));
1757+
setIsCustomize(!isCustomize);
17181758
}}
17191759
>
17201760
Cutomize Email
@@ -1982,6 +2022,8 @@ function PlaceHolderSign() {
19822022
setSignersData={setSignersData}
19832023
blockColor={blockColor}
19842024
setBlockColor={setBlockColor}
2025+
setIsAddSigner={setIsAddSigner}
2026+
handleDeleteUser={handleDeleteUser}
19852027
/>
19862028
</div>
19872029
) : (
@@ -2007,6 +2049,9 @@ function PlaceHolderSign() {
20072049
blockColor={blockColor}
20082050
setBlockColor={setBlockColor}
20092051
isMailSend={isMailSend}
2052+
setIsAddSigner={setIsAddSigner}
2053+
handleDeleteUser={handleDeleteUser}
2054+
roleName={roleName}
20102055
// handleAddSigner={handleAddSigner}
20112056
/>
20122057
<div data-tut="reactourSecond">
@@ -2033,35 +2078,6 @@ function PlaceHolderSign() {
20332078
)}
20342079
</DndProvider>
20352080
<div>
2036-
{/* <ModalUi
2037-
headerColor={"#dc3545"}
2038-
isOpen={signerExistModal}
2039-
title={"Users required"}
2040-
handleClose={() => {
2041-
setSignerExistModal(false);
2042-
}}
2043-
>
2044-
<div style={{ height: "100%", padding: 20 }}>
2045-
<p>Please assign signers to all placeholders</p>
2046-
2047-
<div
2048-
style={{
2049-
height: "1px",
2050-
backgroundColor: "#9f9f9f",
2051-
width: "100%",
2052-
marginTop: "15px",
2053-
marginBottom: "15px"
2054-
}}
2055-
></div>
2056-
<button
2057-
onClick={() => setSignerExistModal(false)}
2058-
type="button"
2059-
className="finishBtn cancelBtn"
2060-
>
2061-
Close
2062-
</button>
2063-
</div>
2064-
</ModalUi> */}
20652081
<ModalUi
20662082
headerColor={"#dc3545"}
20672083
isOpen={isAlreadyPlace.status}
@@ -2095,6 +2111,13 @@ function PlaceHolderSign() {
20952111
isAddUser={isAddUser}
20962112
uniqueId={uniqueId}
20972113
closePopup={closePopup}
2114+
signersData={signersdata}
2115+
/>
2116+
<LinkUserModal
2117+
handleAddUser={handleAddNewRecipients}
2118+
isAddSigner={isAddSigner}
2119+
closePopup={closePopup}
2120+
signersData={signersdata}
20982121
/>
20992122
<WidgetNameModal
21002123
widgetName={widgetName}

apps/OpenSign/src/pages/SignyourselfPdf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,6 @@ function SignYourSelf() {
10011001
{/* this component used to render all pdf pages in left side */}
10021002

10031003
<RenderAllPdfPage
1004-
pdfUrl={pdfUrl}
10051004
signPdfUrl={pdfDetails[0] && pdfDetails[0].URL}
10061005
allPages={allPages}
10071006
setAllPages={setAllPages}

0 commit comments

Comments
 (0)