🔥 The free & Open Source DocuSign alternative
JavaScript digital-signaturedocument-signingdocusign-alternativedocusign-freee-signatureelectronic-signatureelectronic-signaturesesignesignaturehacktoberfestjavascriptlegaltechmongodbnodejsopen-sourcepdf-signpdf-signaturereactjsself-hostedsign-pdf-files
fix: handle condition to load public-template script without templatId
RaktimaNXG96aff5230f56
diff --git a/apps/OpenSign/public/locales/en/translation.json b/apps/OpenSign/public/locales/en/translation.jsonindex 6077d59dd..4bad06f67 100644--- a/apps/OpenSign/public/locales/en/translation.json+++ b/apps/OpenSign/public/locales/en/translation.json@@ -126,7 +126,8 @@"Share with team": "Share with team","Share": "Share","View": "View",- "option": "Option"+ "option": "Option",+ "Embed":"Embed"},"report-heading": {"Sr.No": "Sr.No",@@ -616,5 +617,6 @@"buycredits": "Buy credits","rotate-right":"Rotate right","rotate-left":"Rotate left",- "rotate-alert-mssg":"All widgets on this page will be lost. Are you sure you want to proceed?"+ "rotate-alert-mssg":"All widgets on this page will be lost. Are you sure you want to proceed?",+ "templateid":"Template-Id"}diff --git a/apps/OpenSign/public/locales/fr/translation.json b/apps/OpenSign/public/locales/fr/translation.jsonindex 53b329712..cd831c6c8 100644--- a/apps/OpenSign/public/locales/fr/translation.json+++ b/apps/OpenSign/public/locales/fr/translation.json@@ -146,7 +146,8 @@"Share with team": "Partager avec l'équipe","Share": "Partager","View": "Voir",- "option": "Option"+ "option": "Option",+ "Embed":"Intégrer"},"report-help": {"Draft Documents": "Il s'agit de documents que vous avez commencés mais que vous n'avez pas finalisés pour envoi.",@@ -616,5 +617,6 @@"buycredits": "Acheter des crédits","rotate-right" :"Faire pivoter à droite","rotate-left" :"Faire pivoter à gauche",- "rotate-alert-mssg" :"Tous les widgets de cette page seront perdus. Êtes-vous sûr de vouloir continuer ?"+ "rotate-alert-mssg" :"Tous les widgets de cette page seront perdus. Êtes-vous sûr de vouloir continuer ?",+ "templateid":"ID de modèle"}diff --git a/apps/OpenSign/src/json/ReportJson.js b/apps/OpenSign/src/json/ReportJson.jsindex f09d72279..8100f5477 100644--- a/apps/OpenSign/src/json/ReportJson.js+++ b/apps/OpenSign/src/json/ReportJson.js@@ -354,6 +354,13 @@ export default function reportJson(id) {redirectUrl: "template",action: "redirect"},+ {+ btnId: "2434",+ btnLabel: "Embed",+ hoverLabel: "Embed",+ btnIcon: "fa-light fa-code",+ action: "Embed"+ },{btnId: "1834",btnLabel: "Delete",diff --git a/apps/OpenSign/src/pages/PdfRequestFiles.js b/apps/OpenSign/src/pages/PdfRequestFiles.jsindex 8bde5629a..656cb7958 100644--- a/apps/OpenSign/src/pages/PdfRequestFiles.js+++ b/apps/OpenSign/src/pages/PdfRequestFiles.js@@ -299,63 +299,65 @@ function PdfRequestFiles(props) {templateDeatils.data && templateDeatils.data.result? [templateDeatils.data.result]: [];-- if (documentData && documentData.length > 0) {- const url =- documentData[0] &&- (documentData[0]?.SignedUrl || documentData[0]?.URL);- if (url) {- //convert document url in array buffer format to use embed widgets in pdf using pdf-lib- const arrayBuffer = await convertPdfArrayBuffer(url);- if (arrayBuffer === "Error") {- setHandleError(t("something-went-wrong-mssg"));+ if (documentData && documentData[0]?.error) {+ props?.setTemplateStatus({+ status: "Invalid"+ });+ } else if (documentData && documentData.length > 0) {+ if (documentData[0]?.IsPublic) {+ props?.setTemplateStatus({+ status: "Success"+ });+ const url =+ documentData[0] &&+ (documentData[0]?.SignedUrl || documentData[0]?.URL);+ if (url) {+ //convert document url in array buffer format to use embed widgets in pdf using pdf-lib+ const arrayBuffer = await convertPdfArrayBuffer(url);+ if (arrayBuffer === "Error") {+ setHandleError(t("something-went-wrong-mssg"));+ } else {+ setPdfArrayBuffer(arrayBuffer);+ }} else {- setPdfArrayBuffer(arrayBuffer);+ setHandleError(t("something-went-wrong-mssg"));}- } else {- setHandleError(t("something-went-wrong-mssg"));- }- setIsPublicTemplate(true);- const getPublicRole = documentData[0]?.PublicRole[0];- const getUniqueIdDetails = documentData[0]?.Placeholders.find(- (x) => x.Role === getPublicRole- );- if (getUniqueIdDetails) {- setUniqueId(getUniqueIdDetails.Id);- }- setSignerPos(documentData[0]?.Placeholders);- let placeholdersOrSigners = [];- // const placeholder = documentData[0]?.Placeholders;- for (const placeholder of documentData[0].Placeholders) {- //`emailExist` variable to handle condition for quick send flow and show unsigned signers list- const signerIdExist = placeholder?.signerObjId;- if (signerIdExist) {- const getSignerData = documentData[0].Signers.find(- (data) => data.objectId === placeholder?.signerObjId- );- placeholdersOrSigners.push(getSignerData);- } else {- placeholdersOrSigners.push(placeholder);+ setIsPublicTemplate(true);+ const getPublicRole = documentData[0]?.PublicRole[0];+ const getUniqueIdDetails = documentData[0]?.Placeholders.find(+ (x) => x.Role === getPublicRole+ );+ if (getUniqueIdDetails) {+ setUniqueId(getUniqueIdDetails.Id);+ }+ setSignerPos(documentData[0]?.Placeholders);+ let placeholdersOrSigners = [];+ // const placeholder = documentData[0]?.Placeholders;+ for (const placeholder of documentData[0].Placeholders) {+ //`emailExist` variable to handle condition for quick send flow and show unsigned signers list+ const signerIdExist = placeholder?.signerObjId;+ if (signerIdExist) {+ const getSignerData = documentData[0].Signers.find(+ (data) => data.objectId === placeholder?.signerObjId+ );+ placeholdersOrSigners.push(getSignerData);+ } else {+ placeholdersOrSigners.push(placeholder);+ }}+ setUnSignedSigners(placeholdersOrSigners);+ setPdfDetails(documentData);+ setIsLoading({+ isLoad: false+ });+ } else {+ props?.setTemplateStatus({+ status: "Private"+ });}- setUnSignedSigners(placeholdersOrSigners);- setPdfDetails(documentData);- setIsLoading({- isLoad: false- });- } else if (- documentData === "Error: Something went wrong!" ||- (documentData.result && documentData.result.error)- ) {- console.log("err in get template details ");- setHandleError(t("something-went-wrong-mssg"));- setIsLoading({- isLoad: false- });} else {- setHandleError(t("no-data"));- setIsLoading({- isLoad: false+ props?.setTemplateStatus({+ status: "Invalid"});}} catch (err) {diff --git a/apps/OpenSign/src/primitives/GetReportDisplay.js b/apps/OpenSign/src/primitives/GetReportDisplay.jsindex 8b0286fe0..4f33ebed8 100644--- a/apps/OpenSign/src/primitives/GetReportDisplay.js+++ b/apps/OpenSign/src/primitives/GetReportDisplay.js@@ -362,6 +362,8 @@ const ReportTable = (props) => {setSelectedTeam(formatedList);}setIsShareWith({ [item.objectId]: true });+ } else if (act.action === "Embed") {+ handleEmbedFunction(item);}};// Get current list@@ -834,7 +836,6 @@ const ReportTable = (props) => {setTimeout(() => setIsAlert(false), 1500);}};-//function to make template public and set public roleconst handlePublicTemplate = async (item) => {if (selectedPublicRole || !props.isPublic[item.objectId]) {@@ -994,9 +995,26 @@ const ReportTable = (props) => {type: "success",message: t("copied")});- setTimeout(() => setIsAlert(false), 1500);+ setCopied({ ...copied, publicprofile: true });+ setTimeout(() => {+ setIsAlert(false);+ setCopied(false);+ }, 1500);};+ const copyTemplateId = (templateid) => {+ copytoData(templateid);+ setIsAlert(true);+ setAlertMsg({+ type: "success",+ message: t("copied")+ });+ setCopied({ ...copied, templateid: true });+ setTimeout(() => {+ setIsAlert(false);+ setCopied(false);+ }, 1500);+ };const handleShowRole = (item) => {const getRole = item.Placeholders.find((data) => !data.signerObjId);return getRole?.Role;@@ -1035,7 +1053,14 @@ const ReportTable = (props) => {setTimeout(() => setIsAlert(false), 1500);}};-+ const handleEmbedFunction = (item) => {+ setIsPublicProfile({+ [item.objectId]: props.isPublic[item.objectId]+ });+ let extendUser = JSON.parse(localStorage.getItem("Extand_Class"));+ setIsPublicUserName(extendUser[0]?.UserName || "");+ };+ console.log("ispublic", props.isPublic);return (<div className="relative">{Object.keys(actLoader)?.length > 0 && (@@ -1312,16 +1337,90 @@ const ReportTable = (props) => {{publicUserName ? (<div className="font-normal text-black"><p>{t("public-url-copy-mssg")}</p>- <div className=" flex items-center gap-3 mt-2 p-[2px] ">- <span className="font-bold">- {t("public-url")}:- </span>- <span- onClick={() => copytoProfileLink()}- className="underline underline-offset-2 w-[150px] md:w-[350px] whitespace-nowrap overflow-hidden text-ellipsis cursor-pointer"- >- {publicUrl()}- </span>+ <div className=" flex items-center justify-between gap-3 mt-2 p-[2px] ">+ <div className="w-[280px] whitespace-nowrap overflow-hidden text-ellipsis">+ <span className="font-bold">+ {t("public-url")} :+ </span>+ <span+ onClick={() =>+ copytoProfileLink()+ }+ className="ml-[2px] underline underline-offset-2 cursor-pointer"+ >+ {publicUrl()}+ </span>+ </div>+ <div className="flex items-center gap-2">+ <RWebShare+ data={{+ url: publicUrl(),+ title: "Public url"+ }}+ >+ <button className="op-btn op-btn-primary op-btn-outline op-btn-xs md:op-btn-sm ">+ <i className="fa-light fa-share-from-square"></i>{" "}+ <span className="hidden md:inline-block">+ {t("btnLabel.Share")}+ </span>+ </button>+ </RWebShare>+ <button+ className="op-btn op-btn-primary op-btn-outline op-btn-xs md:op-btn-sm"+ onClick={() =>+ copytoProfileLink()+ }+ >+ <i className="fa-light fa-link"></i>{" "}+ <span className="hidden md:inline-block">+ {copied["publicprofile"]+ ? t("copied")+ : t("copy")}+ </span>+ </button>+ </div>+ </div>+ <div className=" flex items-center justify-between gap-3 mt-2 p-[2px] ">+ <div>+ <span className="font-bold">+ {t("templateid")} :+ </span>+ <span+ onClick={() =>+ copyTemplateId(item.objectId)+ }+ className="underline ml-[2px] underline-offset-2 w-[150px] md:w-[350px] whitespace-nowrap overflow-hidden text-ellipsis cursor-pointer"+ >+ {item.objectId}+ </span>+ </div>+ <div className="flex items-center gap-2">+ <RWebShare+ data={{+ text: item.objectId+ }}+ >+ <button className="op-btn op-btn-primary op-btn-outline op-btn-xs md:op-btn-sm ">+ <i className="fa-light fa-share-from-square"></i>{" "}+ <span className="hidden md:inline-block">+ {t("btnLabel.Share")}+ </span>+ </button>+ </RWebShare>+ <button+ className="op-btn op-btn-primary op-btn-outline op-btn-xs md:op-btn-sm"+ onClick={() =>+ copyTemplateId(item.objectId)+ }+ >+ <i className="fa-light fa-link"></i>{" "}+ <span className="hidden md:inline-block">+ {copied["templateid"]+ ? t("copied")+ : t("copy")}+ </span>+ </button>+ </div></div></div>) : (@@ -1376,33 +1475,65 @@ const ReportTable = (props) => {{isOption[item.objectId] &&act.action === "option" && (<ul className="absolute -right-1 top-auto z-[70] w-max op-dropdown-content op-menu shadow bg-base-100 text-base-content rounded-box">- {act.subaction?.map((subact) => (- <li- key={subact.btnId}- onClick={() =>- handleActionBtn(- subact,- item- )- }- title={t(- `btnLabel.${subact.btnLabel}`- )}- >- <span>- <i- className={`${subact.btnIcon} mr-1.5`}- ></i>- {subact.btnLabel && (- <span className="text-[13px] capitalize font-medium">- {t(- `btnLabel.${subact.btnLabel}`+ {act.subaction?.map((subact) =>+ props.isPublic[+ item.objectId+ ] ? (+ <li+ key={subact.btnId}+ onClick={() =>+ handleActionBtn(+ subact,+ item+ )+ }+ title={t(+ `btnLabel.${subact.btnLabel}`+ )}+ >+ <span>+ <i+ className={`${subact.btnIcon} mr-1.5`}+ ></i>+ {subact.btnLabel && (+ <span className="text-[13px] capitalize font-medium">+ {t(+ `btnLabel.${subact.btnLabel}`+ )}+ </span>+ )}+ </span>+ </li>+ ) : (+ subact.action !== "Embed" && (+ <li+ key={subact.btnId}+ onClick={() =>+ handleActionBtn(+ subact,+ item+ )+ }+ title={t(+ `btnLabel.${subact.btnLabel}`+ )}+ >+ <span>+ <i+ className={`${subact.btnIcon} mr-1.5`}+ ></i>+ {subact.btnLabel && (+ <span className="text-[13px] capitalize font-medium">+ {t(+ `btnLabel.${subact.btnLabel}`+ )}+ </span>)}</span>- )}- </span>- </li>- ))}+ </li>+ )+ )+ )}</ul>)}</div>