Skip to content

πŸ”₯ The free & Open Source DocuSign alternative

fix: report visibility issue of Need your sign and Recent signature request

prafull-opensignlabs2fe79dc2a800
diff --git a/apps/OpenSign/src/components/dashboard/DashboardCard.js b/apps/OpenSign/src/components/dashboard/DashboardCard.js
index 0bf4fabaa..c51f7ba42 100644
--- a/apps/OpenSign/src/components/dashboard/DashboardCard.js
+++ b/apps/OpenSign/src/components/dashboard/DashboardCard.js
@@ -156,7 +156,35 @@ const DashboardCard = (props) => {
if (props.Data.key !== "count") {
setresponse(res.data.results[0][props.Data.key]);
} else {
- setresponse(res.data[props.Data.key]);
+ if (props.Label === "Need your Signature") {
+ const listData = res.data?.results.filter(
+ (x) => x.Signers.length > 0
+ );
+ let arr = [];
+ for (const obj of listData) {
+ const isSigner = obj.Signers.some(
+ (item) => item.UserId.objectId === currentUser.id
+ );
+ if (isSigner) {
+ let isRecord;
+ if (obj?.AuditTrail && obj?.AuditTrail.length > 0) {
+ isRecord = obj?.AuditTrail.some(
+ (item) =>
+ item?.UserPtr?.UserId?.objectId === currentUser.id &&
+ item.Activity === "Signed"
+ );
+ } else {
+ isRecord = false;
+ }
+ if (isRecord === false) {
+ arr.push(obj);
+ }
+ }
+ }
+ setresponse(arr.length);
+ } else {
+ setresponse(res.data[props.Data.key]);
+ }
}
} else {
setresponse(0);
diff --git a/apps/OpenSign/src/components/dashboard/DashboardReport.js b/apps/OpenSign/src/components/dashboard/DashboardReport.js
index a23f20b15..4a0575f14 100644
--- a/apps/OpenSign/src/components/dashboard/DashboardReport.js
+++ b/apps/OpenSign/src/components/dashboard/DashboardReport.js
@@ -34,10 +34,39 @@ function DashboardReport(props) {
"X-Parse-Session-Token": localStorage.getItem("accesstoken")
};
try {
- const url = `${serverURL}?where=${strParams}&keys=${strKeys}&order=${orderBy}`;
+ const url = `${serverURL}?where=${strParams}&keys=${strKeys}&order=${orderBy}&include=AuditTrail.UserPtr`;
const res = await axios.get(url, { headers: headers });
// console.log("res ", res.data?.results);
- setList(res.data?.results);
+ if (id === "5Go51Q7T8r") {
+ const currentUser = Parse.User.current().id;
+ const listData = res.data?.results.filter(
+ (x) => x.Signers.length > 0
+ );
+ let arr = [];
+ for (const obj of listData) {
+ const isSigner = obj.Signers.some(
+ (item) => item.UserId.objectId === currentUser
+ );
+ if (isSigner) {
+ let isRecord;
+ if (obj?.AuditTrail && obj?.AuditTrail.length > 0) {
+ isRecord = obj?.AuditTrail.some(
+ (item) =>
+ item?.UserPtr?.UserId?.objectId === currentUser &&
+ item.Activity === "Signed"
+ );
+ } else {
+ isRecord = false;
+ }
+ if (isRecord === false) {
+ arr.push(obj);
+ }
+ }
+ }
+ setList(arr);
+ } else {
+ setList(res.data?.results);
+ }
setIsLoader(false);
} catch (err) {
console.log("err ", err);
diff --git a/apps/OpenSign/src/json/ReportJson.js b/apps/OpenSign/src/json/ReportJson.js
index c37ad828d..960559938 100644
--- a/apps/OpenSign/src/json/ReportJson.js
+++ b/apps/OpenSign/src/json/ReportJson.js
@@ -1,8 +1,6 @@
import Parse from "parse";
export default function reportJson(id) {
const currentUserId = Parse.User.current().id;
- // const extendedCls = localStorage.getItem("Extand_Class");
- // const json = JSON.parse(extendedCls)?.[0];
// console.log("json ", json);
switch (id) {
@@ -55,28 +53,7 @@ export default function reportJson(id) {
ExpiryDate: {
$gt: { __type: "Date", iso: new Date().toISOString() }
},
- $and: [
- {
- "AuditTrail.UserPtr": {
- $ne: {
- __type: "Pointer",
- className: "contracts_Users",
- objectId: "CkpaR0F6mj"
- }
- }
- },
- { "AuditTrail.Activity": { $ne: "Signed" } }
- ],
- Placeholders: { $ne: null },
- Signers: {
- $in: [
- {
- __type: "Pointer",
- className: "contracts_Users",
- objectId: "CkpaR0F6mj"
- }
- ]
- }
+ Placeholders: { $ne: null }
},
keys: [
"Name",
@@ -84,7 +61,9 @@ export default function reportJson(id) {
"Folder.Name",
"URL",
"ExtUserPtr.Name",
- "Signers.Name"
+ "Signers.Name",
+ "Signers.UserId",
+ "AuditTrail"
],
orderBy: "-updatedAt",
actions: [
@@ -342,28 +321,7 @@ export default function reportJson(id) {
ExpiryDate: {
$gt: { __type: "Date", iso: new Date().toISOString() }
},
- $and: [
- {
- "AuditTrail.UserPtr": {
- $ne: {
- __type: "Pointer",
- className: "contracts_Users",
- objectId: "CkpaR0F6mj"
- }
- }
- },
- { "AuditTrail.Activity": { $ne: "Signed" } }
- ],
- Placeholders: { $ne: null },
- Signers: {
- $in: [
- {
- __type: "Pointer",
- className: "contracts_Users",
- objectId: "CkpaR0F6mj"
- }
- ]
- }
+ Placeholders: { $ne: null }
},
keys: [
"Name",
@@ -371,7 +329,9 @@ export default function reportJson(id) {
"Folder.Name",
"URL",
"ExtUserPtr.Name",
- "Signers.Name"
+ "Signers.Name",
+ "Signers.UserId",
+ "AuditTrail"
],
orderBy: "-updatedAt",
actions: [
diff --git a/apps/OpenSign/src/routes/Report.js b/apps/OpenSign/src/routes/Report.js
index d59394b17..d82dc3630 100644
--- a/apps/OpenSign/src/routes/Report.js
+++ b/apps/OpenSign/src/routes/Report.js
@@ -27,6 +27,7 @@ const Report = () => {
const { className, params, keys, orderBy } = json;
Parse.serverURL = localStorage.getItem("BaseUrl12");
Parse.initialize(localStorage.getItem("AppID12"));
+ const currentUser = Parse.User.current().id;
const serverURL =
localStorage.getItem("BaseUrl12") + "classes/" + className;
@@ -38,10 +39,37 @@ const Report = () => {
"X-Parse-Session-Token": localStorage.getItem("accesstoken")
};
try {
- const url = `${serverURL}?where=${strParams}&keys=${strKeys}&order=${orderBy}`;
+ const url = `${serverURL}?where=${strParams}&keys=${strKeys}&order=${orderBy}&include=AuditTrail.UserPtr`;
const res = await axios.get(url, { headers: headers });
- // console.log("res ", res.data?.results);
- setList(res.data?.results);
+ if (id === "4Hhwbp482K") {
+ const listData = res.data?.results.filter(
+ (x) => x.Signers.length > 0
+ );
+ let arr = [];
+ for (const obj of listData) {
+ const isSigner = obj.Signers.some(
+ (item) => item.UserId.objectId === currentUser
+ );
+ if (isSigner) {
+ let isRecord;
+ if (obj?.AuditTrail && obj?.AuditTrail.length > 0) {
+ isRecord = obj?.AuditTrail.some(
+ (item) =>
+ item?.UserPtr?.UserId?.objectId === currentUser &&
+ item.Activity === "Signed"
+ );
+ } else {
+ isRecord = false;
+ }
+ if (isRecord === false) {
+ arr.push(obj);
+ }
+ }
+ }
+ setList(arr);
+ } else {
+ setList(res.data?.results);
+ }
setIsLoader(false);
} catch (err) {
console.log("err ", err);