fix: mobile to desktop and desktop to mobile view placeholder location issue

This commit is contained in:
RaktimaNXG
2023-12-07 20:01:15 +05:30
parent dec13e8b5f
commit d224a44e54
7 changed files with 302 additions and 90 deletions
@@ -296,7 +296,7 @@ function PdfRequestFiles() {
}
}
if (checkSignUrl && checkSignUrl.length > 0) {
if (checkSignUrl && checkSignUrl.length == 0) {
alert("Please complete your signature!");
} else {
setIsUiLoading(true);
@@ -348,17 +348,16 @@ function PdfRequestFiles() {
);
//function for call to embed signature in pdf and get digital signature pdf
signPdfFun(
newImgUrl,
documentId,
signerObjectId,
pdfOriginalWidth,
pngUrl,
containerWH,
data,
pdfBase64,
pageNo,
containerWH
pageNo
)
.then((res) => {
if (res && res.status === "success") {
@@ -390,9 +389,10 @@ function PdfRequestFiles() {
pngUrl,
pdfDoc,
pdfOriginalWidth,
false
false,
containerWH
);
// console.log(pdfBytes)
//function for call to embed signature in pdf and get digital signature pdf
signPdfFun(
pdfBytes,
@@ -407,7 +407,7 @@ function SignYourSelf() {
}
}
if (checkSignUrl && checkSignUrl.length > 0) {
if (checkSignUrl && checkSignUrl.length == 0) {
alert("Please complete your signature!");
} else {
setIsCeleb(true);
@@ -479,7 +479,7 @@ function SignYourSelf() {
true,
containerWH
);
//function for call to embed signature in pdf and get digital signature pdf
signPdfFun(pdfBytes, documentId);
}
setIsSignPad(false);
@@ -1,13 +1,16 @@
import React from "react";
import Modal from "react-bootstrap/Modal";
import ModalHeader from "react-bootstrap/esm/ModalHeader";
import { useNavigate } from "react-router-dom";
function ModalComponent({ isShow, type, setIsShowEmail }) {
const navigate = useNavigate();
return (
<Modal show={isShow}>
<ModalHeader className="bg-danger" style={{ color: "white" }}>
{type === "signersAlert" ? (
<span>Select signers</span>
) : type === "alreadyPlace" ? (
<span>Already Placed!</span>
) : (
<span>Document Expired!</span>
)}
@@ -16,24 +19,42 @@ function ModalComponent({ isShow, type, setIsShowEmail }) {
<Modal.Body>
{type === "signersAlert" ? (
<p>Please select signer for add placeholder!</p>
) : type === "alreadyPlace" ? (
<p>Already set placeHolder for this document.</p>
) : (
<p>This Document is no longer available.</p>
)}
</Modal.Body>
<Modal.Footer>
{type === "signersAlert" &&(
<button
onClick={() => {
setIsShowEmail(false);
}}
style={{
color: "black"
}}
type="button"
className="finishBtn"
>
Ok
</button>)}
{type === "signersAlert" ? (
<button
onClick={() => {
setIsShowEmail(false);
}}
style={{
color: "black"
}}
type="button"
className="finishBtn"
>
Ok
</button>
) : (
type === "alreadyPlace" && (
<button
onClick={() => {
navigate(-1);
}}
style={{
color: "black"
}}
type="button"
className="finishBtn"
>
Ok
</button>
)
)}
</Modal.Footer>
</Modal>
);
@@ -59,30 +59,64 @@ function RenderPdf({
let width;
if (isMobile) {
if (!pos.isMobile) {
width = pos.Width / scale ? pos.Width / scale : 150 / scale;
return width;
if (pos.IsResize) {
width = pos.Width ? pos.Width : 150;
return width;
} else {
width = pos.Width / scale ? pos.Width / scale : 150 / scale;
// width =
// pos.Width * pos.scale ? pos.Width * pos.scale : 150 * pos.scale;
return width;
}
} else {
width = pos.Width ? pos.Width : 150;
return width;
}
} else {
width = pos.Width ? pos.Width : 150;
return width;
if (pos.isMobile) {
if (pos.IsResize) {
width = pos.Width ? pos.Width : 150;
return width;
} else {
width = pos.Width ? pos.Width * pos.scale : 150 * pos.scale;
return width;
}
} else {
width = pos.Width ? pos.Width : 150;
return width;
}
}
};
const posHeight = (pos) => {
let width;
let height;
if (isMobile) {
if (!pos.isMobile) {
width = pos.Height / scale ? pos.Height / scale : 60 / scale;
return width;
if (pos.IsResize) {
// height = pos.Height ? pos.Height / scale : 60 / scale;
height = pos.Height ? pos.Height : 60;
return height;
} else {
height = pos.Height ? pos.Height / scale : 60 / scale;
// height = pos.Height ? pos.Height * pos.scale : 60 * pos.scale;
return height;
}
} else {
width = pos.Height ? pos.Height : 60;
return width;
height = pos.Height ? pos.Height : 60;
return height;
}
} else {
width = pos.Height ? pos.Height : 60;
return width;
if (pos.isMobile) {
if (pos.IsResize) {
height = pos.Height ? pos.Height : 60;
return height;
} else {
height = pos.Height ? pos.Height * pos.scale : 60 * pos.scale;
return height;
}
} else {
height = pos.Height ? pos.Height : 60;
return height;
}
}
};
@@ -99,7 +133,7 @@ function RenderPdf({
if (isMobile) {
//if pos.isMobile false -- placeholder saved from desktop view then handle position in mobile view divided by scale
if (!pos.isMobile) {
return pos.xPosition / scale - 32;
return pos.xPosition / scale;
}
//pos.isMobile true -- placeholder save from mobile view(small device) handle position in mobile view(small screen) view divided by scale
else {
@@ -169,7 +203,8 @@ function RenderPdf({
data.signerObjId === signerObjectId
? "pointer"
: "not-allowed",
borderColor: themeColor()
borderColor: themeColor(),
background: data.blockColor
}}
className="placeholderBlock"
size={{
@@ -186,7 +221,8 @@ function RenderPdf({
pageNumber,
setSignerPos,
pdfOriginalWidth,
containerWH
containerWH,
true
);
}}
lockAspectRatio={pos.Width && 2.5}
@@ -262,6 +298,46 @@ function RenderPdf({
}
};
const calculateWidth = (pos) => {
let width;
if (isMobile) {
width = pos.Width ? pos.Width * scale : 150 * scale;
return width;
} else {
if (pos.isMobile) {
if (pos.IsResize) {
width = pos.Width ? pos.Width : 150;
return width;
} else {
width = pos.Width ? pos.Width * pos.scale : 150 * pos.scale;
return width;
}
} else {
width = pos.Width ? pos.Width : 150;
return width;
}
}
};
const calculateHeight = (pos) => {
let height;
if (isMobile) {
height = pos.Height ? pos.Height * scale : 60 * scale;
return height;
} else {
if (pos.isMobile) {
if (pos.IsResize) {
height = pos.Height ? pos.Height : 60;
return height;
} else {
height = pos.Height ? pos.Height * pos.scale : 60 * pos.scale;
return height;
}
} else {
height = pos.Height ? pos.Height : 60;
return height;
}
}
};
return (
<>
{isMobile && scale ? (
@@ -413,7 +489,8 @@ function RenderPdf({
bounds="parent"
style={{
cursor: "all-scroll",
borderColor: themeColor()
borderColor: themeColor(),
background: data.blockColor
}}
className="placeholderBlock"
onDrag={() =>
@@ -464,6 +541,7 @@ function RenderPdf({
setSignerPos,
pdfOriginalWidth,
containerWH,
false,
setIsResize
);
}}
@@ -739,8 +817,8 @@ function RenderPdf({
}}
className="placeholderBlock"
size={{
width: pos.Width ? pos.Width : 150,
height: pos.Height ? pos.Height : 60
width: calculateWidth(pos),
height: calculateHeight(pos)
}}
lockAspectRatio={pos.Width && 2.5}
//if pos.isMobile false -- placeholder saved from mobile view then handle position in desktop view to multiply by scale
@@ -828,6 +906,7 @@ function RenderPdf({
bounds="parent"
style={{
cursor: "all-scroll",
background: data.blockColor,
borderColor: themeColor()
}}
className="placeholderBlock"
@@ -878,6 +957,7 @@ function RenderPdf({
setSignerPos,
pdfOriginalWidth,
containerWH,
false,
setIsResize
);
}}
@@ -65,6 +65,7 @@ function PlaceHolderSign() {
const [isShowEmail, setIsShowEmail] = useState(false);
const [selectedEmail, setSelectedEmail] = useState(false);
const [isResize, setIsResize] = useState(false);
const [isAlreadyPlace, setIsAlreadyPlace] = useState(false);
const [pdfLoadFail, setPdfLoadFail] = useState({
status: false,
type: "load"
@@ -181,8 +182,12 @@ function PlaceHolderSign() {
//getting document details
const documentData = await contractDocument(documentId);
if (documentData && documentData.length > 0) {
const alreadyPlaceholder =
documentData[0].Placeholders && documentData[0].Placeholders;
if (alreadyPlaceholder && alreadyPlaceholder.length > 0) {
setIsAlreadyPlace(true);
}
setPdfDetails(documentData);
const currEmail = documentData[0].ExtUserPtr.Email;
const filterCurrEmail = documentData[0].Signers.filter(
(data) => data.Email === currEmail
@@ -916,6 +921,7 @@ function PlaceHolderSign() {
)}
</Modal.Footer>
</Modal>
<ModalComponent isShow={isAlreadyPlace} type={"alreadyPlace"} />
<ModalComponent
isShow={isShowEmail}
type={"signersAlert"}
@@ -396,7 +396,7 @@ function EmbedPdfImage() {
}
}
if (checkSignUrl && checkSignUrl.length > 0) {
if (checkSignUrl && checkSignUrl.length == 0) {
alert("Please complete your signature!");
} else {
const loadObj = {
@@ -456,10 +456,10 @@ function EmbedPdfImage() {
signerUserId,
pdfOriginalWidth,
xyPostion,
containerWH,
data,
pdfBase64,
pageNo,
containerWH
pageNo
)
.then((res) => {
if (res && res.status === "success") {
@@ -508,7 +508,7 @@ function EmbedPdfImage() {
}
})
.catch((err) => {
alert("something went wrong in query");
alert("something went wrong in query", err);
});
}
setIsSignPad(false);