@@ -1255,13 +1255,14 @@ export const multiSignEmbed = async (
1255
1255
"email"
1256
1256
] . includes ( position . type ) ;
1257
1257
if ( position . type === "checkbox" ) {
1258
- let addYPosition , isCheck ;
1258
+ let addYPosition = 0 ,
1259
+ isCheck ;
1259
1260
1260
1261
if ( position ?. options ?. values . length > 0 ) {
1261
1262
position ?. options ?. values . forEach ( ( item , ind ) => {
1262
1263
const checkboxRandomId = "checkbox" + randomId ( ) ;
1263
1264
let yPosition ;
1264
- const height = 10 ;
1265
+ const height = 13 ;
1265
1266
if (
1266
1267
position ?. options ?. response &&
1267
1268
position ?. options ?. response ?. length > 0
@@ -1282,14 +1283,14 @@ export const multiSignEmbed = async (
1282
1283
if ( ! position ?. options ?. isHideLabel ) {
1283
1284
// below line of code is used to embed label with radio button in pdf
1284
1285
page . drawText ( item , {
1285
- x : xPos ( position ) + 15 ,
1286
+ x : xPos ( position ) + 17 ,
1286
1287
y : yPosition + 2 ,
1287
1288
size : height
1288
1289
} ) ;
1289
1290
}
1290
1291
checkbox . addToPage ( page , {
1291
1292
x : xPos ( position ) ,
1292
- y : yPosition ,
1293
+ y : yPosition - 3 ,
1293
1294
width : height ,
1294
1295
height : height
1295
1296
} ) ;
@@ -1702,3 +1703,66 @@ export const getYear = (date) => {
1702
1703
const newYear = new Date ( date ) . getFullYear ( ) ;
1703
1704
return newYear ;
1704
1705
} ;
1706
+
1707
+ //function to create/copy widget next to already dropped widget
1708
+ export const handleCopyNextToWidget = (
1709
+ position ,
1710
+ widgetType ,
1711
+ xyPostion ,
1712
+ index ,
1713
+ setXyPostion ,
1714
+ userId
1715
+ ) => {
1716
+ const isSigners = xyPostion . some ( ( data ) => data . signerPtr ) ;
1717
+ let filterSignerPos ;
1718
+ //get position of previous widget and create new widget next to that widget on same data except
1719
+ // xPosition and key
1720
+ let newpos = position ;
1721
+ const calculateXPosition =
1722
+ parseInt ( position . xPosition ) +
1723
+ defaultWidthHeight ( widgetType ) . width +
1724
+ resizeBorderExtraWidth ( ) ;
1725
+ const newId = randomId ( ) ;
1726
+ newpos = { ...newpos , xPosition : calculateXPosition , key : newId } ;
1727
+ //if condition to create widget in request-sign flow
1728
+ if ( isSigners ) {
1729
+ if ( userId ) {
1730
+ filterSignerPos = xyPostion . filter ( ( data ) => data . Id === userId ) ;
1731
+ }
1732
+ const getPlaceHolder = filterSignerPos [ 0 ] ?. placeHolder ;
1733
+ const getPageNumer = getPlaceHolder . filter (
1734
+ ( data ) => data . pageNumber === index
1735
+ ) ;
1736
+ const getXYdata = getPageNumer [ 0 ] . pos ;
1737
+ getXYdata . push ( newpos ) ;
1738
+ if ( getPageNumer . length > 0 ) {
1739
+ const newUpdateSignPos = getPlaceHolder . map ( ( obj ) => {
1740
+ if ( obj . pageNumber === index ) {
1741
+ return { ...obj , pos : getXYdata } ;
1742
+ }
1743
+ return obj ;
1744
+ } ) ;
1745
+
1746
+ const newUpdateSigner = xyPostion . map ( ( obj ) => {
1747
+ if ( obj . Id === userId ) {
1748
+ return { ...obj , placeHolder : newUpdateSignPos } ;
1749
+ }
1750
+ return obj ;
1751
+ } ) ;
1752
+
1753
+ setXyPostion ( newUpdateSigner ) ;
1754
+ }
1755
+ } else {
1756
+ // else condition to create widget in sign-yourself flow
1757
+ let getXYdata = xyPostion [ index ] . pos ;
1758
+ getXYdata . push ( newpos ) ;
1759
+ const updatePlaceholder = xyPostion . map ( ( obj , ind ) => {
1760
+ if ( ind === index ) {
1761
+ return { ...obj , pos : getXYdata } ;
1762
+ }
1763
+ return obj ;
1764
+ } ) ;
1765
+
1766
+ setXyPostion ( updatePlaceholder ) ;
1767
+ }
1768
+ } ;
0 commit comments