From c5c001f0307d667354912e3b7e279f4c24ef28be Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Fri, 8 Mar 2024 16:21:54 +0530 Subject: [PATCH 1/3] feat: year and month selection feature add on date widgets, wrong date embed on pdf issue fix --- .../src/components/pdf/Placeholder.js | 16 ++++++- .../src/components/pdf/PlaceholderType.js | 47 ++++++++++++++++++- apps/OpenSign/src/constant/Utils.js | 20 ++++++++ 3 files changed, 80 insertions(+), 3 deletions(-) diff --git a/apps/OpenSign/src/components/pdf/Placeholder.js b/apps/OpenSign/src/components/pdf/Placeholder.js index d1ec47e01..46e019a0c 100644 --- a/apps/OpenSign/src/components/pdf/Placeholder.js +++ b/apps/OpenSign/src/components/pdf/Placeholder.js @@ -54,7 +54,7 @@ function Placeholder(props) { useEffect(() => { //set default current date and default format MM/dd/yyyy - if (props.isPlaceholder || props.isSignYourself) { + if (props.isSignYourself) { const date = new Date(); const milliseconds = date.getTime(); const newDate = moment(milliseconds).format("MM/DD/YYYY"); @@ -63,6 +63,20 @@ function Placeholder(props) { 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 + }; + setSelectDate(dateObj); } // eslint-disable-next-line react-hooks/exhaustive-deps }, []); diff --git a/apps/OpenSign/src/components/pdf/PlaceholderType.js b/apps/OpenSign/src/components/pdf/PlaceholderType.js index 32ab4aa87..29c250458 100644 --- a/apps/OpenSign/src/components/pdf/PlaceholderType.js +++ b/apps/OpenSign/src/components/pdf/PlaceholderType.js @@ -1,5 +1,5 @@ import React, { useEffect, useState, forwardRef, useRef } from "react"; -import { onChangeInput } from "../../constant/Utils"; +import { getMonth, getYear, onChangeInput, range } from "../../constant/Utils"; import DatePicker from "react-datepicker"; import "react-datepicker/dist/react-datepicker.css"; import "../../styles/signature.css"; @@ -15,6 +15,21 @@ function PlaceholderType(props) { const inputRef = useRef(null); const [textValue, setTextValue] = useState(); const [selectedCheckbox, setSelectedCheckbox] = useState([]); + const years = range(1990, getYear(new Date()) + 16, 1); + const months = [ + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December" + ]; const validateExpression = (regexValidation) => { let regexObject = regexValidation; if (props.pos?.options.validation.type === "regex") { @@ -31,7 +46,6 @@ function PlaceholderType(props) { const handleInputBlur = () => { props.setDraggingEnabled(true); const validateType = props.pos?.options?.validation?.type; - let regexValidation; if (validateType) { switch (validateType) { @@ -293,6 +307,7 @@ function PlaceholderType(props) { isRadio ); }; + switch (type) { case "signature": return props.pos.SignUrl ? ( @@ -595,6 +610,34 @@ function PlaceholderType(props) { return (
( +
+ + +
+ )} disabled={ props.isNeedSign && props.data?.signerObjId !== props.signerObjId } diff --git a/apps/OpenSign/src/constant/Utils.js b/apps/OpenSign/src/constant/Utils.js index 3e320cd10..ceb828315 100644 --- a/apps/OpenSign/src/constant/Utils.js +++ b/apps/OpenSign/src/constant/Utils.js @@ -1517,3 +1517,23 @@ export const addDefaultSignatureImg = (xyPostion, defaultSignImg) => { } return xyDefaultPos; }; + +//function for create list of year for date widget +export const range = (start, end, step) => { + const range = []; + for (let i = start; i <= end; i += step) { + range.push(i); + } + return range; +}; +//function for get month +export const getMonth = (date) => { + const newMonth = new Date(date).getMonth(); + return newMonth; +}; + +//function for get year +export const getYear = (date) => { + const newYear = new Date(date).getFullYear(); + return newYear; +}; From cd2be94d29907a3de78c316d3d5c743b2d2a259d Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Fri, 8 Mar 2024 16:40:22 +0530 Subject: [PATCH 2/3] fix: change template react-tour message --- apps/OpenSign/src/components/pdf/Placeholder.js | 2 +- apps/OpenSign/src/pages/TemplatePlaceholder.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/OpenSign/src/components/pdf/Placeholder.js b/apps/OpenSign/src/components/pdf/Placeholder.js index 46e019a0c..8d3bb2510 100644 --- a/apps/OpenSign/src/components/pdf/Placeholder.js +++ b/apps/OpenSign/src/components/pdf/Placeholder.js @@ -74,7 +74,7 @@ function Placeholder(props) { const newDate = moment(milliseconds).format(dateFormat); const dateObj = { date: newDate, - format: props.pos?.options?.validation?.format + format: dateFormat }; setSelectDate(dateObj); } diff --git a/apps/OpenSign/src/pages/TemplatePlaceholder.js b/apps/OpenSign/src/pages/TemplatePlaceholder.js index 9237c3665..41b43ecbd 100644 --- a/apps/OpenSign/src/pages/TemplatePlaceholder.js +++ b/apps/OpenSign/src/pages/TemplatePlaceholder.js @@ -725,7 +725,7 @@ const TemplatePlaceholder = () => { selector: '[data-tut="reactourFirst"]', content: () => ( ), @@ -737,7 +737,7 @@ const TemplatePlaceholder = () => { selector: '[data-tut="reactourSecond"]', content: () => ( ), @@ -759,7 +759,7 @@ const TemplatePlaceholder = () => { selector: '[data-tut="reactourFour"]', content: () => ( ), From f4090c0c6128b5216c9bc60bc4dc9ebab5269d0a Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Fri, 8 Mar 2024 16:57:43 +0530 Subject: [PATCH 3/3] fix: label widgets hint, date default format issue --- apps/OpenSign/src/components/pdf/Placeholder.js | 4 +++- apps/OpenSign/src/components/pdf/PlaceholderType.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/OpenSign/src/components/pdf/Placeholder.js b/apps/OpenSign/src/components/pdf/Placeholder.js index 8d3bb2510..f21cb988f 100644 --- a/apps/OpenSign/src/components/pdf/Placeholder.js +++ b/apps/OpenSign/src/components/pdf/Placeholder.js @@ -74,7 +74,9 @@ function Placeholder(props) { const newDate = moment(milliseconds).format(dateFormat); const dateObj = { date: newDate, - format: dateFormat + format: props.pos?.options?.validation?.format + ? props.pos?.options?.validation?.format + : "MM/dd/YYYY" }; setSelectDate(dateObj); } diff --git a/apps/OpenSign/src/components/pdf/PlaceholderType.js b/apps/OpenSign/src/components/pdf/PlaceholderType.js index 29c250458..795d942bd 100644 --- a/apps/OpenSign/src/components/pdf/PlaceholderType.js +++ b/apps/OpenSign/src/components/pdf/PlaceholderType.js @@ -755,6 +755,7 @@ function PlaceholderType(props) { case "label": return (