🔥 The free & Open Source DocuSign alternative
JavaScript digital-signaturedocument-signingdocusign-alternativedocusign-freee-signatureelectronic-signatureelectronic-signaturesesignesignaturehacktoberfestjavascriptlegaltechmongodbnodejsopen-sourcepdf-signpdf-signaturereactjsself-hostedsign-pdf-files
feat: ask reason for decline/revoke document
prafull-opensignlabs1c9fb5ebcbf1
diff --git a/apps/OpenSign/src/components/pdf/PdfHeader.js b/apps/OpenSign/src/components/pdf/PdfHeader.jsindex 4223194b9..878ed5c12 100644--- a/apps/OpenSign/src/components/pdf/PdfHeader.js+++ b/apps/OpenSign/src/components/pdf/PdfHeader.js@@ -44,10 +44,7 @@ function Header({//function for show decline alertconst handleDeclinePdfAlert = async () => {- const currentDecline = {- currnt: "Sure",- isDeclined: true- };+ const currentDecline = { currnt: "Sure", isDeclined: true };setIsDecline(currentDecline);};@@ -209,7 +206,7 @@ function Header({</DropdownMenu.Trigger><DropdownMenu.Portal><DropdownMenu.Content- className="bg-white shadow-md rounded px-2 py-1"+ className="bg-white shadow-md rounded-full px-3 py-2"sideOffset={5}><DropdownMenu.Item@@ -362,40 +359,16 @@ function Header({>Finish</button>- <div className="op-dropdown op-dropdown-end">- <div- tabIndex={0}- role="button"- className="op-btn op-btn-info op-btn-sm shadow"- >- <i- className="fa-light fa-ellipsis-v"- aria-hidden="true"- ></i>- </div>- <ul- tabIndex={0}- className="op-dropdown-content z-[1] op-menu op-menu-sm p-1 shadow bg-base-100 rounded-box mt-1"- >- <li- onClick={() =>- handleDownloadPdf(- pdfDetails,- pdfUrl,- setIsDownloading- )- }- >- <span className="font-semibold text-[12px]">- <i- className="fa-light fa-arrow-down"- aria-hidden="true"- ></i>{" "}- Download- </span>- </li>- </ul>- </div>+ <button+ type="button"+ className="op-btn op-btn-neutral op-btn-sm mr-[3px] shadow"+ onClick={() =>+ handleDownloadPdf(pdfDetails, pdfUrl, setIsDownloading)+ }+ >+ <i className="fa-light fa-arrow-down font-semibold lg:hidden"></i>+ <span className="hidden lg:block">Download</span>+ </button></>)}</div>diff --git a/apps/OpenSign/src/json/ReportJson.js b/apps/OpenSign/src/json/ReportJson.jsindex 91dc7004e..a33990b46 100644--- a/apps/OpenSign/src/json/ReportJson.js+++ b/apps/OpenSign/src/json/ReportJson.js@@ -346,14 +346,14 @@ export default function reportJson(id) {message:"This menu reveals more options such as Edit & Delete. Use the 'Edit' button to add signer roles, modify fields, and update your template. Changes will apply to all future documents created from this template but won’t affect existing documents.Use the Delete button you can delete template. ",subaction: [- // {- // btnId: "1873",- // btnLabel: "Share-with",- // hoverLabel: "Share-with",- // btnIcon: "fa-light fa-share-nodes",- // redirectUrl: "",- // action: "sharewith"- // },+ {+ btnId: "1873",+ btnLabel: "Share-with",+ hoverLabel: "Share-with",+ btnIcon: "fa-light fa-share-nodes",+ redirectUrl: "",+ action: "sharewith"+ },{btnId: "2434",btnLabel: "Edit",diff --git a/apps/OpenSign/src/pages/PdfRequestFiles.js b/apps/OpenSign/src/pages/PdfRequestFiles.jsindex 526a751f3..3b0d4cd52 100644--- a/apps/OpenSign/src/pages/PdfRequestFiles.js+++ b/apps/OpenSign/src/pages/PdfRequestFiles.js@@ -1140,11 +1140,9 @@ function PdfRequestFiles() {});};//function for set decline true on press decline button- const declineDoc = async () => {+ const declineDoc = async (reason) => {setIsDecline({ isDeclined: false });- const data = {- IsDeclined: true- };+ const data = { IsDeclined: true, DeclineReason: reason };setIsUiLoading(true);await axios@@ -1486,12 +1484,9 @@ function PdfRequestFiles() {<ModalUiisOpen={defaultSignAlert.isShow}title={"Auto sign"}- handleClose={() => {- setDefaultSignAlert({- isShow: false,- alertMessage: ""- });- }}+ handleClose={() =>+ setDefaultSignAlert({ isShow: false, alertMessage: "" })+ }><div className="h-full p-[20px]"><p>{defaultSignAlert.alertMessage}</p>@@ -1506,12 +1501,12 @@ function PdfRequestFiles() {Yes</button><button- onClick={() => {+ onClick={() =>setDefaultSignAlert({isShow: false,alertMessage: ""- });- }}+ })+ }type="button"className="op-btn op-btn-secondary">@@ -1520,12 +1515,9 @@ function PdfRequestFiles() {</>) : (<button- onClick={() => {- setIsAlert({- isShow: false,- alertMessage: ""- });- }}+ onClick={() =>+ setIsAlert({ isShow: false, alertMessage: "" })+ }type="button"className="op-btn op-btn-primary">diff --git a/apps/OpenSign/src/primitives/GetReportDisplay.js b/apps/OpenSign/src/primitives/GetReportDisplay.jsindex 205df2089..e848a0a10 100644--- a/apps/OpenSign/src/primitives/GetReportDisplay.js+++ b/apps/OpenSign/src/primitives/GetReportDisplay.js@@ -68,6 +68,7 @@ const ReportTable = (props) => {// const [publicUserName, setIsPublicUserName] = useState("");const [isViewShare, setIsViewShare] = useState({});const [isSubscribe, setIsSubscribe] = useState(true);+ const [reason, setReason] = useState("");const Extand_Class = localStorage.getItem("Extand_Class");const extClass = Extand_Class && JSON.parse(Extand_Class);const startIndex = (currentPage - 1) * props.docPerPage;@@ -146,21 +147,23 @@ const ReportTable = (props) => {if (props.ReportName === "Templates") {try {const extUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];- const team = new Parse.Query("contracts_Teams");- team.equalTo("OrganizationId", {- __type: "Pointer",- className: "contracts_Organizations",- objectId: extUser.OrganizationId.objectId- });- team.notEqualTo("IsActive", false);- const teamtRes = await team.find();- if (teamtRes.length > 0) {- const _teamRes = JSON.parse(JSON.stringify(teamtRes));- const formatedList = _teamRes.map((x) => ({- label: x.Name,- value: x.objectId- }));- setTeamList(formatedList);+ if (extUser?.OrganizationId?.objectId) {+ const team = new Parse.Query("contracts_Teams");+ team.equalTo("OrganizationId", {+ __type: "Pointer",+ className: "contracts_Organizations",+ objectId: extUser.OrganizationId.objectId+ });+ team.notEqualTo("IsActive", false);+ const teamtRes = await team.find();+ if (teamtRes.length > 0) {+ const _teamRes = JSON.parse(JSON.stringify(teamtRes));+ const formatedList = _teamRes.map((x) => ({+ label: x.Name,+ value: x.objectId+ }));+ setTeamList(formatedList);+ }}} catch (err) {console.log("Err in fetch top level teamlist", err);@@ -444,6 +447,7 @@ const ReportTable = (props) => {const handleClose = () => {setIsRevoke({});setIsDeleteModal({});+ setReason("");// setIsMakePublic({});// setSelectedPublicRole("");// setIsPublicProfile({});@@ -487,10 +491,7 @@ const ReportTable = (props) => {const handleRevoke = async (item) => {setIsRevoke({});setActLoader({ [`${item.objectId}`]: true });- const data = {- IsDeclined: true- };-+ const data = { IsDeclined: true, DeclineReason: reason };await axios.put(`${localStorage.getItem("baseUrl")}classes/contracts_Document/${@@ -508,6 +509,7 @@ const ReportTable = (props) => {.then(async (result) => {const res = result.data;if (res) {+ setReason("");setActLoader({});setIsAlert(true);setAlertMsg({@@ -523,6 +525,7 @@ const ReportTable = (props) => {}).catch((err) => {console.log("err", err);+ setReason("");setIsAlert(true);setAlertMsg({type: "danger",@@ -1708,20 +1711,28 @@ const ReportTable = (props) => {handleClose={handleClose}><div className="m-[20px]">- <div className="text-lg font-normal text-black">+ <div className="text-sm md:text-lg font-normal text-black">Are you sure you want to revoke this document?</div>- <hr className="bg-[#ccc] mt-4" />+ <div className="mt-2">+ <textarea+ rows={3}+ placeholder="Reason (optional)"+ className="px-4 op-textarea op-textarea-bordered focus:outline-none hover:border-base-content w-full text-xs"+ value={reason}+ onChange={(e) => setReason(e.target.value)}+ ></textarea>+ </div><div className="flex items-center mt-3 gap-2"><buttononClick={() => handleRevoke(item)}- className="op-btn op-btn-primary"+ className="op-btn op-btn-primary px-6">Yes</button><buttononClick={handleClose}- className="op-btn op-btn-secondary"+ className="op-btn op-btn-secondary px-6">No</button>diff --git a/apps/OpenSign/src/primitives/PdfDeclineModal.js b/apps/OpenSign/src/primitives/PdfDeclineModal.jsindex 6345fb02f..67c16c5e2 100644--- a/apps/OpenSign/src/primitives/PdfDeclineModal.js+++ b/apps/OpenSign/src/primitives/PdfDeclineModal.js@@ -1,4 +1,4 @@-import React from "react";+import React, { useState } from "react";import "../styles/signature.css";function CustomModal({@@ -9,10 +9,11 @@ function CustomModal({declineDoc,setIsDecline}) {+ const [reason, setReason] = useState("");return (show && (- <dialog className="op-modal op-modal-open absolute z-[998]">- <div className="w-[80%] md:w-[40%] op-modal-box p-0 overflow-y-auto hide-scrollbar text-sm">+ <dialog className="op-modal op-modal-open absolute z-[448]">+ <div className="w-[95%] md:w-[60%] lg:w-[40%] op-modal-box p-0 overflow-y-auto hide-scrollbar text-sm"><h3 className="text-[#de4337] font-bold text-lg pt-[15px] px-[20px]">{headMsg && headMsg}</h3>@@ -21,19 +22,34 @@ function CustomModal({</div>{footerMessage && (<>- <div className="h-[1px] bg-[#9f9f9f] w-full"></div>- <div className="m-[15px] ">+ <div className="mx-3">+ <textarea+ rows={3}+ placeholder="Reason (optional)"+ className="px-4 op-textarea op-textarea-bordered focus:outline-none hover:border-base-content w-full text-xs"+ value={reason}+ onChange={(e) => setReason(e.target.value)}+ ></textarea>+ </div>+ {/* <div className="h-[1px] bg-[#9f9f9f] w-full"></div> */}+ <div className="m-[15px]"><button- className="op-btn op-btn-primary mr-2"+ className="op-btn op-btn-primary mr-2 px-6"type="button"- onClick={() => declineDoc()}+ onClick={() => {+ setReason("");+ declineDoc(reason);+ }}>Yes</button><buttontype="button"className="op-btn op-btn-secondary"- onClick={() => setIsDecline({ isDeclined: false })}+ onClick={() => {+ setReason("");+ setIsDecline({ isDeclined: false });+ }}>Close</button>diff --git a/apps/OpenSignServer/cloud/parsefunction/SubscriptionAftersave.js b/apps/OpenSignServer/cloud/parsefunction/SubscriptionAftersave.jsindex 445452101..9c8ae81bd 100644--- a/apps/OpenSignServer/cloud/parsefunction/SubscriptionAftersave.js+++ b/apps/OpenSignServer/cloud/parsefunction/SubscriptionAftersave.js@@ -65,7 +65,7 @@ export default async function SubscriptionAftersave(request) {const extUserRes = await extUserQuery.first({ useMasterKey: true });if (extUserRes) {const extUser = JSON.parse(JSON.stringify(extUserRes));- if (extUser?.UserRole !== 'contracts_Admin') {+ if (!extUser?.OrganizationId) {await addTeamAndOrg(extUser);}}@@ -86,7 +86,7 @@ export default async function SubscriptionAftersave(request) {const extUserRes = await extUserQuery.first({ useMasterKey: true });if (extUserRes) {const extUser = JSON.parse(JSON.stringify(extUserRes));- if (extUser?.UserRole !== 'contracts_Admin') {+ if (!extUser?.OrganizationId) {await addTeamAndOrg(extUser);}}diff --git a/apps/OpenSignServer/databases/migrations/20240710163936-addfield_declinereason_doc_cls.cjs b/apps/OpenSignServer/databases/migrations/20240710163936-addfield_declinereason_doc_cls.cjsnew file mode 100644index 000000000..e14b25c2e--- /dev/null+++ b/apps/OpenSignServer/databases/migrations/20240710163936-addfield_declinereason_doc_cls.cjs@@ -0,0 +1,21 @@+/**+ *+ * @param {Parse} Parse+ */+exports.up = async Parse => {+ const className = 'contracts_Document';+ const schema = new Parse.Schema(className);+ schema.addString('DeclineReason');+ return schema.update();+};++/**+ *+ * @param {Parse} Parse+ */+exports.down = async Parse => {+ const className = 'contracts_Document';+ const schema = new Parse.Schema(className);+ schema.deleteField('DeclineReason');+ return schema.update();+};