)}
- {/* this component used to render all pdf pages in left side */}
+
+ {/* this component used for UI interaction and show their functionality */}
+ {pdfLoadFail && !checkTourStatus && (
+
+ )}
-
+ {/* this component used to render all pdf pages in left side */}
- {/* pdf render view */}
-
500 && "20px",
- marginRight: !isMobile && pdfOriginalWidth > 500 && "20px"
- }}
- >
-
{
- setIsAlert({
- isShow: false,
- alertMessage: ""
- });
+
+
+ {/* pdf render view */}
+ 500 && "20px",
+ marginRight: !isMobile && pdfOriginalWidth > 500 && "20px"
}}
>
-
-
{isAlert.alertMessage}
+
{
+ setIsAlert({
+ isShow: false,
+ alertMessage: ""
+ });
+ }}
+ >
+
+
{isAlert.alertMessage}
-
-
{
- setIsAlert({
- isShow: false,
- alertMessage: ""
- });
- }}
- type="button"
- className="finishBtn cancelBtn"
- >
- Ok
-
+
+
{
+ setIsAlert({
+ isShow: false,
+ alertMessage: ""
+ });
+ }}
+ type="button"
+ className="finishBtn cancelBtn"
+ >
+ Ok
+
+
+
+
+ {/* this modal is used show this document is already sign */}
+
{
+ setShowAlreadySignDoc({ status: false });
+ }}
+ >
+
+
{showAlreadySignDoc.mssg}
+
+
+
setShowAlreadySignDoc({ status: false })}
+ >
+ Close
+
+
+
+
+
+ {/* this is modal of signature pad */}
+
+ {/* render email component to send email after finish signature on document */}
+
+ {/* pdf header which contain funish back button */}
+
+
+
+ {containerWH && (
+
+ )}
-
+
- {/* this modal is used show this document is already sign */}
-
{
- setShowAlreadySignDoc({ status: false });
- }}
+ {/*if document is not completed then render signature and stamp button in the right side */}
+ {/*else document is completed then render signed by signer name in the right side */}
+
-
-
{showAlreadySignDoc.mssg}
-
-
-
setShowAlreadySignDoc({ status: false })}
- >
- Close
-
-
-
-
-
- {/* this is modal of signature pad */}
-
- {/* render email component to send email after finish signature on document */}
-
- {/* pdf header which contain funish back button */}
-
-
-
- {containerWH && (
-
+ {!documentStatus.isCompleted ? (
+
+
+
+ ) : (
+
+
+
)}
-
- {/*if document is not completed then render signature and stamp button in the right side */}
- {/*else document is completed then render signed by signer name in the right side */}
-
- {!documentStatus.isCompleted ? (
-
-
-
- ) : (
-
-
-
- )}
-
)}
diff --git a/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js b/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js
index c525d23cb..e72f6d36f 100644
--- a/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js
+++ b/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js
@@ -348,6 +348,154 @@ const TemplatePlaceholder = () => {
getSignerPos(item, monitor);
};
+ const addWidgetOptions = (type) => {
+ let option = {};
+
+ switch (type) {
+ case "signature":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+
+ case "stamp":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+
+ case "checkbox":
+ option = {
+ name: "",
+ values: [],
+ status: "Optional",
+ response: false,
+ validation: {}
+ };
+ return option;
+ case "text":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+
+ case "initials":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+ case "name":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {
+ type: "text",
+ pattern: ""
+ }
+ };
+ return option;
+
+ case "company":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {
+ type: "text",
+ pattern: ""
+ }
+ };
+ return option;
+ case "job title":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {
+ type: "text",
+ pattern: ""
+ }
+ };
+ return option;
+ case "date":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: getDate()
+ };
+ return option;
+ case "image":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+ case "email":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {
+ type: "email",
+ pattern: ""
+ }
+ };
+ return option;
+ case "dropdown":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+ case "radio":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+ case "label":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+ }
+ };
+
// `getSignerPos` is used to get placeholder position when user place it and save it in array
const getSignerPos = (item, monitor) => {
if (uniqueId) {
@@ -373,18 +521,11 @@ const TemplatePlaceholder = () => {
isStamp:
(dragTypeValue === "stamp" || dragTypeValue === "image") && true,
key: key,
- isDrag: false,
scale: scale,
isMobile: isMobile,
- yBottom: window.innerHeight / 2 - 60,
zIndex: posZIndex,
type: dragTypeValue,
- widgetValue:
- dragTypeValue === "checkbox"
- ? false
- : dragTypeValue === "date"
- ? getDate()
- : ""
+ options: addWidgetOptions(dragTypeValue)
};
dropData.push(dropObj);
placeHolder = {
@@ -407,20 +548,11 @@ const TemplatePlaceholder = () => {
isStamp:
(dragTypeValue === "stamp" || dragTypeValue === "image") && true,
key: key,
- isDrag: false,
- firstXPos: signBtnPosition[0] && signBtnPosition[0].xPos,
- firstYPos: signBtnPosition[0] && signBtnPosition[0].yPos,
- yBottom: ybottom,
scale: scale,
isMobile: isMobile,
zIndex: posZIndex,
type: item.text,
- widgetValue:
- dragTypeValue === "checkbox"
- ? false
- : dragTypeValue === "date"
- ? getDate()
- : ""
+ options: addWidgetOptions(dragTypeValue)
};
dropData.push(dropObj);
@@ -1013,6 +1145,8 @@ const TemplatePlaceholder = () => {
//function for base on condition to add checkbox widget status and input text validation in signerPos array
const handleApplyWidgetsStatus = (textValidate) => {
+ const options = ["email", "number", "text"];
+ const regexType = options.includes(textValidate);
let regularExpression = textValidate;
const filterSignerPos = signerPos.filter((data) => data.Id === uniqueId);
if (filterSignerPos.length > 0) {
@@ -1032,19 +1166,32 @@ const TemplatePlaceholder = () => {
if (selectRequiredType === "Read only") {
return {
...position,
- widgetStatus: selectRequiredType,
- widgetValue: true
+ options: {
+ ...position.options,
+ status: selectRequiredType,
+ response: true
+ }
};
} else {
return {
...position,
- widgetStatus: selectRequiredType
+ options: {
+ ...position.options,
+ status: selectRequiredType,
+ response: false
+ }
};
}
} else {
return {
...position,
- validation: regularExpression
+ options: {
+ ...position.options,
+ validation: {
+ type: regexType ? regularExpression : "regex",
+ pattern: !regexType ? regularExpression : ""
+ }
+ }
};
}
}
@@ -1111,15 +1258,21 @@ const TemplatePlaceholder = () => {
} else {
return {
...position,
- widgetName: dropdownName,
- widgetOption: dropdownOptions
+ options: {
+ ...position.options,
+ name: dropdownName,
+ values: dropdownOptions
+ }
};
}
} else {
return {
...position,
- widgetName: dropdownName,
- widgetOption: dropdownOptions
+ options: {
+ ...position.options,
+ name: dropdownName,
+ values: dropdownOptions
+ }
};
}
}
diff --git a/microfrontends/SignDocuments/src/Component/WidgetComponent/checkboxStatus.js b/microfrontends/SignDocuments/src/Component/WidgetComponent/checkboxStatus.js
index d2946dbc8..f8630ae87 100644
--- a/microfrontends/SignDocuments/src/Component/WidgetComponent/checkboxStatus.js
+++ b/microfrontends/SignDocuments/src/Component/WidgetComponent/checkboxStatus.js
@@ -6,8 +6,8 @@ function CheckboxStatus(props) {
const checkboxType = ["Optional", "Required", "Read only"];
useEffect(() => {
- if (props.currWidgetsDetails?.widgetStatus) {
- props.setSelectRequiredType(props.currWidgetsDetails?.widgetStatus);
+ if (props.currWidgetsDetails?.options?.status) {
+ props.setSelectRequiredType(props.currWidgetsDetails?.options?.status);
}
}, [props.currWidgetsDetails]);
@@ -53,7 +53,7 @@ function CheckboxStatus(props) {
>
Apply
- {props.currWidgetsDetails?.widgetStatus && (
+ {props.currWidgetsDetails?.options?.status && (
{
if (
- props.currWidgetsDetails?.widgetName &&
- props.currWidgetsDetails?.widgetOption
+ props.currWidgetsDetails?.options?.name &&
+ props.currWidgetsDetails?.options?.values
) {
- setDropdownName(props.currWidgetsDetails?.widgetName);
- setDropdownOptionList(props.currWidgetsDetails?.widgetOption);
+ setDropdownName(props.currWidgetsDetails?.options?.name);
+ setDropdownOptionList(props.currWidgetsDetails?.options?.values);
}
}, [props.currWidgetsDetails]);
@@ -149,7 +149,7 @@ function DropdownWidgetOption(props) {
>
Save
- {props.currWidgetsDetails?.widgetOption?.length > 0 && (
+ {props.currWidgetsDetails?.options?.values?.length > 0 && (
{
setIsShowDateFormat(!isShowDateFormat);
e.stopPropagation();
- props.setSignKey(props.pos.key);
- props.setUniqueId(props.data.Id);
+ if (props.data) {
+ props.setSignKey(props.pos.key);
+ props.setUniqueId(props.data.Id);
+ }
}}
onTouchEnd={(e) => {
e.stopPropagation();
setIsShowDateFormat(!isShowDateFormat);
- props.setSignKey(props.pos.key);
- props.setUniqueId(props.data.Id);
+ if (props.data) {
+ props.setSignKey(props.pos.key);
+ props.setUniqueId(props.data.Id);
+ }
}}
>
{
const regexObject = new RegExp(regexValidation);
- let isValidate = regexObject.test(inputValue);
+
+ let isValidate = regexObject.test(textValue);
if (!isValidate) {
props.setValidateAlert(true);
inputRef.current.focus();
@@ -29,9 +29,10 @@ function PlaceholderType(props) {
const handleInputBlur = () => {
props.setDraggingEnabled(true);
- const validateType = props.pos?.validation;
+ const validateType = props.pos?.options.validation.type;
+
let regexValidation;
- if (props.pos?.validation) {
+ if (validateType) {
switch (validateType) {
case "email":
regexValidation = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
@@ -46,7 +47,7 @@ function PlaceholderType(props) {
validateExpression(regexValidation);
break;
default:
- regexValidation = validateType;
+ regexValidation = props.pos?.options.validation.pattern;
validateExpression(regexValidation);
}
}
@@ -54,8 +55,16 @@ function PlaceholderType(props) {
const handleTextValid = (e, regx) => {
const textInput = e.target.value;
- const sanitizedValue = textInput.replace(regx, "");
- setTextValue(sanitizedValue);
+ setTextValue(textInput);
+ // console.log('textInput',textInput)
+ // let isValidate = regx.test(textValue);
+ // console.log('isValidate',isValidate,regx)
+ // if (isValidate) {
+ // const sanitizedValue = textInput.replace(regx, "");
+ // setTextValue(sanitizedValue);
+ // } else {
+ // setTextValue('');
+ // }
};
function checkRegularExpress(validateType) {
switch (validateType) {
@@ -72,14 +81,13 @@ function PlaceholderType(props) {
}
}
useEffect(() => {
- if (props.pos.validation) {
- checkRegularExpress(props.pos.validation);
+ if (props.pos?.options?.validation?.type) {
+ checkRegularExpress(props.pos?.options?.validation?.type);
}
}, []);
useEffect(() => {
if (props.isNeedSign && props.pos.type === "date") {
- // props.pos.widgetValue
const updateDate = new Date();
setStartDate(updateDate);
}
@@ -107,8 +115,8 @@ function PlaceholderType(props) {
date: props.saveDateFormat,
format: props.selectDate
? props.selectDate?.format
- : props.pos?.dateFormat
- ? props.pos?.dateFormat
+ : props.pos?.options?.validation?.format
+ ? props.pos?.options?.validation?.format
: "MM/dd/YYYY"
};
props.setSelectDate(dateObj);
@@ -124,8 +132,8 @@ function PlaceholderType(props) {
false,
props.selectDate?.format
? props.selectDate.format
- : props.pos?.dateFormat
- ? props.pos?.dateFormat
+ : props.pos?.options?.validation?.format
+ ? props.pos?.options?.validation?.format
: "MM/dd/YYYY"
);
}
@@ -174,7 +182,7 @@ function PlaceholderType(props) {
const handleChecked = () => {
if (props.isPlaceholder) {
- if (props.pos?.widgetStatus === "Read only") {
+ if (props.pos?.options?.status === "Read only") {
if (checkedValue) {
return checkedValue;
} else {
@@ -189,7 +197,7 @@ function PlaceholderType(props) {
}
}
} else {
- return props.pos?.widgetValue;
+ return props.pos?.options?.response;
}
};
@@ -253,12 +261,12 @@ function PlaceholderType(props) {
className="inputPlaceholder"
style={{ outlineColor: "#007bff" }}
type="checkbox"
- defaultChecked={props.pos?.widgetStatus === "Read only"}
+ defaultChecked={props.pos?.options?.status === "Read only"}
disabled={
props.isNeedSign && props.data?.signerObjId !== props.signerObjId
? true
: props.isNeedSign &&
- props.pos?.widgetStatus === "Read only" &&
+ props.pos?.options?.status === "Read only" &&
true
// : props.isPlaceholder
}
@@ -267,7 +275,7 @@ function PlaceholderType(props) {
onChange={(e) => {
let isChecked = e.target.checked;
if (props.isPlaceholder) {
- if (props.pos.widgetStatus === "Read only") {
+ if (props.pos?.options?.status === "Read only") {
setCheckedValue(true);
isChecked = true;
} else {
@@ -297,9 +305,11 @@ function PlaceholderType(props) {
placeholder={validatePlaceholder}
style={{ fontSize: calculateFontSize() }}
value={
- textValue
+ props.pos?.options?.validation
? textValue
- : props.pos.widgetValue && props.pos.widgetValue
+ ? textValue
+ : props.pos.options?.response && props.pos.options.response
+ : textValue
}
type="text"
tabIndex="0"
@@ -311,7 +321,10 @@ function PlaceholderType(props) {
onBlur={handleInputBlur}
onChange={(e) => {
// props.pos?.validation && handleTextValid(e, props.pos?.validation);
- setInputValue(e.target.value);
+ // if (!props.pos.options?.validation) {
+ // setTextValue(e.target.value);
+ // }
+ setTextValue(e.target.value);
onChangeInput(
e.target.value,
props.pos.key,
@@ -338,6 +351,7 @@ function PlaceholderType(props) {
{
setSelectOption(e.target.value);
@@ -354,11 +368,15 @@ function PlaceholderType(props) {
>
{/* Default/Title option */}
- {props.pos.widgetName}
+ {props.pos.options.name}
- {props.pos.widgetOption.map((data, ind) => {
- return {data} ;
+ {props.pos?.options?.values.map((data, ind) => {
+ return (
+
+ {data}
+
+ );
})}
) : (
@@ -366,7 +384,7 @@ function PlaceholderType(props) {
className="inputPlaceholder"
style={{ fontSize: calculateFontSize() }}
>
- {props.pos.widgetName ? props.pos.widgetName : props.pos.type}
+ {props.pos?.options?.name ? props.pos.options.name : props.pos.type}
);
case "initials":
@@ -402,13 +420,13 @@ function PlaceholderType(props) {
tabIndex="0"
ref={inputRef}
placeholder={"name"}
- style={{ fontSize: calculateFontSize(), textAlign: "center" }}
+ style={{ fontSize: calculateFontSize() }}
className="inputPlaceholder"
type="text"
value={
textValue
? textValue
- : props.pos.widgetValue && props.pos.widgetValue
+ : props.pos.options.response && props.pos.options.response
}
onBlur={handleInputBlur}
onChange={(e) => {
@@ -447,7 +465,7 @@ function PlaceholderType(props) {
value={
textValue
? textValue
- : props.pos.widgetValue && props.pos.widgetValue
+ : props.pos.options.response && props.pos.options.response
}
onBlur={handleInputBlur}
onChange={(e) => {
@@ -486,7 +504,7 @@ function PlaceholderType(props) {
value={
textValue
? textValue
- : props.pos.widgetValue && props.pos.widgetValue
+ : props.pos.options.response && props.pos.options.response
}
onBlur={handleInputBlur}
onChange={(e) => {
@@ -519,16 +537,15 @@ function PlaceholderType(props) {
disabled={
props.isNeedSign && props.data?.signerObjId !== props.signerObjId
}
- // disabled={props.isPlaceholder ? true : false}
onBlur={handleInputBlur}
closeOnScroll={true}
className="inputPlaceholder"
style={{ outlineColor: "#007bff" }}
selected={
- // props.pos?.widgetValue ? props.pos.widgetValue :
startDate
? startDate
- : props.pos?.widgetValue && new Date(props.pos.widgetValue)
+ : props.pos.options?.response &&
+ new Date(props.pos.options.response)
}
onChange={(date) => {
setStartDate(date);
@@ -538,8 +555,8 @@ function PlaceholderType(props) {
dateFormat={
props.selectDate
? props.selectDate?.format
- : props.pos?.dateFormat
- ? props.pos?.dateFormat
+ : props.pos?.options?.validation?.format
+ ? props.pos?.options?.validation?.format
: "dd MMMM, YYYY"
}
/>
@@ -583,11 +600,14 @@ function PlaceholderType(props) {
value={
textValue
? textValue
- : props.pos.widgetValue && props.pos.widgetValue
+ : props.pos.options?.response && props.pos.options.response
}
onBlur={handleInputBlur}
onChange={(e) => {
- handleTextValid(e, /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$/);
+ handleTextValid(
+ e,
+ /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
+ );
onChangeInput(
e.target.value,
props.pos.key,
@@ -612,13 +632,12 @@ function PlaceholderType(props) {
case "radio":
return (
- {props.pos?.widgetOption?.map((data, ind) => {
+ {props.pos.options?.values.map((data, ind) => {
return (
{
+ let option = {};
+
+ switch (type) {
+ case "signature":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+
+ case "stamp":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+
+ case "checkbox":
+ option = {
+ name: "",
+ values: [],
+ status: "Optional",
+ response: false,
+ validation: {}
+ };
+ return option;
+ case "text":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+
+ case "initials":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+ case "name":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {
+ type: "text",
+ pattern: ""
+ }
+ };
+ return option;
+
+ case "company":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {
+ type: "text",
+ pattern: ""
+ }
+ };
+ return option;
+ case "job title":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {
+ type: "text",
+ pattern: ""
+ }
+ };
+ return option;
+ case "date":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: getDate()
+ };
+ return option;
+ case "image":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+ case "email":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {
+ type: "email",
+ pattern: ""
+ }
+ };
+ return option;
+ case "dropdown":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+ case "radio":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+ case "label":
+ option = {
+ name: "",
+ values: [],
+ status: "",
+ response: "",
+ validation: {}
+ };
+ return option;
+ }
+ };
//function for setting position after drop signature button over pdf
const addPositionOfSignature = (item, monitor) => {
getSignerPos(item, monitor);
};
-
const getSignerPos = (item, monitor) => {
// setSignerObjId("");
// setContractName("");
@@ -351,15 +497,9 @@ function PlaceHolderSign() {
isDrag: false,
scale: scale,
isMobile: isMobile,
- yBottom: window.innerHeight / 2 - 60,
zIndex: posZIndex,
type: dragTypeValue,
- widgetValue:
- dragTypeValue === "checkbox"
- ? false
- : dragTypeValue === "date"
- ? getDate()
- : ""
+ options: addWidgetOptions(dragTypeValue)
};
dropData.push(dropObj);
placeHolder = {
@@ -374,28 +514,17 @@ function PlaceHolderSign() {
.getBoundingClientRect();
const x = offset.x - containerRect.left;
const y = offset.y - containerRect.top;
- const ybottom = containerRect.bottom - offset.y;
-
const dropObj = {
xPosition: signBtnPosition[0] ? x - signBtnPosition[0].xPos : x,
yPosition: signBtnPosition[0] ? y - signBtnPosition[0].yPos : y,
isStamp:
(dragTypeValue === "stamp" || dragTypeValue === "image") && true,
key: key,
- isDrag: false,
- firstXPos: signBtnPosition[0] && signBtnPosition[0].xPos,
- firstYPos: signBtnPosition[0] && signBtnPosition[0].yPos,
- yBottom: ybottom,
scale: scale,
isMobile: isMobile,
zIndex: posZIndex,
type: dragTypeValue,
- widgetValue:
- dragTypeValue === "checkbox"
- ? false
- : dragTypeValue === "date"
- ? getDate()
- : ""
+ options: addWidgetOptions(dragTypeValue)
};
dropData.push(dropObj);
@@ -538,7 +667,6 @@ function PlaceHolderSign() {
//function for set and update x and y postion after drag and drop signature tab
const handleStop = (event, dragElement, signerId, key) => {
- console.log("handle stop");
if (!isResize && isDragging) {
const dataNewPlace = addZIndex(signerPos, key, setZIndex);
let updateSignPos = [...signerPos];
@@ -647,7 +775,6 @@ function PlaceHolderSign() {
}
return obj;
});
- console.log("signerpos3");
setSignerPos(newUpdateSigner);
} else {
const updateFilter = signerPos.filter((data) => data.Id !== Id);
@@ -988,13 +1115,12 @@ function PlaceHolderSign() {
const getXYdata = getPageNumer[0].pos;
const getPosData = getXYdata;
- const addSignPos = getPosData.map((position, ind) => {
+ const addSignPos = getPosData.map((position) => {
if (position.key === signKey) {
if (widgetType === "radio") {
if (addOption) {
return {
...position,
-
Height: position.Height
? position.Height + 15
: defaultWidthHeight(widgetType).height + 15
@@ -1009,15 +1135,21 @@ function PlaceHolderSign() {
} else {
return {
...position,
- widgetName: dropdownName,
- widgetOption: dropdownOptions
+ options: {
+ ...position.options,
+ name: dropdownName,
+ values: dropdownOptions
+ }
};
}
} else {
return {
...position,
- widgetName: dropdownName,
- widgetOption: dropdownOptions
+ options: {
+ ...position.options,
+ name: dropdownName,
+ values: dropdownOptions
+ }
};
}
}
@@ -1138,6 +1270,8 @@ function PlaceHolderSign() {
//function for base on condition to add checkbox widget status and input text validation in signerPos array
const handleApplyWidgetsStatus = (textValidate) => {
+ const options = ["email", "number", "text"];
+ const regexType = options.includes(textValidate);
let regularExpression = textValidate;
const filterSignerPos = signerPos.filter((data) => data.Id === uniqueId);
@@ -1158,19 +1292,32 @@ function PlaceHolderSign() {
if (selectRequiredType === "Read only") {
return {
...position,
- widgetStatus: selectRequiredType,
- widgetValue: true
+ options: {
+ ...position.options,
+ status: selectRequiredType,
+ response: true
+ }
};
} else {
return {
...position,
- widgetStatus: selectRequiredType
+ options: {
+ ...position.options,
+ status: selectRequiredType,
+ response: false
+ }
};
}
} else {
return {
...position,
- validation: regularExpression
+ options: {
+ ...position.options,
+ validation: {
+ type: regexType ? regularExpression : "regex",
+ pattern: !regexType ? regularExpression : ""
+ }
+ }
};
}
}
diff --git a/microfrontends/SignDocuments/src/utils/Utils.js b/microfrontends/SignDocuments/src/utils/Utils.js
index 37a20258b..425745505 100644
--- a/microfrontends/SignDocuments/src/utils/Utils.js
+++ b/microfrontends/SignDocuments/src/utils/Utils.js
@@ -67,7 +67,10 @@ export const addInitialData = (signerPos, setXyPostion, value, userId) => {
) {
return {
...item,
- widgetValue: widgetData,
+ options: {
+ ...item.options,
+ response: widgetData
+ },
Width: calculateInitialWidthHeight(item.type, widgetData).getWidth,
Height: calculateInitialWidthHeight(item.type, widgetData).getHeight
};
@@ -109,22 +112,32 @@ export const onChangeInput = (
if (getPageNumer.length > 0) {
const getXYdata = getPageNumer[0].pos;
const getPosData = getXYdata;
- const addSignPos = getPosData.map((url, ind) => {
- if (url.key === signKey) {
+ const addSignPos = getPosData.map((position, ind) => {
+ if (position.key === signKey) {
if (dateFormat) {
return {
- ...url,
- widgetValue: value,
- dateFormat: dateFormat
+ ...position,
+ options: {
+ ...position.options,
+ response: value,
+ validation: {
+ type: "date-format",
+ format: dateFormat // This indicates the required date format explicitly.
+ }
+ }
};
} else {
return {
- ...url,
- widgetValue: value
+ ...position,
+
+ options: {
+ ...position.options,
+ response: value
+ }
};
}
}
- return url;
+ return position;
});
const newUpdateSignPos = getPlaceHolder.map((obj) => {
@@ -147,11 +160,14 @@ export const onChangeInput = (
} else {
let getXYdata = xyPostion[index].pos;
- const updatePosition = getXYdata.map((positionData, ind) => {
+ const updatePosition = getXYdata.map((positionData) => {
if (positionData.key === signKey) {
return {
...positionData,
- widgetValue: value
+ options: {
+ ...positionData.options,
+ response: value
+ }
};
}
return positionData;
@@ -493,7 +509,11 @@ export function onSaveImage(xyPostion, index, signKey, imgWH, image) {
Width: getIMGWH.newWidth,
Height: getIMGWH.newHeight,
SignUrl: image.src,
- ImageType: image.imgType
+ ImageType: image.imgType,
+ options: {
+ ...position.options,
+ response: image.src
+ }
};
}
return position;
@@ -549,7 +569,11 @@ export function onSaveSign(
...position,
Width: posWidth,
Height: posHeight,
- SignUrl: signatureImg
+ SignUrl: signatureImg,
+ options: {
+ ...position.options,
+ response: signatureImg
+ }
};
}
return position;
@@ -613,7 +637,7 @@ export const addDefaultSignatureImg = (xyPostion, defaultSignImg) => {
const getPageNo = xyPostion[i].pageNumber;
const getPosData = getXYdata;
- const addSign = getPosData.map((position, ind) => {
+ const addSign = getPosData.map((position) => {
getIMGWH = calculateImgAspectRatio(imgWH, position);
if (position.type) {
if (position?.type === "signature") {
@@ -622,7 +646,11 @@ export const addDefaultSignatureImg = (xyPostion, defaultSignImg) => {
SignUrl: defaultSignImg,
Width: getIMGWH.newWidth,
Height: getIMGWH.newHeight,
- ImageType: "default"
+ ImageType: "default",
+ options: {
+ ...position.options,
+ response: defaultSignImg
+ }
};
}
} else if (position && !position.isStamp) {
@@ -631,7 +659,11 @@ export const addDefaultSignatureImg = (xyPostion, defaultSignImg) => {
SignUrl: defaultSignImg,
Width: getIMGWH.newWidth,
Height: getIMGWH.newHeight,
- ImageType: "default"
+ ImageType: "default",
+ options: {
+ ...position.options,
+ response: defaultSignImg
+ }
};
}
return position;
@@ -1030,6 +1062,15 @@ export const multiSignEmbed = async (
}
};
const randomboxId = "randombox_" + imgData.key;
+ const widgetTypeExist = [
+ "text",
+ "name",
+ "company",
+ "job title",
+ "date",
+ "email",
+ "label"
+ ].includes(imgData.type);
if (imgData.type === "checkbox") {
const checkBox = form.createCheckBox(randomboxId);
@@ -1039,25 +1080,17 @@ export const multiSignEmbed = async (
width: scaleWidth,
height: scaleHeight
});
- if (imgData.widgetValue) {
+ if (imgData.options.response) {
checkBox.check();
} else {
checkBox.uncheck();
}
checkBox.enableReadOnly();
- } else if (
- imgData.type === "text" ||
- imgData.type === "name" ||
- imgData.type === "company" ||
- imgData.type === "job title" ||
- imgData.type === "date" ||
- imgData.type === "email" ||
- imgData.type === "label"
- ) {
+ } else if (widgetTypeExist) {
const font = await pdfDoc.embedFont("Helvetica");
const fontSize = 12;
- const textContent = imgData.widgetValue;
+ const textContent = imgData.options?.response;
page.drawText(textContent, {
x: xPos(imgData),
y: yPos(imgData) + 10,
@@ -1067,8 +1100,8 @@ export const multiSignEmbed = async (
});
} else if (imgData.type === "dropdown") {
const dropdown = form.createDropdown(randomboxId);
- dropdown.addOptions(imgData.widgetOption);
- dropdown.select(imgData.widgetValue);
+ dropdown.addOptions(imgData?.options?.values);
+ dropdown.select(imgData.options?.response);
dropdown.addToPage(page, {
x: xPos(imgData),
y: yPos(imgData),
@@ -1080,8 +1113,8 @@ export const multiSignEmbed = async (
const radioGroup = form.createRadioGroup(randomboxId);
let addYPosition = 18;
- for (let i = 1; i <= imgData?.widgetOption.length; i++) {
- const data = imgData?.widgetOption[i - 1];
+ for (let i = 1; i <= imgData?.options?.values.length; i++) {
+ const data = imgData?.options?.values[i - 1];
let yPosition;
if (i > 1) {
yPosition = yPos(imgData) - addYPosition;
@@ -1100,7 +1133,7 @@ export const multiSignEmbed = async (
}
}
- radioGroup.select(imgData.widgetValue);
+ radioGroup.select(imgData.options?.response);
radioGroup.enableReadOnly();
} else {
page.drawImage(img, {
@@ -1164,49 +1197,9 @@ export const handleImageResize = (
(data) => data.pageNumber === pageNumber
);
if (getPageNumer.length > 0) {
- // const getXYdata = getPageNumer[0].pos.filter(
- // (data, ind) => data.key === key && data.Width && data.Height
- // );
- // if (getXYdata.length > 0) {
- // const getXYdata = getPageNumer[0].pos;
- // const getPosData = getXYdata;
- // const addSignPos = getPosData.map((url, ind) => {
- // if (url.key === key) {
- // return {
- // ...url,
- // Width: ref.offsetWidth,
- // Height: ref.offsetHeight,
- // IsResize: showResize ? true : false
- // };
- // }
- // return url;
- // });
-
- // const newUpdateSignPos = getPlaceHolder.map((obj, ind) => {
- // if (obj.pageNumber === pageNumber) {
- // return { ...obj, pos: addSignPos };
- // }
- // return obj;
- // });
-
- // // const newUpdateSigner = signerPos.map((obj, ind) => {
- // // if (obj.signerObjId === signerId) {
- // // return { ...obj, placeHolder: newUpdateSignPos };
- // // }
- // // return obj;
- // // });
-
- // const newUpdateSigner = signerPos.map((obj, ind) => {
- // if (obj.Id === signerId) {
- // return { ...obj, placeHolder: newUpdateSignPos };
- // }
- // return obj;
- // });
- // setSignerPos(newUpdateSigner);
- // } else {
const getXYdata = getPageNumer[0].pos;
const getPosData = getXYdata;
- const addSignPos = getPosData.map((url, ind) => {
+ const addSignPos = getPosData.map((url) => {
if (url.key === key) {
return {
...url,
@@ -1218,19 +1211,13 @@ export const handleImageResize = (
return url;
});
- const newUpdateSignPos = getPlaceHolder.map((obj, ind) => {
+ const newUpdateSignPos = getPlaceHolder.map((obj) => {
if (obj.pageNumber === pageNumber) {
return { ...obj, pos: addSignPos };
}
return obj;
});
- // const newUpdateSigner = signerPos.map((obj, ind) => {
- // if (obj.signerObjId === signerId) {
- // return { ...obj, placeHolder: newUpdateSignPos };
- // }
- // return obj;
- // });
const newUpdateSigner = signerPos.map((obj, ind) => {
if (obj.Id === signerId) {
return { ...obj, placeHolder: newUpdateSignPos };
@@ -1240,7 +1227,6 @@ export const handleImageResize = (
setSignerPos(newUpdateSigner);
}
- // }
}
};