From 5348c6620a452b6229f8580fd6d8aee2b1c83fb7 Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Fri, 8 Mar 2024 17:51:00 +0530 Subject: [PATCH 01/21] fix: signature widget setting icon for placed with old data --- apps/OpenSign/src/components/pdf/Placeholder.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/OpenSign/src/components/pdf/Placeholder.js b/apps/OpenSign/src/components/pdf/Placeholder.js index f21cb988f..ea8c155f4 100644 --- a/apps/OpenSign/src/components/pdf/Placeholder.js +++ b/apps/OpenSign/src/components/pdf/Placeholder.js @@ -237,10 +237,12 @@ function Placeholder(props) { }} > ) : ( - props.pos.type !== "date" && - props.pos.type !== "label" && - props.pos.type !== "signature" && - !props.isSignYourself && ( + ((!props?.pos?.type && props.pos.isStamp) || + (props?.pos?.type && + props?.pos?.type !== "date" && + props?.pos?.type !== "label" && + props?.pos?.type !== "signature" && + !props.isSignYourself)) && ( { e.stopPropagation(); From 885b5287b48824404aa68385abb1d6e3256311ad Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Fri, 8 Mar 2024 18:39:02 +0530 Subject: [PATCH 02/21] fix: condition of render setting icon for widgets --- apps/OpenSign/src/components/pdf/Placeholder.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/OpenSign/src/components/pdf/Placeholder.js b/apps/OpenSign/src/components/pdf/Placeholder.js index ea8c155f4..2bdf2ed6e 100644 --- a/apps/OpenSign/src/components/pdf/Placeholder.js +++ b/apps/OpenSign/src/components/pdf/Placeholder.js @@ -239,9 +239,7 @@ function Placeholder(props) { ) : ( ((!props?.pos?.type && props.pos.isStamp) || (props?.pos?.type && - props?.pos?.type !== "date" && - props?.pos?.type !== "label" && - props?.pos?.type !== "signature" && + !["date", "label", "signature"].includes(props.pos.type) && !props.isSignYourself)) && ( { From 0e5cffa1fa600fcf4530219d679a465f45cf4ccf Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Mon, 11 Mar 2024 16:59:10 +0530 Subject: [PATCH 03/21] fix: widgets issue after placing on multiple pages --- .../src/components/pdf/Placeholder.js | 97 +++++++++++-------- .../src/components/pdf/PlaceholderCopy.js | 14 ++- .../src/components/pdf/PlaceholderType.js | 41 +++++--- apps/OpenSign/src/components/pdf/RenderPdf.js | 8 +- apps/OpenSign/src/constant/Utils.js | 29 ++++-- apps/OpenSign/src/pages/PlaceHolderSign.js | 11 ++- 6 files changed, 129 insertions(+), 71 deletions(-) diff --git a/apps/OpenSign/src/components/pdf/Placeholder.js b/apps/OpenSign/src/components/pdf/Placeholder.js index 2bdf2ed6e..b5b524059 100644 --- a/apps/OpenSign/src/components/pdf/Placeholder.js +++ b/apps/OpenSign/src/components/pdf/Placeholder.js @@ -13,6 +13,8 @@ function Placeholder(props) { const [selectDate, setSelectDate] = useState(); const [dateFormat, setDateFormat] = useState([]); const [saveDateFormat, setSaveDateFormat] = useState(""); + + const [startDate, setStartDate] = useState(); const dateFormatArr = [ "L", "DD-MM-YYYY", @@ -52,36 +54,41 @@ function Placeholder(props) { } }; + //useEffect for to set date and date format for all flow (signyour-self, request-sign,placeholder,template) + //checking if already have data and set else set new date useEffect(() => { //set default current date and default format MM/dd/yyyy - if (props.isSignYourself) { - const date = new Date(); - const milliseconds = date.getTime(); - const newDate = moment(milliseconds).format("MM/DD/YYYY"); - const dateObj = { - date: newDate, - format: "MM/dd/YYYY" - }; - setSelectDate(dateObj); - } else { - const defaultRes = props?.pos?.options?.response; - const defaultFormat = props.pos?.options?.validation?.format; - const updateDate = defaultRes - ? new Date(props?.pos?.options?.response) - : new Date(); - const dateFormat = defaultFormat ? defaultFormat : "MM/DD/YYYY"; - const milliseconds = updateDate.getTime(); - const newDate = moment(milliseconds).format(dateFormat); - const dateObj = { - date: newDate, - format: props.pos?.options?.validation?.format - ? props.pos?.options?.validation?.format - : "MM/dd/YYYY" - }; - setSelectDate(dateObj); - } + // if (props.isSignYourself) { + // const date = new Date(); + // const milliseconds = date.getTime(); + // const newDate = moment(milliseconds).format("MM/DD/YYYY"); + // const dateObj = { + // date: newDate, + // format: "MM/dd/YYYY" + // }; + // setSelectDate(dateObj); + // } else { + const defaultRes = props?.pos?.options?.response; + + const defaultFormat = props.pos?.options?.validation?.format; + const updateDate = defaultRes + ? new Date(props?.pos?.options?.response) + : new Date(); + const dateFormat = defaultFormat ? defaultFormat : "MM/DD/YYYY"; + const milliseconds = updateDate.getTime(); + const newDate = moment(milliseconds).format(dateFormat); + const dateObj = { + date: newDate, + format: props.pos?.options?.validation?.format + ? props.pos?.options?.validation?.format + : "MM/dd/YYYY" + }; + setSelectDate(dateObj); + setStartDate(updateDate); + + // } // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + }, [props.index]); //function for add selected date and format in selectFormat const changeDateFormat = () => { @@ -206,13 +213,27 @@ function Placeholder(props) { props?.handleNameModal(true); } - if (props.isPlaceholder) { + if (props.isPlaceholder && props.type !== "label") { props.setUniqueId(props.data.Id); } props.setSignKey(props.pos.key); props.setWidgetType(props.pos.type); props.setCurrWidgetsDetails(props.pos); }; + const handleCopyPlaceholder = (e) => { + if (props.data && props?.pos?.type !== "label") { + props.setSignerObjId(props?.data?.signerObjId); + props.setUniqueId(props?.data?.Id); + } else if (props.data && props.pos.type === "label") { + props.setTempSignerId(props.uniqueId); + props.setSignerObjId(props?.data?.signerObjId); + props.setUniqueId(props?.data?.Id); + } + e.stopPropagation(); + props.setIsPageCopy(true); + props.setSignKey(props.pos.key); + }; + const PlaceholderIcon = () => { return ( props.isShowBorder && ( @@ -365,22 +386,10 @@ function Placeholder(props) { { - if (props.data) { - props.setSignerObjId(props.data.signerObjId); - props.setUniqueId(props.data.Id); - } - e.stopPropagation(); - props.setIsPageCopy(true); - props.setSignKey(props.pos.key); + handleCopyPlaceholder(e); }} onTouchEnd={(e) => { - if (props.data) { - props.setSignerObjId(props.data.signerObjId); - props.setUniqueId(props.data.Id); - } - e.stopPropagation(); - props.setIsPageCopy(true); - props.setSignKey(props.pos.key); + handleCopyPlaceholder(e); }} style={{ color: "#188ae2", @@ -618,6 +627,8 @@ function Placeholder(props) { setSaveDateFormat={setSaveDateFormat} saveDateFormat={saveDateFormat} setValidateAlert={props.setValidateAlert} + setStartDate={setStartDate} + startDate={startDate} /> ) : ( @@ -643,6 +654,8 @@ function Placeholder(props) { setSaveDateFormat={setSaveDateFormat} saveDateFormat={saveDateFormat} setValidateAlert={props.setValidateAlert} + setStartDate={setStartDate} + startDate={startDate} /> )} diff --git a/apps/OpenSign/src/components/pdf/PlaceholderCopy.js b/apps/OpenSign/src/components/pdf/PlaceholderCopy.js index 4ae92e18f..b57023bdf 100644 --- a/apps/OpenSign/src/components/pdf/PlaceholderCopy.js +++ b/apps/OpenSign/src/components/pdf/PlaceholderCopy.js @@ -180,7 +180,13 @@ function PlaceholderCopy(props) { copyPlaceholder("first"); } }; - + const handleUniqueId = () => { + if (props.widgetType === "label") { + props.setUniqueId(props?.tempSignerId); + props.setTempSignerId(""); + } + props.setIsPageCopy(false); + }; return ( { handleApplyCopy(); - props.setIsPageCopy(false); + handleUniqueId(); }} style={{ background: themeColor }} type="button" @@ -232,7 +238,9 @@ function PlaceholderCopy(props) { diff --git a/apps/OpenSign/src/components/pdf/PlaceholderType.js b/apps/OpenSign/src/components/pdf/PlaceholderType.js index 795d942bd..5dc0452d3 100644 --- a/apps/OpenSign/src/components/pdf/PlaceholderType.js +++ b/apps/OpenSign/src/components/pdf/PlaceholderType.js @@ -7,10 +7,8 @@ import RegexParser from "regex-parser"; function PlaceholderType(props) { const type = props?.pos?.type; - const [selectOption, setSelectOption] = useState( - props.pos?.options?.defaultValue ? props.pos?.options?.defaultValue : "" - ); - const [startDate, setStartDate] = useState(new Date()); + const [selectOption, setSelectOption] = useState(""); + const [validatePlaceholder, setValidatePlaceholder] = useState(""); const inputRef = useRef(null); const [textValue, setTextValue] = useState(); @@ -89,10 +87,7 @@ function PlaceholderType(props) { } useEffect(() => { - if (props.isNeedSign && type === "date") { - const updateDate = new Date(); - setStartDate(updateDate); - } else if (type && type === "checkbox" && props.isNeedSign) { + if (type && type === "checkbox" && props.isNeedSign) { const isDefaultValue = props.pos.options?.defaultValue; if (isDefaultValue) { setSelectedCheckbox(isDefaultValue); @@ -103,8 +98,20 @@ function PlaceholderType(props) { checkRegularExpress(props.pos?.options?.validation?.type); } setTextValue( - props.pos?.options?.defaultValue ? props.pos?.options?.defaultValue : "" + props.pos?.options?.response + ? props.pos?.options?.response + : props.pos?.options?.defaultValue + ? props.pos?.options?.defaultValue + : "" + ); + setSelectOption( + props.pos?.options?.response + ? props.pos?.options?.response + : props.pos?.options?.defaultValue + ? props.pos?.options?.defaultValue + : "" ); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -135,7 +142,7 @@ function PlaceholderType(props) { } } // const updateDate = new Date(props.saveDateFormat); - setStartDate(updateDate); + props.setStartDate(updateDate); const dateObj = { date: props.saveDateFormat, format: props.selectDate @@ -646,17 +653,23 @@ function PlaceholderType(props) { className="inputPlaceholder" style={{ outlineColor: "#007bff" }} selected={ - startDate - ? startDate + props?.startDate + ? props?.startDate : props.pos.options?.response && new Date(props.pos.options.response) } onChange={(date) => { - setStartDate(date); + props.setStartDate(date); }} popperPlacement="top-end" customInput={} dateFormat={ + // props.pos?.options?.validation?.format + // ? props.pos?.options?.validation?.format + // : props.selectDate + // ? props.selectDate?.format + // : "MM/dd/YYYY" + props.selectDate ? props.selectDate?.format : props.pos?.options?.validation?.format @@ -757,7 +770,9 @@ function PlaceholderType(props) {