From 77622ebea9c3499684795d3ab1553f9be68b239e Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Tue, 25 Jun 2024 16:07:54 +0530 Subject: [PATCH] fix: exiting user can't receive bulk emails, input widgets's size reduced in request-sign process --- apps/OpenSign/src/components/BulkSendUi.js | 47 +++++++++++++++---- .../src/components/pdf/PlaceholderType.js | 10 ++-- .../src/components/pdf/WidgetComponent.js | 5 +- apps/OpenSign/src/constant/Utils.js | 44 ++++++++--------- apps/OpenSign/src/pages/PdfRequestFiles.js | 5 +- 5 files changed, 73 insertions(+), 38 deletions(-) diff --git a/apps/OpenSign/src/components/BulkSendUi.js b/apps/OpenSign/src/components/BulkSendUi.js index bd58169a3..3a737d3d9 100644 --- a/apps/OpenSign/src/components/BulkSendUi.js +++ b/apps/OpenSign/src/components/BulkSendUi.js @@ -113,9 +113,15 @@ const BulkSendUi = (props) => { let Placeholders = [...props.item.Placeholders]; // Initialize an empty array to store updated documents let Documents = []; - // Loop through each form forms.forEach((form) => { + //checking if user enter email which already exist as a signer then add user in a signers array + let existSigner = []; + form.fields.map((data) => { + if (data.signer) { + existSigner.push(data.signer); + } + }); // Map through the copied Placeholders array to update email values const updatedPlaceholders = Placeholders.map((placeholder) => { // Find the field in the current form that matches the placeholder Id @@ -123,23 +129,44 @@ const BulkSendUi = (props) => { (element) => parseInt(element.fieldId) === placeholder.Id ); // If a matching field is found, update the email value in the placeholder - const signer = field?.signer?.objectId ? field.signer : {}; + const signer = field?.signer?.objectId ? field.signer : ""; if (field) { - return { - ...placeholder, - email: field.email, - signerObjId: field?.signer?.objectId || "", - signerPtr: signer - }; + if (signer) { + return { + ...placeholder, + signerObjId: field?.signer?.objectId || "", + signerPtr: signer + }; + } else { + return { + ...placeholder, + email: field.email, + signerObjId: field?.signer?.objectId || "", + signerPtr: signer + }; + } } // If no matching field is found, keep the placeholder as is return placeholder; }); // Push a new document object with updated Placeholders into the Documents array - Documents.push({ ...props.item, Placeholders: updatedPlaceholders }); + if (existSigner?.length > 0) { + Documents.push({ + ...props.item, + Placeholders: updatedPlaceholders, + Signers: props.item.Signers + ? [...props.item.Signers, ...existSigner] + : [...existSigner] + }); + } else { + Documents.push({ + ...props.item, + Placeholders: updatedPlaceholders + }); + } }); - // console.log("Documents ", Documents); + //console.log("Documents ", Documents); await batchQuery(Documents); }; diff --git a/apps/OpenSign/src/components/pdf/PlaceholderType.js b/apps/OpenSign/src/components/pdf/PlaceholderType.js index c2c3f9fb6..815d830c0 100644 --- a/apps/OpenSign/src/components/pdf/PlaceholderType.js +++ b/apps/OpenSign/src/components/pdf/PlaceholderType.js @@ -424,7 +424,7 @@ function PlaceholderType(props) {
{type} @@ -523,7 +523,7 @@ function PlaceholderType(props) {
{type} @@ -563,7 +563,7 @@ function PlaceholderType(props) {
{type} @@ -603,7 +603,7 @@ function PlaceholderType(props) {
{type} @@ -721,7 +721,7 @@ function PlaceholderType(props) {
{type} diff --git a/apps/OpenSign/src/components/pdf/WidgetComponent.js b/apps/OpenSign/src/components/pdf/WidgetComponent.js index 51b10c4ff..6b812bbcc 100644 --- a/apps/OpenSign/src/components/pdf/WidgetComponent.js +++ b/apps/OpenSign/src/components/pdf/WidgetComponent.js @@ -355,7 +355,10 @@ function WidgetComponent({ Fields
-
+
{ + const intialText = widgetData; + const span = document.createElement("span"); + span.textContent = intialText; + span.style.font = `14px`; // here put your text size and font family + span.style.display = "hidden"; + document.body.appendChild(span); + const width = span.offsetWidth; + const height = span.offsetHeight; + document.body.removeChild(span); + return { + getWidth: width, + getHeight: height + }; +}; export const addInitialData = (signerPos, setXyPostion, value, userId) => { function widgetDataValue(type) { switch (type) { @@ -991,9 +1007,13 @@ export const addInitialData = (signerPos, setXyPostion, value, userId) => { options: { ...item.options, defaultValue: widgetData - }, - Width: calculateInitialWidthHeight(item.type, widgetData).getWidth, - Height: calculateInitialWidthHeight(item.type, widgetData).getHeight + } + // Width: + // calculateInitialWidthHeight(item.type, widgetData).getWidth || + // item?.Width, + // Height: + // calculateInitialWidthHeight(item.type, widgetData).getHeight || + // item?.Height }; } else { return { @@ -1004,24 +1024,6 @@ export const addInitialData = (signerPos, setXyPostion, value, userId) => { }); }; -//calculate width and height -export const calculateInitialWidthHeight = (widgetData) => { - const intialText = widgetData; - const span = document.createElement("span"); - span.textContent = intialText; - span.style.font = `14px`; // here put your text size and font family - span.style.display = "hidden"; - document.body.appendChild(span); - const width = span.offsetWidth; - const height = span.offsetHeight; - - document.body.removeChild(span); - return { - getWidth: width, - getHeight: height - }; -}; - //function for embed document id export const embedDocId = async (pdfDoc, documentId, allPages) => { for (let i = 0; i < allPages; i++) { diff --git a/apps/OpenSign/src/pages/PdfRequestFiles.js b/apps/OpenSign/src/pages/PdfRequestFiles.js index e2c21a10c..6fd6db379 100644 --- a/apps/OpenSign/src/pages/PdfRequestFiles.js +++ b/apps/OpenSign/src/pages/PdfRequestFiles.js @@ -1750,7 +1750,10 @@ function PdfRequestFiles() {
{signedSigners.length > 0 && ( <> -
+
Signed by