Skip to content

Commit

Permalink
fix: date is not visible in templateplaceholer
Browse files Browse the repository at this point in the history
  • Loading branch information
prafull-opensignlabs committed Mar 7, 2024
1 parent c2796f6 commit d3d33c8
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 74 deletions.
7 changes: 2 additions & 5 deletions apps/OpenSign/src/components/pdf/Placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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>
);
})}
Expand Down
128 changes: 63 additions & 65 deletions apps/OpenSign/src/components/pdf/PlaceholderType.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 : ""
);
Expand All @@ -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") {
Expand Down Expand Up @@ -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") {
Expand All @@ -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]);
Expand All @@ -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]);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -296,7 +293,7 @@ function PlaceholderType(props) {
isRadio
);
};
switch (props.pos.type) {
switch (type) {
case "signature":
return props.pos.SignUrl ? (
<img
Expand Down Expand Up @@ -425,7 +422,7 @@ function PlaceholderType(props) {
fontSize: calculateFontSize()
}}
>
<span>{props.pos.type}</span>
<span>{type}</span>
</div>
);
case "dropdown":
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -503,6 +500,7 @@ function PlaceholderType(props) {
value={textValue}
onBlur={handleInputBlur}
onChange={(e) => {
const isDefault = false;
handleTextValid(e);
onChangeInput(
e.target.value,
Expand All @@ -511,7 +509,7 @@ function PlaceholderType(props) {
props.index,
props.setXyPostion,
props.data && props.data?.Id,
false
isDefault
);
}}
/>
Expand All @@ -522,7 +520,7 @@ function PlaceholderType(props) {
fontSize: calculateFontSize()
}}
>
<span>{props.pos.type}</span>
<span>{type}</span>
</div>
);
case "company":
Expand Down Expand Up @@ -556,7 +554,7 @@ function PlaceholderType(props) {
fontSize: calculateFontSize()
}}
>
<span>{props.pos.type}</span>
<span>{type}</span>
</div>
);
case "job title":
Expand Down Expand Up @@ -590,7 +588,7 @@ function PlaceholderType(props) {
fontSize: calculateFontSize()
}}
>
<span>{props.pos.type}</span>
<span>{type}</span>
</div>
);
case "date":
Expand Down Expand Up @@ -677,7 +675,7 @@ function PlaceholderType(props) {
fontSize: calculateFontSize()
}}
>
<span>{props.pos.type}</span>
<span>{type}</span>
</div>
);
case "radio":
Expand Down
29 changes: 25 additions & 4 deletions apps/OpenSign/src/pages/PlaceHolderSign.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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"
}
Expand All @@ -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>
Expand Down

0 comments on commit d3d33c8

Please sign in to comment.