feat: change label widget name to text and text widget name to text input

This commit is contained in:
RaktimaNXG
2024-03-13 11:40:17 +05:30
parent 08e805569f
commit c04fd80a38
9 changed files with 86 additions and 58 deletions
@@ -2,7 +2,12 @@ import React, { useState, useEffect } from "react";
import BorderResize from "./BorderResize";
import PlaceholderBorder from "./PlaceholderBorder";
import { Rnd } from "react-rnd";
import { defaultWidthHeight, isMobile } from "../../constant/Utils";
import {
defaultWidthHeight,
isMobile,
textInputWidget,
textWidget
} from "../../constant/Utils";
import PlaceholderType from "./PlaceholderType";
import moment from "moment";
import "../../styles/opensigndrive.css";
@@ -202,7 +207,7 @@ function Placeholder(props) {
}
const widgetTypeExist = [
"text",
textInputWidget,
"checkbox",
"name",
"company",
@@ -238,7 +243,7 @@ function Placeholder(props) {
} else if (
props.isPlaceholder &&
!props.isDragging &&
props.pos.type !== "label"
props.pos.type !== textWidget
) {
if (props.pos.key === props.selectWidgetId) {
props.handleLinkUser(props.data.Id);
@@ -277,7 +282,7 @@ function Placeholder(props) {
props?.handleNameModal(true);
}
if (props.isPlaceholder && props.type !== "label") {
if (props.isPlaceholder && props.type !== textWidget) {
props.setUniqueId(props.data.Id);
}
props.setSignKey(props.pos.key);
@@ -285,10 +290,10 @@ function Placeholder(props) {
props.setCurrWidgetsDetails(props.pos);
};
const handleCopyPlaceholder = (e) => {
if (props.data && props?.pos?.type !== "label") {
if (props.data && props?.pos?.type !== textWidget) {
props.setSignerObjId(props?.data?.signerObjId);
props.setUniqueId(props?.data?.Id);
} else if (props.data && props.pos.type === "label") {
} else if (props.data && props.pos.type === textWidget) {
props.setTempSignerId(props.uniqueId);
props.setSignerObjId(props?.data?.signerObjId);
props.setUniqueId(props?.data?.Id);
@@ -324,7 +329,9 @@ function Placeholder(props) {
) : (
((!props?.pos?.type && props.pos.isStamp) ||
(props?.pos?.type &&
!["date", "label", "signature"].includes(props.pos.type) &&
!["date", textWidget, "signature"].includes(
props.pos.type
) &&
!props.isSignYourself)) && (
<i
onClick={(e) => {
@@ -349,7 +356,7 @@ function Placeholder(props) {
)
)}
{props.pos.type !== "label" && !props.isSignYourself && (
{props.pos.type !== textWidget && !props.isSignYourself && (
<i
data-tut="reactourLinkUser"
className="fa-regular fa-user signUserIcon"
@@ -511,7 +518,7 @@ function Placeholder(props) {
//ref={nodeRef}
key={props.pos.key}
lockAspectRatio={
props.pos.type !== "label" &&
props.pos.type !== textWidget &&
(props.pos.Width
? props.pos.Width / props.pos.Height
: defaultWidthHeight(props.pos.type).width /
@@ -1,7 +1,7 @@
import React, { useState } from "react";
import { themeColor } from "../../constant/const";
import ModalUi from "../../primitives/ModalUi";
import { randomId } from "../../constant/Utils";
import { randomId, textWidget } from "../../constant/Utils";
function PlaceholderCopy(props) {
const copyType = ["All pages", "All pages but last", "All pages but first"];
@@ -181,7 +181,7 @@ function PlaceholderCopy(props) {
}
};
const handleUniqueId = () => {
if (props.widgetType === "label") {
if (props.widgetType === textWidget) {
props.setUniqueId(props?.tempSignerId);
props.setTempSignerId("");
}
@@ -1,5 +1,12 @@
import React, { useEffect, useState, forwardRef, useRef } from "react";
import { getMonth, getYear, onChangeInput, range } from "../../constant/Utils";
import {
getMonth,
getYear,
onChangeInput,
range,
textInputWidget,
textWidget
} from "../../constant/Utils";
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
import "../../styles/signature.css";
@@ -77,7 +84,7 @@ function PlaceholderType(props) {
case "number":
setValidatePlaceholder("12345");
break;
case "text":
case textInputWidget:
setValidatePlaceholder("enter text");
break;
default:
@@ -132,7 +139,7 @@ function PlaceholderType(props) {
useEffect(() => {
if (type && type === "date") {
if (props?.selectDate) {
let updateDate;
// let updateDate;
// if (props?.selectDate.format === "dd-MM-yyyy") {
// // console.log('saveDateformat',props.saveDateFormat)
// const [day, month, year] = props.saveDateFormat.split("-");
@@ -410,7 +417,7 @@ function PlaceholderType(props) {
})}
</div>
);
case "text":
case textInputWidget:
return props.isSignYourself ||
(props.isNeedSign && props.data?.signerObjId === props.signerObjId) ? (
<input
@@ -770,7 +777,7 @@ function PlaceholderType(props) {
})}
</div>
);
case "label":
case textWidget:
return (
<textarea
placeholder="Enter label"
@@ -3,7 +3,7 @@ import ModalUi from "../../primitives/ModalUi";
import RecipientList from "./RecipientList";
import { useDrag } from "react-dnd";
import WidgetList from "./WidgetList";
import { widgets } from "../../constant/Utils";
import { textInputWidget, textWidget, widgets } from "../../constant/Utils";
import { themeColor } from "../../constant/const";
function WidgetComponent({
dragSignature,
@@ -58,16 +58,15 @@ function WidgetComponent({
isDragCheck: !!monitor.isDragging()
})
});
const [, text] = useDrag({
const [, textInput] = useDrag({
type: "BOX",
item: {
type: "BOX",
id: 7,
text: "text"
text: textInputWidget
},
collect: (monitor) => ({
isDragText: !!monitor.isDragging()
isDragTextInput: !!monitor.isDragging()
})
});
const [, initials] = useDrag({
@@ -165,16 +164,16 @@ function WidgetComponent({
isDragRadio: !!monitor.isDragging()
})
});
const [, label] = useDrag({
const [, text] = useDrag({
type: "BOX",
item: {
type: "BOX",
id: 16,
text: "label"
text: textWidget
},
collect: (monitor) => ({
isDragLabel: !!monitor.isDragging()
isDragText: !!monitor.isDragging()
})
});
const isMobile = window.innerWidth < 767;
@@ -208,8 +207,8 @@ function WidgetComponent({
jobTitle,
company,
date,
label,
text,
textInput,
checkbox,
dropdown,
radio,
@@ -227,13 +226,15 @@ function WidgetComponent({
const filterWidgets = widget.filter(
(data) =>
data.type !== "dropdown" && data.type !== "radio" && data.type !== "label"
data.type !== "dropdown" &&
data.type !== "radio" &&
data.type !== textWidget
);
const labelWidget = widget.filter((data) => data.type !== "label");
const textWidgetData = widget.filter((data) => data.type !== textWidget);
const updateWidgets = isSignYourself
? filterWidgets
: isTemplateFlow
? labelWidget
? textWidgetData
: widget;
return (
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from "react";
import ModalUi from "../../primitives/ModalUi";
import "../../styles/AddUser.css";
import RegexParser from "regex-parser";
import { textInputWidget } from "../../constant/Utils";
const WidgetNameModal = (props) => {
const [formdata, setFormdata] = useState({
@@ -69,7 +70,7 @@ const WidgetNameModal = (props) => {
return "/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$/";
case "number":
return "/^\\d+$/";
case "text":
case textInputWidget:
return "/^[a-zA-Zs]+$/";
default:
return type;
@@ -111,8 +112,8 @@ const WidgetNameModal = (props) => {
required
/>
</div>
{(props.defaultdata?.type === "text" ||
props.widgetName === "text") && (
{(props.defaultdata?.type === textInputWidget ||
props.widgetName === textInputWidget) && (
<>
<div className="form-section">
<label htmlFor="textvalidate" style={{ fontSize: 13 }}>
@@ -243,8 +244,8 @@ const WidgetNameModal = (props) => {
})}
</div>
</div>
{(props.defaultdata?.type === "text" ||
props?.widgetName === "text") && (
{(props.defaultdata?.type === textInputWidget ||
props?.widgetName === textInputWidget) && (
<div className="form-section">
<label htmlFor="hint" style={{ fontSize: 13 }}>
Hint
+10 -8
View File
@@ -5,6 +5,8 @@ import React from "react";
import { rgb } from "pdf-lib";
export const isMobile = window.innerWidth < 767;
export const textInputWidget = "text input";
export const textWidget = "text";
export const openInNewTab = (url) => {
window.open(url, "_blank", "noopener,noreferrer");
};
@@ -182,12 +184,12 @@ export const widgets = [
iconSize: "20px"
},
{
type: "label",
type: textWidget,
icon: "fa-solid fa-text-width",
iconSize: "20px"
},
{
type: "text",
type: textInputWidget,
icon: "fa-solid fa-font",
iconSize: "21px"
},
@@ -236,7 +238,7 @@ export const addWidgetOptions = (type) => {
return defaultOpt;
case "checkbox":
return defaultOpt;
case "text":
case textInputWidget:
return { ...defaultOpt, validation: { type: "text", pattern: "" } };
case "initials":
return defaultOpt;
@@ -256,7 +258,7 @@ export const addWidgetOptions = (type) => {
return defaultOpt;
case "radio":
return { ...defaultOpt, values: [] };
case "label":
case textWidget:
return defaultOpt;
default:
return {};
@@ -322,7 +324,7 @@ export const defaultWidthHeight = (type) => {
return { width: 150, height: 60 };
case "checkbox":
return { width: 15, height: 15 };
case "text":
case textInputWidget:
return { width: 150, height: 25 };
case "dropdown":
return { width: 120, height: 22 };
@@ -342,7 +344,7 @@ export const defaultWidthHeight = (type) => {
return { width: 150, height: 20 };
case "radio":
return { width: 15, height: 30 };
case "label":
case textWidget:
return { width: 150, height: 17 };
default:
return { width: 150, height: 60 };
@@ -1137,7 +1139,7 @@ export const multiSignEmbed = async (
}
};
const widgetTypeExist = [
"text",
textInputWidget,
"name",
"company",
"job title",
@@ -1183,7 +1185,7 @@ export const multiSignEmbed = async (
checkbox.enableReadOnly();
});
}
} else if (position.type === "label") {
} else if (position.type === textWidget) {
const font = await pdfDoc.embedFont("Helvetica");
const fontSize = 12;
let textContent;
+16 -11
View File
@@ -24,7 +24,9 @@ import {
randomId,
defaultWidthHeight,
multiSignEmbed,
addWidgetOptions
addWidgetOptions,
textInputWidget,
textWidget
} from "../constant/Utils";
import RenderPdf from "../components/pdf/RenderPdf";
import { useNavigate } from "react-router-dom";
@@ -384,7 +386,7 @@ function PlaceHolderSign() {
setSelectWidgetId(key);
if (signer) {
let filterSignerPos;
if (dragTypeValue === "label") {
if (dragTypeValue === textWidget) {
filterSignerPos = signerPos.filter((data) => data.Role === "prefill");
} else {
filterSignerPos = signerPos.filter((data) => data.Id === uniqueId);
@@ -411,7 +413,7 @@ function PlaceHolderSign() {
};
updatePlace.push(xyPos);
let updatesignerPos;
if (dragTypeValue === "label") {
if (dragTypeValue === textWidget) {
updatesignerPos = signerPos.map((x) =>
x.Role === "prefill" ? { ...x, placeHolder: updatePlace } : x
);
@@ -424,7 +426,7 @@ function PlaceHolderSign() {
setSignerPos(updatesignerPos);
} else {
let updatesignerPos;
if (dragTypeValue === "label") {
if (dragTypeValue === textWidget) {
updatesignerPos = signerPos.map((x) =>
x.Role === "prefill"
? { ...x, placeHolder: [...x.placeHolder, placeHolder] }
@@ -442,7 +444,7 @@ function PlaceHolderSign() {
} else {
//adding new placeholder for selected signer in pos array (placeholder)
let placeHolderPos;
if (dragTypeValue === "label") {
if (dragTypeValue === textWidget) {
placeHolderPos = {
signerPtr: {},
signerObjId: "",
@@ -484,7 +486,10 @@ function PlaceHolderSign() {
setIsCheckbox(true);
} else if (dragTypeValue === "radio") {
setIsRadio(true);
} else if (dragTypeValue !== "label" && dragTypeValue !== "signature") {
} else if (
dragTypeValue !== textWidget &&
dragTypeValue !== "signature"
) {
setIsNameModal(true);
}
setWidgetType(dragTypeValue);
@@ -734,7 +739,7 @@ function PlaceHolderSign() {
if (getPrefill && isLabel) {
const alert = {
mssg: "label",
mssg: textWidget,
alert: true
};
setIsSendAlert(alert);
@@ -1184,7 +1189,7 @@ function PlaceHolderSign() {
const getPosData = getXYdata;
const addSignPos = getPosData.map((position) => {
if (position.key === signKey) {
if (position.type === "text") {
if (position.type === textInputWidget) {
return {
...position,
options: {
@@ -1404,13 +1409,13 @@ function PlaceHolderSign() {
<ModalUi
headerColor={
isSendAlert.mssg === "sure" || isSendAlert.mssg === "label"
isSendAlert.mssg === "sure" || isSendAlert.mssg === textWidget
? "#dc3545"
: isSendAlert.mssg === "confirm" && themeColor
}
isOpen={isSendAlert.alert}
title={
isSendAlert.mssg === "sure" || isSendAlert.mssg === "label"
isSendAlert.mssg === "sure" || isSendAlert.mssg === textWidget
? "Fields required"
: isSendAlert.mssg === "confirm" && "Send Mail"
}
@@ -1419,7 +1424,7 @@ function PlaceHolderSign() {
<div style={{ height: "100%", padding: 20 }}>
{isSendAlert.mssg === "sure" ? (
<p>Please add field for all recipients.</p>
) : isSendAlert.mssg === "label" ? (
) : isSendAlert.mssg === textWidget ? (
<p>Please confirm that you have filled label widget.</p>
) : (
isSendAlert.mssg === "confirm" && (
+3 -3
View File
@@ -3,7 +3,6 @@ import { PDFDocument } from "pdf-lib";
import "../styles/signature.css";
import { themeColor } from "../constant/const";
import axios from "axios";
import moment from "moment";
import Loader from "../primitives/LoaderWithMsg";
import loader from "../assets/images/loader2.gif";
import RenderAllPdfPage from "../components/pdf/RenderAllPdfPage";
@@ -26,7 +25,8 @@ import {
contractUsers,
contactBook,
randomId,
getDate
getDate,
textInputWidget
} from "../constant/Utils";
import { useParams } from "react-router-dom";
import Tour from "reactour";
@@ -343,7 +343,7 @@ function SignYourSelf() {
name: "checkbox"
};
case "text":
case textInputWidget:
return {
name: "text"
};
@@ -21,7 +21,9 @@ import {
addZIndex,
createDocument,
defaultWidthHeight,
addWidgetOptions
addWidgetOptions,
textInputWidget,
textWidget
} from "../constant/Utils";
import RenderPdf from "../components/pdf/RenderPdf";
import "../styles/AddUser.css";
@@ -444,7 +446,10 @@ const TemplatePlaceholder = () => {
setIsCheckbox(true);
} else if (dragTypeValue === "radio") {
setIsRadio(true);
} else if (dragTypeValue !== "label" && dragTypeValue !== "signature") {
} else if (
dragTypeValue !== textWidget &&
dragTypeValue !== "signature"
) {
setIsNameModal(true);
}
setCurrWidgetsDetails({});
@@ -1106,7 +1111,7 @@ const TemplatePlaceholder = () => {
const getPosData = getXYdata;
const addSignPos = getPosData.map((position) => {
if (position.key === signKey) {
if (position.type === "text") {
if (position.type === textInputWidget) {
return {
...position,
options: {