mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-17 21:25:54 +02:00
fix: add copy option eside to widget for signature,stamp and text widgets
This commit is contained in:
@@ -369,7 +369,8 @@
|
||||
"copy-type": {
|
||||
"All pages": "All pages",
|
||||
"All pages but last": "All pages but last",
|
||||
"All pages but first": "All pages but first"
|
||||
"All pages but first": "All pages but first",
|
||||
"Beside to widget":"Beside to widget"
|
||||
},
|
||||
"options": "Options",
|
||||
"minimun-check": "Minimun check",
|
||||
|
||||
@@ -368,7 +368,8 @@
|
||||
"copy-type": {
|
||||
"All pages": "Toutes les pages",
|
||||
"All pages but last": "Toutes les pages sauf la dernière",
|
||||
"All pages but first": "Toutes les pages sauf la première"
|
||||
"All pages but first": "Toutes les pages sauf la première",
|
||||
"Beside to widget": "À côté du widget"
|
||||
},
|
||||
"options": "Possibilités",
|
||||
"minimun-check": "Vérification minimale",
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
import React, { useState } from "react";
|
||||
import ModalUi from "../../primitives/ModalUi";
|
||||
import { randomId, textWidget } from "../../constant/Utils";
|
||||
import {
|
||||
handleCopyNextToWidget,
|
||||
randomId,
|
||||
textWidget
|
||||
} from "../../constant/Utils";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
function PlaceholderCopy(props) {
|
||||
const { t } = useTranslation();
|
||||
const copyType = ["All pages", "All pages but last", "All pages but first"];
|
||||
const [selectCopyType, setSelectCopyType] = useState("");
|
||||
const copyType = [
|
||||
{ id: 1, type: "All pages" },
|
||||
{ id: 2, type: "All pages but last" },
|
||||
{ id: 3, type: "All pages but first" },
|
||||
{ id: 4, type: "Beside to widget" }
|
||||
];
|
||||
const [selectCopyType, setSelectCopyType] = useState(1);
|
||||
//function for get copy placeholder position
|
||||
const getCopyPlaceholderPosition = (
|
||||
type,
|
||||
@@ -20,7 +29,7 @@ function PlaceholderCopy(props) {
|
||||
(data) => data.xPosition !== currentPlaceholder.xPosition
|
||||
);
|
||||
//copy all page placeholder at requested position except first page
|
||||
if (newPageNumber === 1 && type === "first") {
|
||||
if (newPageNumber === 1 && type === 3) {
|
||||
if (filterPosition && filterPosition.length > 0) {
|
||||
return {
|
||||
pageNumber: newPageNumber,
|
||||
@@ -29,7 +38,7 @@ function PlaceholderCopy(props) {
|
||||
}
|
||||
}
|
||||
//copy all page placeholder at requested position except last page
|
||||
else if (newPageNumber === props.allPages && type === "last") {
|
||||
else if (newPageNumber === props.allPages && type === 2) {
|
||||
if (existPlaceholderPosition) {
|
||||
return {
|
||||
pageNumber: newPageNumber,
|
||||
@@ -172,20 +181,60 @@ function PlaceholderCopy(props) {
|
||||
|
||||
//function for getting selected type placeholder copy
|
||||
const handleApplyCopy = () => {
|
||||
if (selectCopyType === "All pages") {
|
||||
copyPlaceholder("all");
|
||||
} else if (selectCopyType === "All pages but last") {
|
||||
copyPlaceholder("last");
|
||||
} else if (selectCopyType === "All pages but first") {
|
||||
copyPlaceholder("first");
|
||||
if (selectCopyType === 4) {
|
||||
const signerPosition = props.xyPostion;
|
||||
let currentXYposition;
|
||||
const signerId = props.signerObjId ? props.signerObjId : props.Id;
|
||||
if (signerId) {
|
||||
const filterSignerPosition = signerPosition.filter(
|
||||
(item) => item?.Id === signerId
|
||||
);
|
||||
currentXYposition = filterSignerPosition[0].placeHolder.filter(
|
||||
(data) => data.pageNumber === props?.pageNumber
|
||||
);
|
||||
//get current placeholder position data which user want to copy
|
||||
currentXYposition = currentXYposition[0].pos.find(
|
||||
(position) => position.key === props.signKey
|
||||
);
|
||||
//function to create new widget next to just widget
|
||||
handleCopyNextToWidget(
|
||||
currentXYposition,
|
||||
props.widgetType,
|
||||
props.xyPostion,
|
||||
props.pageNumber,
|
||||
props.setXyPostion,
|
||||
props?.Id
|
||||
);
|
||||
} else {
|
||||
const getIndex = props?.xyPostion.findIndex(
|
||||
(data) => data.pageNumber === props.pageNumber
|
||||
);
|
||||
const placeholderPosition = props?.xyPostion[getIndex];
|
||||
//get current placeholder position data which user want to copy
|
||||
currentXYposition = placeholderPosition.pos.find(
|
||||
(pos) => pos.key === props.signKey
|
||||
);
|
||||
//function to create new widget next to just widget
|
||||
handleCopyNextToWidget(
|
||||
currentXYposition,
|
||||
props.widgetType,
|
||||
props.xyPostion,
|
||||
getIndex,
|
||||
props.setXyPostion
|
||||
);
|
||||
}
|
||||
} else {
|
||||
copyPlaceholder(selectCopyType);
|
||||
}
|
||||
};
|
||||
const handleUniqueId = () => {
|
||||
if (props.widgetType === textWidget) {
|
||||
const signerId = props.signerObjId ? props.signerObjId : props.Id;
|
||||
if (signerId && props.widgetType === textWidget) {
|
||||
props.setUniqueId(props?.tempSignerId);
|
||||
props.setTempSignerId("");
|
||||
}
|
||||
props.setIsPageCopy(false);
|
||||
setSelectCopyType(1);
|
||||
};
|
||||
return (
|
||||
<ModalUi
|
||||
@@ -201,11 +250,11 @@ function PlaceholderCopy(props) {
|
||||
<input
|
||||
className="mr-[8px] op-radio op-radio-xs"
|
||||
type="radio"
|
||||
value={data}
|
||||
onChange={() => setSelectCopyType(data)}
|
||||
checked={selectCopyType === data}
|
||||
value={data.id}
|
||||
onChange={() => setSelectCopyType(data.id)}
|
||||
checked={selectCopyType === data.id}
|
||||
/>
|
||||
{t(`copy-type.${data}`)}
|
||||
{t(`copy-type.${data.type}`)}
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -872,7 +872,6 @@ export const onChangeInput = (
|
||||
}
|
||||
} else {
|
||||
let getXYdata = xyPostion[index].pos;
|
||||
|
||||
const updatePosition = getXYdata.map((positionData) => {
|
||||
if (positionData.key === signKey) {
|
||||
if (dateFormat) {
|
||||
@@ -1859,29 +1858,26 @@ export const handleCopyNextToWidget = (
|
||||
setXyPostion,
|
||||
userId
|
||||
) => {
|
||||
const isSigners = xyPostion.some((data) => data.signerPtr);
|
||||
let filterSignerPos;
|
||||
//get position of previous widget and create new widget next to that widget on same data except
|
||||
// xPosition and key
|
||||
let newpos = position;
|
||||
let newposition = position;
|
||||
const calculateXPosition =
|
||||
parseInt(position.xPosition) +
|
||||
defaultWidthHeight(widgetType).width +
|
||||
resizeBorderExtraWidth();
|
||||
const newId = randomId();
|
||||
newpos = { ...newpos, xPosition: calculateXPosition, key: newId };
|
||||
newposition = { ...newposition, xPosition: calculateXPosition, key: newId };
|
||||
//if condition to create widget in request-sign flow
|
||||
if (isSigners) {
|
||||
if (userId) {
|
||||
filterSignerPos = xyPostion.filter((data) => data.Id === userId);
|
||||
}
|
||||
const getPlaceHolder = filterSignerPos[0]?.placeHolder;
|
||||
const getPageNumer = getPlaceHolder.filter(
|
||||
if (userId) {
|
||||
filterSignerPos = xyPostion.filter((data) => data.Id === userId);
|
||||
const getPlaceHolder = filterSignerPos && filterSignerPos[0]?.placeHolder;
|
||||
const getPageNumer = getPlaceHolder?.filter(
|
||||
(data) => data.pageNumber === index
|
||||
);
|
||||
const getXYdata = getPageNumer[0].pos;
|
||||
getXYdata.push(newpos);
|
||||
if (getPageNumer.length > 0) {
|
||||
const getXYdata = getPageNumer && getPageNumer[0]?.pos;
|
||||
getXYdata.push(newposition);
|
||||
if (getPageNumer && getPageNumer.length > 0) {
|
||||
const newUpdateSignPos = getPlaceHolder.map((obj) => {
|
||||
if (obj.pageNumber === index) {
|
||||
return { ...obj, pos: getXYdata };
|
||||
@@ -1899,9 +1895,8 @@ export const handleCopyNextToWidget = (
|
||||
setXyPostion(newUpdateSigner);
|
||||
}
|
||||
} else {
|
||||
// else condition to create widget in sign-yourself flow
|
||||
let getXYdata = xyPostion[index].pos;
|
||||
getXYdata.push(newpos);
|
||||
let getXYdata = xyPostion[index]?.pos || [];
|
||||
getXYdata.push(newposition);
|
||||
const updatePlaceholder = xyPostion.map((obj, ind) => {
|
||||
if (ind === index) {
|
||||
return { ...obj, pos: getXYdata };
|
||||
|
||||
@@ -1333,6 +1333,7 @@ function SignYourSelf() {
|
||||
allPages={allPages}
|
||||
pageNumber={pageNumber}
|
||||
signKey={signKey}
|
||||
widgetType={widgetType}
|
||||
/>
|
||||
{/* this is modal of signature pad */}
|
||||
<SignPad
|
||||
|
||||
Reference in New Issue
Block a user