Skip to content

Commit 9429b00

Browse files
Merge pull request #1120 from OpenSignLabs/rotatepage_document
fix: handle conditions and throw errors for public template script loading
2 parents 5a6437e + 3395785 commit 9429b00

File tree

5 files changed

+224
-87
lines changed

5 files changed

+224
-87
lines changed

apps/OpenSign/public/locales/en/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@
126126
"Share with team": "Share with team",
127127
"Share": "Share",
128128
"View": "View",
129-
"option": "Option"
129+
"option": "Option",
130+
"Embed":"Embed"
130131
},
131132
"report-heading": {
132133
"Sr.No": "Sr.No",
@@ -617,5 +618,6 @@
617618
"rotate-right":"Rotate right",
618619
"rotate-left":"Rotate left",
619620
"rotate-alert-mssg":"All widgets on this page will be lost. Are you sure you want to proceed?",
621+
"templateid":"Template-Id",
620622
"bulksendsubcriptionalert":"Please upgrade to Professional or Team plan to use quicksend."
621623
}

apps/OpenSign/public/locales/fr/translation.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@
146146
"Share with team": "Partager avec l'équipe",
147147
"Share": "Partager",
148148
"View": "Voir",
149-
"option": "Option"
149+
"option": "Option",
150+
"Embed":"Intégrer"
150151
},
151152
"report-help": {
152153
"Draft Documents": "Il s'agit de documents que vous avez commencés mais que vous n'avez pas finalisés pour envoi.",
@@ -617,5 +618,6 @@
617618
"rotate-right" :"Faire pivoter à droite",
618619
"rotate-left" :"Faire pivoter à gauche",
619620
"rotate-alert-mssg" :"Tous les widgets de cette page seront perdus. Êtes-vous sûr de vouloir continuer ?",
621+
"templateid":"ID de modèle",
620622
"bulksendsubcriptionalert":"Veuillez passer au forfait Professionnel ou Équipe pour utiliser Quicksend."
621623
}

apps/OpenSign/src/json/ReportJson.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,13 @@ export default function reportJson(id) {
354354
redirectUrl: "template",
355355
action: "redirect"
356356
},
357+
{
358+
btnId: "2434",
359+
btnLabel: "Embed",
360+
hoverLabel: "Embed",
361+
btnIcon: "fa-light fa-code",
362+
action: "Embed"
363+
},
357364
{
358365
btnId: "1834",
359366
btnLabel: "Delete",

apps/OpenSign/src/pages/PdfRequestFiles.js

Lines changed: 55 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -300,58 +300,66 @@ function PdfRequestFiles(props) {
300300
templateDeatils.data && templateDeatils.data.result
301301
? [templateDeatils.data.result]
302302
: [];
303-
304-
if (documentData && documentData.length > 0) {
305-
const url =
306-
documentData[0] &&
307-
(documentData[0]?.SignedUrl || documentData[0]?.URL);
308-
if (url) {
309-
//convert document url in array buffer format to use embed widgets in pdf using pdf-lib
310-
const arrayBuffer = await convertPdfArrayBuffer(url);
311-
if (arrayBuffer === "Error") {
312-
setHandleError(t("something-went-wrong-mssg"));
303+
if (documentData && documentData[0]?.error) {
304+
props?.setTemplateStatus({
305+
status: "Invalid"
306+
});
307+
} else if (documentData && documentData.length > 0) {
308+
if (documentData[0]?.IsPublic) {
309+
props?.setTemplateStatus({
310+
status: "Success"
311+
});
312+
const url =
313+
documentData[0] &&
314+
(documentData[0]?.SignedUrl || documentData[0]?.URL);
315+
if (url) {
316+
//convert document url in array buffer format to use embed widgets in pdf using pdf-lib
317+
const arrayBuffer = await convertPdfArrayBuffer(url);
318+
if (arrayBuffer === "Error") {
319+
setHandleError(t("something-went-wrong-mssg"));
320+
} else {
321+
setPdfArrayBuffer(arrayBuffer);
322+
}
313323
} else {
314-
setPdfArrayBuffer(arrayBuffer);
324+
setHandleError(t("something-went-wrong-mssg"));
315325
}
316-
} else {
317-
setHandleError(t("something-went-wrong-mssg"));
318-
}
319-
setIsPublicTemplate(true);
320-
const getPublicRole = documentData[0]?.PublicRole[0];
321-
const getUniqueIdDetails = documentData[0]?.Placeholders.find(
322-
(x) => x.Role === getPublicRole
323-
);
324-
if (getUniqueIdDetails) {
325-
setUniqueId(getUniqueIdDetails.Id);
326-
}
327-
setSignerPos(documentData[0]?.Placeholders);
328-
let placeholdersOrSigners = [];
329-
// const placeholder = documentData[0]?.Placeholders;
330-
for (const placeholder of documentData[0].Placeholders) {
331-
//`emailExist` variable to handle condition for quick send flow and show unsigned signers list
332-
const signerIdExist = placeholder?.signerObjId;
333-
if (signerIdExist) {
334-
const getSignerData = documentData[0].Signers.find(
335-
(data) => data.objectId === placeholder?.signerObjId
336-
);
337-
placeholdersOrSigners.push(getSignerData);
338-
} else {
339-
placeholdersOrSigners.push(placeholder);
326+
setIsPublicTemplate(true);
327+
const getPublicRole = documentData[0]?.PublicRole[0];
328+
const getUniqueIdDetails = documentData[0]?.Placeholders.find(
329+
(x) => x.Role === getPublicRole
330+
);
331+
if (getUniqueIdDetails) {
332+
setUniqueId(getUniqueIdDetails.Id);
340333
}
334+
setSignerPos(documentData[0]?.Placeholders);
335+
let placeholdersOrSigners = [];
336+
// const placeholder = documentData[0]?.Placeholders;
337+
for (const placeholder of documentData[0].Placeholders) {
338+
//`emailExist` variable to handle condition for quick send flow and show unsigned signers list
339+
const signerIdExist = placeholder?.signerObjId;
340+
if (signerIdExist) {
341+
const getSignerData = documentData[0].Signers.find(
342+
(data) => data.objectId === placeholder?.signerObjId
343+
);
344+
placeholdersOrSigners.push(getSignerData);
345+
} else {
346+
placeholdersOrSigners.push(placeholder);
347+
}
348+
}
349+
setUnSignedSigners(placeholdersOrSigners);
350+
setPdfDetails(documentData);
351+
setIsLoading({
352+
isLoad: false
353+
});
354+
} else {
355+
props?.setTemplateStatus({
356+
status: "Private"
357+
});
341358
}
342-
setUnSignedSigners(placeholdersOrSigners);
343-
setPdfDetails(documentData);
344-
setIsLoading({ isLoad: false });
345-
} else if (
346-
documentData === "Error: Something went wrong!" ||
347-
(documentData.result && documentData.result.error)
348-
) {
349-
console.log("err in get template details ");
350-
setHandleError(t("something-went-wrong-mssg"));
351-
setIsLoading({ isLoad: false });
352359
} else {
353-
setHandleError(t("no-data"));
354-
setIsLoading({ isLoad: false });
360+
props?.setTemplateStatus({
361+
status: "Invalid"
362+
});
355363
}
356364
} catch (err) {
357365
console.log("err in get template details ", err);

0 commit comments

Comments
 (0)