Skip to content

🔥 The free & Open Source DocuSign alternative

add template report and form , as well as migration code for it

prafull-opensignlabs8ebfd781c3f7
diff --git a/apps/OpenSign/src/json/ReportJson.js b/apps/OpenSign/src/json/ReportJson.js
index d3d6148ba..c65926b05 100644
--- a/apps/OpenSign/src/json/ReportJson.js
+++ b/apps/OpenSign/src/json/ReportJson.js
@@ -164,16 +164,26 @@ export default function reportJson(id) {
]
};
// template report
- case "23jk45slhj":
+ case "6TeaPr321t":
return {
reportName: "Templates",
- heading: contactbook,
+ heading: head,
actions: [
{
- btnLabel: "",
- btnColor: "#f55a42",
+ btnLabel: "Use",
+ btnColor: "#4bd396",
textColor: "white",
- btnIcon: "fa-solid fa-trash"
+ btnIcon: "fa fa-plus",
+ redirectUrl:
+ "remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/placeHolderSign"
+ },
+ {
+ btnLabel: "Edit",
+ btnColor: "#00c9d5",
+ textColor: "white",
+ btnIcon: "fa fa-plus",
+ redirectUrl:
+ "remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/template"
}
]
};
diff --git a/apps/OpenSign/src/primitives/GetReportDisplay.js b/apps/OpenSign/src/primitives/GetReportDisplay.js
index 6c603d76d..f54f719aa 100644
--- a/apps/OpenSign/src/primitives/GetReportDisplay.js
+++ b/apps/OpenSign/src/primitives/GetReportDisplay.js
@@ -55,10 +55,109 @@ const ReportTable = ({
}, [isMoreDocs, pageNumbers, currentPage, setIsNextRecord]);
// `handlemicroapp` is used to open microapp
- const handlemicroapp = (item, url) => {
- localStorage.removeItem("rowlevel");
- navigate("/rpmf/" + url);
- localStorage.setItem("rowlevel", JSON.stringify(item));
+ const handlemicroapp = async (item, url, btnLabel) => {
+ if (ReportName === "Templates") {
+ if(btnLabel === "Edit"){
+ navigate(`/asmf/${url}/${item.objectId}`);
+ }else{
+ setActLoader({ [item.objectId]: true });
+ try {
+ const params = {
+ templateId: item.objectId
+ };
+ const templateDeatils = await axios.post(
+ `${localStorage.getItem("baseUrl")}functions/getTemplate`,
+ params,
+ {
+ headers: {
+ "Content-Type": "application/json",
+ "X-Parse-Application-Id": localStorage.getItem("parseAppId"),
+ sessionToken: localStorage.getItem("accesstoken")
+ }
+ }
+ );
+
+ console.log("templateDeatils.data ", templateDeatils.data);
+ const templateData =
+ templateDeatils.data && templateDeatils.data.result;
+ if (!templateData.error) {
+ const Doc = templateData;
+
+ let placeholdersArr = [];
+ if (Doc.Placeholders?.length > 0) {
+ placeholdersArr = Doc.Placeholders;
+ }
+ let signers = [];
+ if (Doc.Signers?.length > 0) {
+ Doc.Signers?.forEach((x) => {
+ if (x.objectId) {
+ const obj = {
+ __type: "Pointer",
+ className: "contracts_Contactbook",
+ objectId: x.objectId
+ };
+ signers.push(obj);
+ }
+ });
+ }
+ const data = {
+ Name: Doc.Name,
+ URL: Doc.URL,
+ SignedUrl: Doc.SignedUrl,
+ Description: Doc.Description,
+ Note: Doc.Note,
+ Placeholders: placeholdersArr,
+ ExtUserPtr: {
+ __type: "Pointer",
+ className: "contracts_Users",
+ objectId: Doc.ExtUserPtr.objectId
+ },
+ CreatedBy: {
+ __type: "Pointer",
+ className: "_User",
+ objectId: Doc.CreatedBy.objectId
+ },
+ Signers: signers
+ };
+
+ const res = await axios.post(
+ `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem(
+ "_appName"
+ )}_Document`,
+ data,
+ {
+ headers: {
+ "Content-Type": "application/json",
+ "X-Parse-Application-Id": localStorage.getItem("parseAppId"),
+ "X-Parse-Session-Token": localStorage.getItem("accesstoken")
+ }
+ }
+ );
+
+ // console.log("Res ", res.data);
+ if (res.data && res.data.objectId) {
+ setActLoader({});
+ setIsAlert(true);
+ navigate(`/asmf/${url}/${res.data.objectId}`);
+ }
+ } else {
+ setIsAlert(true);
+ setIsErr(true);
+ setActLoader({});
+ }
+ } catch (err) {
+ console.log("err", err);
+ setIsAlert(true);
+ setIsErr(true);
+ setActLoader({});
+ }
+ }
+ } else {
+ localStorage.removeItem("rowlevel");
+ navigate("/rpmf/" + url);
+ localStorage.setItem("rowlevel", JSON.stringify(item));
+ }
+
// localStorage.setItem("rowlevelMicro");
};
const handlebtn = async (item) => {
@@ -217,7 +316,7 @@ const ReportTable = ({
key={index}
onClick={() =>
act?.redirectUrl
- ? handlemicroapp(item, act.redirectUrl)
+ ? handlemicroapp(item, act.redirectUrl, act.btnLabel)
: handlebtn(item)
}
className={`flex justify-center items-center w-full gap-1 px-2 py-1 rounded shadow`}
diff --git a/apps/OpenSign/src/primitives/TemplateForm.js b/apps/OpenSign/src/primitives/TemplateForm.js
index d478f670b..05f8d7d6f 100644
--- a/apps/OpenSign/src/primitives/TemplateForm.js
+++ b/apps/OpenSign/src/primitives/TemplateForm.js
@@ -7,16 +7,16 @@ import SelectFolder from "../components/fields/SelectFolder";
// import SignersInput from "../components/fields/SignersInput";
import Title from "../components/Title";
import { useNavigate } from "react-router-dom";
-import { templateCls } from '../constant/const'
-
+import { templateCls } from "../constant/const";
+
const TemplateForm = () => {
- const navigate = useNavigate()
+ const navigate = useNavigate();
const [signers, setSigners] = useState([]);
const [folder, setFolder] = useState({ ObjectId: "", Name: "" });
const [formData, setFormData] = useState({
- Name: "Please review and sign this document",
+ Name: "",
Description: "",
- Note: ""
+ Note: "Please review and sign this document"
});
const [fileupload, setFileUpload] = useState([]);
const [fileload, setfileload] = useState(false);
@@ -168,7 +168,10 @@ const TemplateForm = () => {
});
setFileUpload([]);
setpercentage(0);
- navigate('/asmf/remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/template/' +res.id)
+ navigate(
+ "/asmf/remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/template/" +
+ res.id
+ );
}
} catch (err) {
console.log("err ", err);
@@ -275,7 +278,9 @@ const TemplateForm = () => {
/>
</div>
<div className="text-xs mt-2">
- <label className="block">Note</label>
+ <label className="block">
+ Note<span className="text-red-500 text-[13px]">*</span>
+ </label>
<input
name="Note"
className="px-3 py-2 w-full border-[1px] border-gray-300 rounded focus:outline-none text-xs"
@@ -294,7 +299,7 @@ const TemplateForm = () => {
/>
</div>
{/* <SignersInput onChange={handleSigners} /> */}
- <SelectFolder onSuccess={handleFolder} folderCls={templateCls}/>
+ <SelectFolder onSuccess={handleFolder} folderCls={templateCls} />
<div className="flex items-center mt-3 gap-2 text-white">
<button
className="px-2 py-2 uppercase rounded shadow-md bg-sky-300 text-xs font-semibold"
diff --git a/apps/OpenSignServer/cloud/parsefunction/GetTemplate.js b/apps/OpenSignServer/cloud/parsefunction/GetTemplate.js
index 96b0a623a..da7371de1 100644
--- a/apps/OpenSignServer/cloud/parsefunction/GetTemplate.js
+++ b/apps/OpenSignServer/cloud/parsefunction/GetTemplate.js
@@ -1,3 +1,5 @@
+import axios from 'axios';
+
export default async function GetTemplate(request) {
const serverUrl = process.env.SERVER_URL;
const templateId = request.params.templateId;
@@ -10,6 +12,8 @@ export default async function GetTemplate(request) {
},
});
const userId = userRes.data && userRes.data.objectId;
+ console.log("templateId ", templateId)
+ console.log("userId ",userId)
if (templateId && userId) {
try {
const template = new Parse.Query('contracts_Template');
@@ -17,9 +21,12 @@ export default async function GetTemplate(request) {
template.include('ExtUserPtr');
template.include('Signers');
template.include('CreateBy');
- const res = template.first({ useMasterKey: true });
+ const res = await template.first({ useMasterKey: true });
+ console.log("res ", res)
if (res) {
+ console.log("res ",res)
const acl = res.getACL();
+ console.log("acl", acl.getReadAccess(userId))
if (acl && acl.getReadAccess(userId)) {
return res;
} else {
diff --git a/apps/OpenSignServer/cloud/parsefunction/getReport.js b/apps/OpenSignServer/cloud/parsefunction/getReport.js
index 759765aaa..ee72f0d20 100644
--- a/apps/OpenSignServer/cloud/parsefunction/getReport.js
+++ b/apps/OpenSignServer/cloud/parsefunction/getReport.js
@@ -19,7 +19,7 @@ export default async function getReport(request) {
const userId = userRes.data && userRes.data.objectId;
if (userId) {
const json = reportId && reportJson(reportId, userId);
- const clsName = reportId === '5KhaPr482K' ? 'contracts_Contactbook' : 'contracts_Document';
+ const clsName = json?.reportClass ? json.reportClass : 'contracts_Document';
if (json) {
const { params, keys } = json;
const orderBy = '-updatedAt';
diff --git a/apps/OpenSignServer/cloud/parsefunction/reportsJson.js b/apps/OpenSignServer/cloud/parsefunction/reportsJson.js
index 66d743a6a..cb52eca29 100644
--- a/apps/OpenSignServer/cloud/parsefunction/reportsJson.js
+++ b/apps/OpenSignServer/cloud/parsefunction/reportsJson.js
@@ -193,6 +193,7 @@ export default function reportJson(id, userId) {
case '5KhaPr482K':
return {
reportName: 'Contactbook',
+ reportClass: 'contracts_Contactbook',
params: {
CreatedBy: {
__type: 'Pointer',
@@ -203,6 +204,21 @@ export default function reportJson(id, userId) {
},
keys: ['Name', 'Email', 'Phone'],
};
+ // Templates report
+ case '6TeaPr321t':
+ return {
+ reportName: 'Templates',
+ reportClass: 'contracts_Template',
+ params: {
+ Type: { $ne: 'Folder' },
+ CreatedBy: {
+ __type: 'Pointer',
+ className: '_User',
+ objectId: currentUserId,
+ },
+ },
+ keys: ['Name', 'Note', 'Folder.Name', 'URL', 'ExtUserPtr.Name', 'Signers.Name'],
+ };
default:
return null;
}
diff --git a/apps/OpenSignServer/databases/migrations/20231129103946-update_menu.cjs b/apps/OpenSignServer/databases/migrations/20231129103946-update_menu.cjs
index c897aefac..2bb108b99 100644
--- a/apps/OpenSignServer/databases/migrations/20231129103946-update_menu.cjs
+++ b/apps/OpenSignServer/databases/migrations/20231129103946-update_menu.cjs
@@ -38,15 +38,7 @@ exports.up = async Parse => {
pageType: 'form',
description: '',
objectId: '8mZzFxbG1z',
- },
- {
- icon: 'fas fa-file-signature',
- title: 'New template',
- target: '_self',
- pageType: 'form',
- description: '',
- objectId: 'template',
- },
+ }
],
},
{
diff --git a/apps/OpenSignServer/databases/migrations/20231208132950-create_template_cls.cjs b/apps/OpenSignServer/databases/migrations/20231208132950-create_template_cls.cjs
deleted file mode 100644
index 47fe71b87..000000000
--- a/apps/OpenSignServer/databases/migrations/20231208132950-create_template_cls.cjs
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- *
- * @param {Parse} Parse
- */
-exports.up = async Parse => {
- const className = 'contracts_Template';
- const schema = new Parse.Schema(className);
-
- schema.addString('Name');
- schema.addString('URL');
- schema.addString('Note');
- schema.addString('Description');
- schema.addArray('Signers');
- schema.addBoolean('IsArchive');
- schema.addArray('Placeholders');
- schema.addPointer('Folder', 'contracts_Template');
- schema.addString('Type');
- schema.addPointer('CreatedBy', '_User');
- schema.addPointer('ExtUserPtr', 'contracts_Users');
- schema.addBoolean('EnablePhoneOTP')
- schema.addBoolean('EnableEmailOTP')
- schema.addBoolean('SendinOrder')
- schema.addBoolean('SentToOthers')
- schema.addBoolean('AutomaticReminders')
-
-
-
- return schema.save();
-};
-
-/**
- *
- * @param {Parse} Parse
- */
-exports.down = async Parse => {
- const className = 'contracts_Template';
- const schema = new Parse.Schema(className);
-
- return schema.purge().then(() => schema.delete());
-};
diff --git a/apps/OpenSignServer/databases/migrations/20231208132950-update_template_menu.cjs b/apps/OpenSignServer/databases/migrations/20231208132950-update_template_menu.cjs
new file mode 100644
index 000000000..9c33a5102
--- /dev/null
+++ b/apps/OpenSignServer/databases/migrations/20231208132950-update_template_menu.cjs
@@ -0,0 +1,572 @@
+/**
+ *
+ * @param {Parse} Parse
+ */
+exports.up = async Parse => {
+ const className = 'w_menu';
+ const userMenu = new Parse.Query(className);
+ const updateUserMenu = await userMenu.get('H9vRfEYKhT');
+ updateUserMenu.set('menuItems', [
+ {
+ icon: 'fas fa-tachometer-alt',
+ title: 'Dashboard',
+ target: '',
+ pageType: 'dashboard',
+ description: '',
+ objectId: '35KBoSgoAK',
+ },
+ {
+ icon: 'far fa-newspaper',
+ title: 'New Document',
+ target: '_self',
+ pageType: null,
+ description: null,
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-nib',
+ title: 'Sign yourself',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: 'sHAnZphf69',
+ },
+ {
+ icon: 'fas fa-file-signature',
+ title: 'Request signatures',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: '8mZzFxbG1z',
+ },
+ {
+ icon: 'fas fa-file-signature',
+ title: 'New template',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: 'template',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-file-signature',
+ title: 'Templates',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '6TeaPr321t',
+ },
+ {
+ icon: 'fas fa-folder',
+ title: 'OpenSignDriveâ„¢',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/legadrive',
+ },
+ {
+ icon: 'fas fa-address-card',
+ title: 'Reports',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-signature',
+ title: 'Need your sign',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '4Hhwbp482K',
+ },
+ {
+ icon: 'fas fa-tasks',
+ title: 'In Progress',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '1MwEuxLEkF',
+ },
+ {
+ icon: 'fas fa-check-circle',
+ title: 'Completed',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'kQUoW4hUXz',
+ },
+ {
+ icon: 'fas fa-edit',
+ title: 'Drafts',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'ByHuevtCFY',
+ },
+ {
+ icon: 'fas fa-times-circle',
+ title: 'Declined',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'UPr2Fm5WY3',
+ },
+ {
+ icon: 'fas fa-hourglass-end',
+ title: 'Expired',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'zNqBHXHsYH',
+ },
+ {
+ icon: 'fa-solid fa-address-book',
+ title: 'Contactbook',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '5KhaPr482K',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-cog',
+ title: 'Settings',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-fancy',
+ title: 'My Signature',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/managesign',
+ },
+ ],
+ },
+ ]);
+
+ const AdminMenu = new Parse.Query(className);
+ const updateAdminMenu = await AdminMenu.get('VPh91h0ZHk');
+ updateAdminMenu.set('menuItems', [
+ {
+ icon: 'fas fa-tachometer-alt',
+ title: 'Dashboard',
+ target: '',
+ pageType: 'dashboard',
+ description: '',
+ objectId: '35KBoSgoAK',
+ },
+ {
+ icon: 'far fa-newspaper',
+ title: 'New Document',
+ target: '_self',
+ pageType: null,
+ description: null,
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-nib',
+ title: 'Sign yourself',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: 'sHAnZphf69',
+ },
+ {
+ icon: 'fas fa-file-signature',
+ title: 'Request signatures',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: '8mZzFxbG1z',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-folder',
+ title: 'OpenSignDriveâ„¢',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/legadrive',
+ },
+ {
+ icon: 'fas fa-address-card',
+ title: 'Reports',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-signature',
+ title: 'Need your sign',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '4Hhwbp482K',
+ },
+ {
+ icon: 'fas fa-tasks',
+ title: 'In Progress',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '1MwEuxLEkF',
+ },
+ {
+ icon: 'fas fa-check-circle',
+ title: 'Completed',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'kQUoW4hUXz',
+ },
+ {
+ icon: 'fas fa-edit',
+ title: 'Drafts',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'ByHuevtCFY',
+ },
+ {
+ icon: 'fas fa-times-circle',
+ title: 'Declined',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'UPr2Fm5WY3',
+ },
+ {
+ icon: 'fas fa-hourglass-end',
+ title: 'Expired',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'zNqBHXHsYH',
+ },
+ {
+ icon: 'fa-solid fa-address-book',
+ title: 'Contactbook',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '5KhaPr482K',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-cog',
+ title: 'Settings',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-fancy',
+ title: 'My Signature',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/managesign',
+ },
+ {
+ icon: 'far fa-user',
+ title: 'Add User',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: 'lM0xRnM3iE',
+ },
+ ],
+ },
+ ]);
+ // TODO: Set the schema here
+ // Example:
+ // schema.addString('name').addNumber('cash');
+ const batch = [updateUserMenu, updateAdminMenu];
+ return Parse.Object.saveAll(batch, { useMasterKey: true });
+};
+
+/**
+ *
+ * @param {Parse} Parse
+ */
+exports.down = async Parse => {
+ // TODO: set className here
+ const className = 'w_menu';
+ const userMenu = new Parse.Query(className);
+ const revertUserMenu = await userMenu.get('H9vRfEYKhT');
+ revertUserMenu.set('menuItems', [
+ {
+ icon: 'fas fa-tachometer-alt',
+ title: 'Dashboard',
+ target: '',
+ pageType: 'dashboard',
+ description: '',
+ objectId: '35KBoSgoAK',
+ },
+ {
+ icon: 'far fa-newspaper',
+ title: 'New Document',
+ target: '_self',
+ pageType: null,
+ description: null,
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-nib',
+ title: 'Sign yourself',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: 'sHAnZphf69',
+ },
+ {
+ icon: 'fas fa-file-signature',
+ title: 'Request signatures',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: '8mZzFxbG1z',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-folder',
+ title: 'OpenSignDriveâ„¢',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/legadrive',
+ },
+ {
+ icon: 'fas fa-address-card',
+ title: 'Reports',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-signature',
+ title: 'Need your sign',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '4Hhwbp482K',
+ },
+ {
+ icon: 'fas fa-tasks',
+ title: 'In Progress',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '1MwEuxLEkF',
+ },
+ {
+ icon: 'fas fa-check-circle',
+ title: 'Completed',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'kQUoW4hUXz',
+ },
+ {
+ icon: 'fas fa-edit',
+ title: 'Drafts',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'ByHuevtCFY',
+ },
+ {
+ icon: 'fas fa-times-circle',
+ title: 'Declined',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'UPr2Fm5WY3',
+ },
+ {
+ icon: 'fas fa-hourglass-end',
+ title: 'Expired',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'zNqBHXHsYH',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-cog',
+ title: 'Settings',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-fancy',
+ title: 'My Signature',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/managesign',
+ },
+ ],
+ },
+ ]);
+
+ const adminMenu = new Parse.Query(className);
+ const revertAdminMenu = await adminMenu.get('VPh91h0ZHk');
+ revertAdminMenu.set('menuItems', [
+ {
+ icon: 'fas fa-tachometer-alt',
+ title: 'Dashboard',
+ target: '',
+ pageType: 'dashboard',
+ description: '',
+ objectId: '35KBoSgoAK',
+ },
+ {
+ icon: 'far fa-newspaper',
+ title: 'New Document',
+ target: '_self',
+ pageType: null,
+ description: null,
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-nib',
+ title: 'Sign yourself',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: 'sHAnZphf69',
+ },
+ {
+ icon: 'fas fa-file-signature',
+ title: 'Request signatures',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: '8mZzFxbG1z',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-folder',
+ title: 'OpenSignDriveâ„¢',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/legadrive',
+ },
+ {
+ icon: 'fas fa-address-card',
+ title: 'Reports',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-signature',
+ title: 'Need your sign',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '4Hhwbp482K',
+ },
+ {
+ icon: 'fas fa-tasks',
+ title: 'In Progress',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: '1MwEuxLEkF',
+ },
+ {
+ icon: 'fas fa-check-circle',
+ title: 'Completed',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'kQUoW4hUXz',
+ },
+ {
+ icon: 'fas fa-edit',
+ title: 'Drafts',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'ByHuevtCFY',
+ },
+ {
+ icon: 'fas fa-times-circle',
+ title: 'Declined',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'UPr2Fm5WY3',
+ },
+ {
+ icon: 'fas fa-hourglass-end',
+ title: 'Expired',
+ target: '_self',
+ pageType: 'report',
+ description: '',
+ objectId: 'zNqBHXHsYH',
+ },
+ ],
+ },
+ {
+ icon: 'fas fa-cog',
+ title: 'Settings',
+ target: '_self',
+ pageType: null,
+ description: '',
+ objectId: null,
+ children: [
+ {
+ icon: 'fas fa-pen-fancy',
+ title: 'My Signature',
+ target: '_self',
+ pageType: 'mf',
+ description: '',
+ objectId:
+ 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/managesign',
+ },
+ {
+ icon: 'far fa-user',
+ title: 'Add User',
+ target: '_self',
+ pageType: 'form',
+ description: '',
+ objectId: 'lM0xRnM3iE',
+ },
+ ],
+ },
+ ]);
+ // TODO: Set the schema here
+ // Example:
+ // schema.addString('name').addNumber('cash');
+ const batch = [revertUserMenu, revertAdminMenu];
+ return Parse.Object.saveAll(batch, { useMasterKey: true });
+};
diff --git a/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js b/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js
index a1edd16fb..cb3e67a67 100644
--- a/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js
+++ b/microfrontends/SignDocuments/src/Component/TemplatePlaceholder.js
@@ -60,7 +60,6 @@ const TemplatePlaceholder = () => {
const [signerUserId, setSignerUserId] = useState();
const [noData, setNoData] = useState(false);
const [pdfOriginalWidth, setPdfOriginalWidth] = useState();
- const [pdfOriginalHeight, setPdfOriginalHeight] = useState();
const [contractName, setContractName] = useState("");
const [containerWH, setContainerWH] = useState();
const signRef = useRef(null);
@@ -185,7 +184,7 @@ const TemplatePlaceholder = () => {
// headers: {
// "Content-Type": "application/json",
// "X-Parse-Application-Id": localStorage.getItem("parseAppId"),
- // "X-Parse-Session-Token": localStorage.getItem("accesstoken")
+ // "sessiontoken": localStorage.getItem("accesstoken")
// }
// }
// );
@@ -195,7 +194,6 @@ const TemplatePlaceholder = () => {
// ? [templateDeatils.data.result]
// : [];
- const params = { templateId: templateId };
const templateDeatils = await axios.get(
`${localStorage.getItem("baseUrl")}classes/contracts_Template/` +
templateId +
@@ -216,18 +214,8 @@ const TemplatePlaceholder = () => {
// console.log("documentData ", documentData)
if (documentData && documentData.length > 0) {
setPdfDetails(documentData);
- const currEmail = documentData[0].ExtUserPtr.Email;
+ setIsSigners(true);
if (documentData[0].Signers && documentData[0].Signers.length > 0) {
- const updateSigners = documentData[0].Signers.map((x, index) => ({
- ...x,
- Id: randomId(),
- Role: "User " + (index + 1)
- }));
- console.log("documentData[0] ", documentData[0]);
- // console.log("updateSigners ", updateSigners);
- // setSignersData(updateSigners);
- setIsSigners(true);
- setUniqueId(updateSigners[0].Id);
setSignerObjId(documentData[0].Signers[0].objectId);
setContractName(documentData[0].Signers[0].className);
setIsSelectId(0);
@@ -236,11 +224,9 @@ const TemplatePlaceholder = () => {
documentData[0].Placeholders.length > 0
) {
setSignerPos(documentData[0].Placeholders);
-
- let updateArr = [...updateSigners];
- console.log("updateArr ", updateArr);
- let arr = documentData[0].Placeholders.map((x) => {
- let matchingSigner = updateArr.find(
+ let signers = [...signersdata];
+ let updatedSigners = documentData[0].Placeholders.map((x) => {
+ let matchingSigner = signers.find(
(y) => x.signerObjId && x.signerObjId === y.objectId
);
@@ -248,21 +234,27 @@ const TemplatePlaceholder = () => {
return {
...matchingSigner,
Role: x.Role ? x.Role : matchingSigner.Role,
- Id: x.Id
+ Id: x.Id,
+ blockColor: x.blockColor
};
} else {
return {
Role: x.Role,
- Id: x.Id
+ Id: x.Id,
+ blockColor: x.blockColor
};
}
});
-
- // console.log("res ", updateArr);
- console.log("updateArray ", arr);
- setSignersData(arr);
+ setSignersData(updatedSigners);
+ setUniqueId(updatedSigners[0].Id);
} else {
- setSignersData(updateSigners);
+ const updatedSigners = documentData[0].Signers.map((x, index) => ({
+ ...x,
+ Id: randomId(),
+ Role: "User " + (index + 1)
+ }));
+ setSignersData(updatedSigners);
+ setUniqueId(updatedSigners[0].Id);
}
} else {
setRoleName("User 1");
@@ -270,20 +262,17 @@ const TemplatePlaceholder = () => {
documentData[0].Placeholders &&
documentData[0].Placeholders.length > 0
) {
- const arr = documentData[0].Placeholders?.filter(
- (x) => !x.signerObjId
- );
- console.log("arr ", arr);
- let updateArr = [];
- arr.forEach((x) => {
- const obj = {
- Role: x.Role,
- Id: randomId()
- };
- updateArr.push(obj);
+ let updatedSigners = documentData[0].Placeholders.map((x) => {
+ return {
+ Role: x.Role,
+ Id: x.Id,
+ blockColor: x.blockColor
+ };
+
});
setSignerPos(documentData[0].Placeholders);
- setSignersData(updateArr);
+ setUniqueId(updatedSigners[0].Id);
+ setSignersData(updatedSigners);
setIsSelectId(0);
}
}
@@ -306,7 +295,6 @@ const TemplatePlaceholder = () => {
}
const res = await contractUsers(jsonSender.email);
if (res[0] && res.length) {
- console.log("res[0] ", res);
setSignerUserId(res[0].objectId);
setCurrentEmail(res[0].Email);
const tourstatus = res[0].TourStatus && res[0].TourStatus;
@@ -351,6 +339,7 @@ const TemplatePlaceholder = () => {
getSignerPos(item, monitor);
}
};
+ console.log("signerdata ", signersdata)
const getSignerPos = (item, monitor) => {
console.log("item ", item);
@@ -550,9 +539,7 @@ const TemplatePlaceholder = () => {
setPdfLoadFail(load);
pdf.getPage(1).then((pdfPage) => {
const pageWidth = pdfPage.view[2];
- const pageHeight = pdfPage.view[3];
setPdfOriginalWidth(pageWidth);
- setPdfOriginalHeight(pageHeight);
});
};
//function for save x and y position and show signature tab on that position
@@ -876,48 +863,6 @@ const TemplatePlaceholder = () => {
Id: Id
};
setSignersData((prevArr) => [...prevArr, obj]);
- // const newWidth = containerWH.width;
- // const scale = pdfOriginalWidth / newWidth;
- // const posZIndex = zIndex + 1;
- // setZIndex(posZIndex);
- // const key = randomId();
- // let dropData = [];
- // let xyPosArr = [];
- // console.log("width ", pdfOriginalWidth);
- // console.log("height ", pdfOriginalHeight);
- // console.log("width ", pdfOriginalWidth / 2);
- // console.log("height ", pdfOriginalHeight / 2);
- // const dropObj = {
- // xPosition: pdfOriginalWidth / 2, // 213.453125, // newWidth / 2 ,
- // yPosition: pdfOriginalHeight / 2, //513.953125,//containerWH.height / 2 ,
- // isStamp: false,
- // key: key,
- // isDrag: false,
- // scale: scale,
- // isMobile: isMobile,
- // yBottom: pdfOriginalHeight / 2, //648.046875 // containerWH.height / 2
- // zIndex: posZIndex
- // };
- // dropData.push(dropObj);
- // const xyPos = {
- // pageNumber: pageNumber,
- // pos: dropData
- // };
-
- // xyPosArr.push(xyPos);
-
- // const placeHolderPos = {
- // signerPtr: {},
- // signerObjId: "",
- // blockColor: color[isSelectListId],
- // placeHolder: xyPosArr,
- // Role: roleName,
- // Id: Id
- // };
-
- // console.log("uniqueId ", uniqueId);
-
- // setSignerPos((prev) => [...prev, placeHolderPos]);
setIsModalRole(false);
setRoleName("");
};
@@ -932,7 +877,6 @@ const TemplatePlaceholder = () => {
setIsAddUser({ [id]: true });
};
const handleAddUser = (data) => {
- // console.log("hello", data);
const signerPtr = {
__type: "Pointer",
className: "contracts_Contactbook",
@@ -944,7 +888,6 @@ const TemplatePlaceholder = () => {
}
return { ...x };
});
- // console.log("updatePlaceHolder ", updatePlaceHolder);
setSignerPos(updatePlaceHolder);
const updateSigner = signersdata.map((x) => {
@@ -953,8 +896,6 @@ const TemplatePlaceholder = () => {
}
return { ...x };
});
- // console.log("updateSigner ", updateSigner);
-
setSignersData(updateSigner);
};
@@ -962,7 +903,6 @@ const TemplatePlaceholder = () => {
setIsAddUser({});
};
const handleRoleChange = (event, roleId) => {
- // console.log("event ", event.target.textContent)
// Update the role when the content changes
const updatedRoles = signersdata.map((role) =>
role.Id === roleId ? { ...role, Role: event.target.textContent } : role
diff --git a/microfrontends/SignDocuments/src/Component/component/fieldsComponent.js b/microfrontends/SignDocuments/src/Component/component/fieldsComponent.js
index 916e29005..744d8fdd7 100644
--- a/microfrontends/SignDocuments/src/Component/component/fieldsComponent.js
+++ b/microfrontends/SignDocuments/src/Component/component/fieldsComponent.js
@@ -91,7 +91,7 @@ function FieldsComponent({
justifyContent: "center"
}}
>
- <span style={{ fontSize: "18px", fontWeight: "500" }}>
+ <span style={{ fontSize: "13px", fontWeight: "700" }}>
Signer :
</span>
@@ -158,14 +158,10 @@ function FieldsComponent({
value={`${ind}|${JSON.stringify(obj)}`}
// value={(obj)}
>
- {" "}
- {obj.Email}
+ {obj.Role ?obj.Role : obj.Email}
</SelectItem>
);
})}
- {/* <SelectItem value="orange">Orange</SelectItem>
- <SelectItem value="apple">Apple</SelectItem>
- <SelectItem value="grape"></SelectItem> */}
</Select.Group>
</Select.Viewport>
<Select.ScrollDownButton className="SelectScrollButton">
@@ -177,7 +173,7 @@ function FieldsComponent({
fontSize: "20px"
}}
className="fa fa-angle-down"
- aria-hidden="true"
+ aria-hidden="false"
></i>
</Select.ScrollDownButton>
</Select.Content>
@@ -223,15 +219,6 @@ function FieldsComponent({
paddingBottom: "2.2rem"
}}
>
- {/* <img
- alt="sign img"
- style={{
- width: "30px",
- height: "30px",
- background: themeColor(),
- }}
- src={sign}
- /> */}
<span
style={{
color: "white",
diff --git a/microfrontends/SignDocuments/src/Component/component/signerListPlace.js b/microfrontends/SignDocuments/src/Component/component/signerListPlace.js
index d4c3e523e..f368773d5 100644
--- a/microfrontends/SignDocuments/src/Component/component/signerListPlace.js
+++ b/microfrontends/SignDocuments/src/Component/component/signerListPlace.js
@@ -48,9 +48,10 @@ function SignerListPlace({
const [isHover, setIsHover] = useState();
//function for onhover signer name change background color
- const onHoverStyle = (ind) => {
+ const onHoverStyle = (ind, blockColor) => {
+ console.log("blockColor ", blockColor)
const style = {
- background: color[ind % color.length],
+ background: blockColor ? blockColor : color[ind % color.length],
padding: "10px",
marginTop: "2px",
display: "flex",
@@ -78,6 +79,22 @@ function SignerListPlace({
return firstLetter;
};
+ const darkenColor = ( color, factor ) => {
+ // Remove '#' from the color code and parse it to get RGB values
+ const hex = color.replace('#', '');
+ const r = parseInt(hex.substring(0, 2), 16);
+ const g = parseInt(hex.substring(2, 4), 16);
+ const b = parseInt(hex.substring(4, 6), 16);
+
+ // Darken the color by reducing each RGB component
+ const darkerR = Math.floor(r * (1 - factor));
+ const darkerG = Math.floor(g * (1 - factor));
+ const darkerB = Math.floor(b * (1 - factor));
+
+ // Convert the darkened RGB components back to hex
+ return `#${(darkerR << 16 | darkerG << 8 | darkerB).toString(16).padStart(6, '0')}`;
+ }
+
return (
<div>
<div
@@ -101,7 +118,7 @@ function SignerListPlace({
key={ind}
style={
isHover === ind || isSelectListId === ind
- ? onHoverStyle(ind)
+ ? onHoverStyle(ind, obj.blockColor)
: nonHoverStyle(ind)
}
onClick={() => {
@@ -121,11 +138,13 @@ function SignerListPlace({
<div
className="signerStyle"
style={{
- background: nameColor[ind % nameColor.length],
+ background: obj.blockColor
+ ? darkenColor(obj.blockColor, 0.4)
+ : nameColor[ind % nameColor.length],
width: 20,
height: 20,
display: "flex",
- borderRadius: 30 / 2,
+ borderRadius : 30 / 2,
justifyContent: "center",
alignItems: "center",
marginRight: "20px",
diff --git a/microfrontends/SignDocuments/src/Component/placeHolderSign.js b/microfrontends/SignDocuments/src/Component/placeHolderSign.js
index a341e3879..8a27c3106 100644
--- a/microfrontends/SignDocuments/src/Component/placeHolderSign.js
+++ b/microfrontends/SignDocuments/src/Component/placeHolderSign.js
@@ -195,13 +195,11 @@ function PlaceHolderSign() {
// if (alreadyPlaceholder && alreadyPlaceholder.length > 0) {
// setIsAlreadyPlace(true);
// }
- setPdfDetails(documentData);
-
// setSignersData(documentData[0]);
-
+ // setIsSelectId(0);
// setSignerObjId(documentData[0].Signers[0].objectId);
// setContractName(documentData[0].Signers[0].className);
- // setIsSelectId(0);
+ setPdfDetails(documentData);
if (documentData[0].Signers && documentData[0].Signers.length > 0) {
const currEmail = documentData[0].ExtUserPtr.Email;
@@ -209,17 +207,6 @@ function PlaceHolderSign() {
(data) => data.Email === currEmail
);
setCurrentEmail(filterCurrEmail);
- // const updateSigners = documentData[0].Signers.map((x, index) => ({
- // ...x,
- // Id: randomId(),
- // Role: "User " + (index + 1)
- // }));
- const updateSigners = documentData[0].Signers;
- // console.log("documentData[0] ", documentData[0]);
- // console.log("updateSigners ", updateSigners);
- // setSignersData(updateSigners);
-
- setUniqueId(updateSigners[0].Id);
setSignerObjId(documentData[0].Signers[0].objectId);
setContractName(documentData[0].Signers[0].className);
setIsSelectId(0);
@@ -228,11 +215,9 @@ function PlaceHolderSign() {
documentData[0].Placeholders.length > 0
) {
setSignerPos(documentData[0].Placeholders);
-
- let updateArr = [...updateSigners];
- console.log("updateArr ", updateArr);
- let arr = documentData[0].Placeholders.map((x) => {
- let matchingSigner = updateArr.find(
+ let signers = [...signersdata];
+ let updatedSigners = documentData[0].Placeholders.map((x) => {
+ let matchingSigner = signers.find(
(y) => x.signerObjId && x.signerObjId === y.objectId
);
@@ -240,23 +225,27 @@ function PlaceHolderSign() {
return {
...matchingSigner,
Role: x.Role ? x.Role : matchingSigner.Role,
- Id: x.Id
+ Id: x.Id,
+ blockColor: x.blockColor
};
} else {
return {
Role: x.Role,
- Id: x.Id
+ Id: x.Id,
+ blockColor: x.blockColor
};
}
});
- setSignersData(arr);
+ setSignersData(updatedSigners);
+ setUniqueId(updatedSigners[0].Id);
} else {
- const updateSigners = documentData[0].Signers.map((x, index) => ({
+ const updatedSigners = documentData[0].Signers.map((x, index) => ({
...x,
Id: randomId(),
Role: "User " + (index + 1)
}));
- setSignersData(updateSigners);
+ setSignersData(updatedSigners);
+ setUniqueId(updatedSigners[0].Id);
}
} else {
setRoleName("User 1");
@@ -264,21 +253,18 @@ function PlaceHolderSign() {
documentData[0].Placeholders &&
documentData[0].Placeholders.length > 0
) {
- const arr = documentData[0].Placeholders?.filter(
- (x) => !x.signerObjId
- );
- // console.log("arr ", arr);
- let updateArr = [];
- arr.forEach((x) => {
- const obj = {
- Role: x.Role,
- Id: x.Id
- };
- updateArr.push(obj);
+ let updatedSigners = documentData[0].Placeholders.map((x) => {
+ return {
+ Role: x.Role,
+ Id: x.Id,
+ blockColor: x.blockColor
+ };
+
});
setSignerPos(documentData[0].Placeholders);
- setSignersData(updateArr);
+ setSignersData(updatedSigners);
setIsSelectId(0);
+ setUniqueId(updatedSigners[0].Id);
}
}
} else if (