Skip to content

🔥 The free & Open Source DocuSign alternative

fix: date is not visible in templateplaceholer

prafull-opensignlabsd3d33c85d929
diff --git a/apps/OpenSign/src/components/pdf/Placeholder.js b/apps/OpenSign/src/components/pdf/Placeholder.js
index 4fe300cd0..d1ec47e01 100644
--- a/apps/OpenSign/src/components/pdf/Placeholder.js
+++ b/apps/OpenSign/src/components/pdf/Placeholder.js
@@ -10,10 +10,7 @@ import "../../styles/opensigndrive.css";
function Placeholder(props) {
const [isDraggingEnabled, setDraggingEnabled] = useState(true);
const [isShowDateFormat, setIsShowDateFormat] = useState(false);
- const [selectDate, setSelectDate] = useState({
- date: moment(new Date().getTime()).format("MM/DD/YYYY"),
- format: "MM/dd/YYYY"
- });
+ const [selectDate, setSelectDate] = useState();
const [dateFormat, setDateFormat] = useState([]);
const [saveDateFormat, setSaveDateFormat] = useState("");
const dateFormatArr = [
@@ -342,7 +339,7 @@ function Placeholder(props) {
className="dropdown-item itemColor"
style={{ fontSize: "12px" }}
>
- {data?.date ? data?.date : "No data"}
+ {data?.date ? data?.date : "nodata"}
</span>
);
})}
diff --git a/apps/OpenSign/src/components/pdf/PlaceholderType.js b/apps/OpenSign/src/components/pdf/PlaceholderType.js
index 3eb4ab6f7..32ab4aa87 100644
--- a/apps/OpenSign/src/components/pdf/PlaceholderType.js
+++ b/apps/OpenSign/src/components/pdf/PlaceholderType.js
@@ -6,7 +6,7 @@ import "../../styles/signature.css";
import RegexParser from "regex-parser";
function PlaceholderType(props) {
- const type = props.pos.type;
+ const type = props?.pos?.type;
const [selectOption, setSelectOption] = useState(
props.pos?.options?.defaultValue ? props.pos?.options?.defaultValue : ""
);
@@ -15,7 +15,6 @@ function PlaceholderType(props) {
const inputRef = useRef(null);
const [textValue, setTextValue] = useState();
const [selectedCheckbox, setSelectedCheckbox] = useState([]);
-
const validateExpression = (regexValidation) => {
let regexObject = regexValidation;
if (props.pos?.options.validation.type === "regex") {
@@ -74,33 +73,43 @@ function PlaceholderType(props) {
setValidatePlaceholder("enter text");
}
}
- useEffect(() => {
- setDefaultdata();
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
- function setDefaultdata() {
- if (props.pos?.options?.hint) {
+ useEffect(() => {
+ if (props.isNeedSign && type === "date") {
+ const updateDate = new Date();
+ setStartDate(updateDate);
+ } else if (type && type === "checkbox" && props.isNeedSign) {
+ const isDefaultValue = props.pos.options?.defaultValue;
+ if (isDefaultValue) {
+ setSelectedCheckbox(isDefaultValue);
+ }
+ } else if (props.pos?.options?.hint) {
setValidatePlaceholder(props.pos?.options.hint);
} else if (props.pos?.options?.validation?.type) {
checkRegularExpress(props.pos?.options?.validation?.type);
}
- if (props.isNeedSign && props.pos.type === "date") {
- const updateDate = new Date();
- setStartDate(updateDate);
- }
setTextValue(
props.pos?.options?.defaultValue ? props.pos?.options?.defaultValue : ""
);
- if (props.pos?.type && props.pos.type === "checkbox" && props.isNeedSign) {
- const isDefaultValue = props.pos.options?.defaultValue;
- if (isDefaultValue) {
- setSelectedCheckbox(isDefaultValue);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ useEffect(() => {
+ if (
+ ["name", "email", "job title", "company"].includes(props.pos?.type) &&
+ props.isNeedSign &&
+ props.data?.signerObjId === props?.signerObjId
+ ) {
+ const defaultData = props.pos?.options?.defaultValue;
+ if (defaultData) {
+ setTextValue(defaultData);
}
}
- }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [props.pos?.options?.defaultValue]);
+
useEffect(() => {
- if (props.pos?.type && props.pos.type === "date") {
+ if (type && type === "date") {
if (props.selectDate) {
let updateDate;
if (props.selectDate.format === "dd-MM-yyyy") {
@@ -122,22 +131,21 @@ function PlaceholderType(props) {
: "MM/dd/YYYY"
};
props.setSelectDate(dateObj);
+ onChangeInput(
+ props.saveDateFormat,
+ props.pos.key,
+ props.xyPostion,
+ props.index,
+ props.setXyPostion,
+ props.data && props.data.Id,
+ false,
+ props.selectDate?.format
+ ? props.selectDate.format
+ : props.pos?.options?.validation?.format
+ ? props.pos?.options?.validation?.format
+ : "MM/dd/YYYY"
+ );
}
-
- onChangeInput(
- props.saveDateFormat,
- props.pos.key,
- props.xyPostion,
- props.index,
- props.setXyPostion,
- props.data && props.data.Id,
- false,
- props.selectDate?.format
- ? props.selectDate.format
- : props.pos?.options?.validation?.format
- ? props.pos?.options?.validation?.format
- : "MM/dd/YYYY"
- );
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [props.saveDateFormat]);
@@ -161,33 +169,22 @@ function PlaceholderType(props) {
useEffect(() => {
if (
- ["name", "email", "job title", "company"].includes(props.pos?.type) &&
+ ["name", "email", "job title", "company"].includes(type) &&
props.isNeedSign &&
- props.data?.signerObjId === props?.signerObjId
+ props.data?.signerObjId === props.signerObjId
) {
- const defaultData = props.pos?.options?.defaultValue;
- if (defaultData) {
- setTextValue(defaultData);
- }
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [props.pos?.options?.defaultValue]);
- useEffect(() => {
- if (["name", "email", "job title", "company"].includes(props.pos?.type)) {
+ const isDefault = true;
const senderUser = localStorage.getItem(`Extand_Class`);
const jsonSender = JSON.parse(senderUser);
-
- if (props.isNeedSign && props.data?.signerObjId === props.signerObjId) {
- onChangeInput(
- jsonSender && jsonSender[0],
- null,
- props.xyPostion,
- null,
- props.setXyPostion,
- props.data.Id,
- true
- );
- }
+ onChangeInput(
+ jsonSender && jsonSender[0],
+ null,
+ props.xyPostion,
+ null,
+ props.setXyPostion,
+ props.data.Id,
+ isDefault
+ );
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [type]);
@@ -237,7 +234,7 @@ function PlaceholderType(props) {
let updateSelectedCheckbox = [],
checkedList;
let isDefaultValue, isDefaultEmpty;
- if (props.pos?.type === "checkbox") {
+ if (type === "checkbox") {
updateSelectedCheckbox = selectedCheckbox ? selectedCheckbox : [];
if (isChecked) {
@@ -296,7 +293,7 @@ function PlaceholderType(props) {
isRadio
);
};
- switch (props.pos.type) {
+ switch (type) {
case "signature":
return props.pos.SignUrl ? (
<img
@@ -425,7 +422,7 @@ function PlaceholderType(props) {
fontSize: calculateFontSize()
}}
>
- <span>{props.pos.type}</span>
+ <span>{type}</span>
</div>
);
case "dropdown":
@@ -466,7 +463,7 @@ function PlaceholderType(props) {
className="inputPlaceholder"
style={{ fontSize: calculateFontSize() }}
>
- {props.pos?.options?.name ? props.pos.options.name : props.pos.type}
+ {props.pos?.options?.name ? props.pos.options.name : type}
</div>
);
case "initials":
@@ -503,6 +500,7 @@ function PlaceholderType(props) {
value={textValue}
onBlur={handleInputBlur}
onChange={(e) => {
+ const isDefault = false;
handleTextValid(e);
onChangeInput(
e.target.value,
@@ -511,7 +509,7 @@ function PlaceholderType(props) {
props.index,
props.setXyPostion,
props.data && props.data?.Id,
- false
+ isDefault
);
}}
/>
@@ -522,7 +520,7 @@ function PlaceholderType(props) {
fontSize: calculateFontSize()
}}
>
- <span>{props.pos.type}</span>
+ <span>{type}</span>
</div>
);
case "company":
@@ -556,7 +554,7 @@ function PlaceholderType(props) {
fontSize: calculateFontSize()
}}
>
- <span>{props.pos.type}</span>
+ <span>{type}</span>
</div>
);
case "job title":
@@ -590,7 +588,7 @@ function PlaceholderType(props) {
fontSize: calculateFontSize()
}}
>
- <span>{props.pos.type}</span>
+ <span>{type}</span>
</div>
);
case "date":
@@ -677,7 +675,7 @@ function PlaceholderType(props) {
fontSize: calculateFontSize()
}}
>
- <span>{props.pos.type}</span>
+ <span>{type}</span>
</div>
);
case "radio":
diff --git a/apps/OpenSign/src/pages/PlaceHolderSign.js b/apps/OpenSign/src/pages/PlaceHolderSign.js
index 74ced4085..7de6b1b63 100644
--- a/apps/OpenSign/src/pages/PlaceHolderSign.js
+++ b/apps/OpenSign/src/pages/PlaceHolderSign.js
@@ -719,8 +719,27 @@ function PlaceHolderSign() {
};
const alertSendEmail = async () => {
- const filterPrefill = signerPos.filter((data) => data.Role !== "prefill");
- if (filterPrefill.length === signersdata.length) {
+ const filterPrefill = signerPos?.filter((data) => data.Role !== "prefill");
+ const getPrefill = signerPos?.filter((data) => data.Role === "prefill");
+ let isLabel = false;
+ if (getPrefill && getPrefill.length > 0) {
+ const prefillPlaceholder = getPrefill[0].placeHolder;
+ if (prefillPlaceholder) {
+ prefillPlaceholder.map((data) => {
+ if (!isLabel) {
+ isLabel = data.pos.some((position) => !position.options.response);
+ }
+ });
+ }
+ }
+
+ if (getPrefill && isLabel) {
+ const alert = {
+ mssg: "label",
+ alert: true
+ };
+ setIsSendAlert(alert);
+ } else if (filterPrefill.length === signersdata.length) {
const IsSignerNotExist = filterPrefill?.some((x) => !x.signerObjId);
if (IsSignerNotExist) {
setSignerExistModal(true);
@@ -1375,13 +1394,13 @@ function PlaceHolderSign() {
<ModalUi
headerColor={
- isSendAlert.mssg === "sure"
+ isSendAlert.mssg === "sure" || isSendAlert.mssg === "label"
? "#dc3545"
: isSendAlert.mssg === "confirm" && themeColor
}
isOpen={isSendAlert.alert}
title={
- isSendAlert.mssg === "sure"
+ isSendAlert.mssg === "sure" || isSendAlert.mssg === "label"
? "Fields required"
: isSendAlert.mssg === "confirm" && "Send Mail"
}
@@ -1390,6 +1409,8 @@ function PlaceHolderSign() {
<div style={{ height: "100%", padding: 20 }}>
{isSendAlert.mssg === "sure" ? (
<p>Please add field for all recipients.</p>
+ ) : isSendAlert.mssg === "label" ? (
+ <p>Please confirm that you have filled label widget.</p>
) : (
isSendAlert.mssg === "confirm" && (
<p>