Skip to content

Commit 7ba2ef6

Browse files
Merge pull request #311 from OpenSignLabs/opensign-drive
feat: implement of document delete and move to folder in opensigndrive
2 parents 7aaa187 + b5d9879 commit 7ba2ef6

File tree

19 files changed

+807
-674
lines changed

19 files changed

+807
-674
lines changed

apps/OpenSign/src/styles/loader.css

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,7 +2211,5 @@
22112211
background-position: -2em 0;
22122212
}
22132213
}
2214-
.box:nth-of-type(n + 43) {
2215-
display: none;
2216-
}
2217-
2214+
2215+

apps/OpenSignServer/cloud/parsefunction/getDocument.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default async function getDocument(request) {
2121
query.include('Signers');
2222
query.include('AuditTrail.UserPtr');
2323
query.include('Placeholders');
24+
query.notEqualTo('IsArchive', true)
2425
const res = await query.first({ useMasterKey: true });
2526
if (res) {
2627
const acl = res.getACL();

apps/OpenSignServer/cloud/parsefunction/getDrive.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export default async function getDrive(request) {
1616
if (userId) {
1717
let url;
1818
if (docId) {
19-
url = `${classUrl}?where={"Folder":{"__type":"Pointer","className":"contracts_Document","objectId":"${docId}"},"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${userId}"}}&include=ExtUserPtr,Signers,Folder`;
19+
url = `${classUrl}?where={"Folder":{"__type":"Pointer","className":"contracts_Document","objectId":"${docId}"},"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${userId}"},"IsArchive":{"$ne":true}}&include=ExtUserPtr,Signers,Folder`;
2020
} else {
21-
url = `${classUrl}?where={"Folder":{"$exists":false},"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${userId}"}}&include=ExtUserPtr,Signers`;
21+
url = `${classUrl}?where={"Folder":{"$exists":false},"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${userId}"},"IsArchive":{"$ne":true}}&include=ExtUserPtr,Signers`;
2222
}
2323
try {
2424
const res = await axios.get(url, {

apps/OpenSignServer/cloud/parsefunction/reportsJson.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ export default function reportJson(id, userId) {
77
return {
88
reportName: 'Draft Documents',
99
params: {
10-
Type: null,
11-
$or: [
12-
{ Signers: null, SignedUrl: null },
13-
{ Signers: { $exists: true }, Placeholders: null },
14-
],
10+
Type: { $ne: 'Folder' },
11+
IsCompleted: { $ne: true },
12+
IsDeclined: { $ne: true },
13+
IsArchive: { $ne: true },
14+
$or: [{ Signers: null }, { Signers: { $exists: true }, Placeholders: null }],
1515
CreatedBy: {
1616
__type: 'Pointer',
1717
className: '_User',
@@ -28,6 +28,7 @@ export default function reportJson(id, userId) {
2828
Type: { $ne: 'Folder' },
2929
IsCompleted: { $ne: true },
3030
IsDeclined: { $ne: true },
31+
IsArchive: { $ne: true },
3132
ExpiryDate: {
3233
$gt: { __type: 'Date', iso: new Date().toISOString() },
3334
},
@@ -66,6 +67,7 @@ export default function reportJson(id, userId) {
6667
Placeholders: { $ne: null },
6768
IsCompleted: { $ne: true },
6869
IsDeclined: { $ne: true },
70+
IsArchive: { $ne: true },
6971
CreatedBy: {
7072
__type: 'Pointer',
7173
className: '_User',
@@ -82,14 +84,15 @@ export default function reportJson(id, userId) {
8284
return {
8385
reportName: 'Completed Documents',
8486
params: {
85-
Type: null,
87+
Type: { $ne: 'Folder' },
8688
IsCompleted: true,
8789
CreatedBy: {
8890
__type: 'Pointer',
8991
className: '_User',
9092
objectId: currentUserId,
9193
},
9294
IsDeclined: { $ne: true },
95+
IsArchive: { $ne: true },
9396
},
9497
keys: [
9598
'Name',
@@ -108,6 +111,7 @@ export default function reportJson(id, userId) {
108111
reportName: 'Declined Documents',
109112
params: {
110113
Type: null,
114+
IsArchive: { $ne: true },
111115
IsDeclined: true,
112116
CreatedBy: {
113117
__type: 'Pointer',
@@ -125,6 +129,7 @@ export default function reportJson(id, userId) {
125129
params: {
126130
IsCompleted: { $ne: true },
127131
IsDeclined: { $ne: true },
132+
IsArchive: { $ne: true },
128133
Type: { $ne: 'Folder' },
129134
$and: [
130135
{
@@ -157,6 +162,7 @@ export default function reportJson(id, userId) {
157162
Placeholders: { $ne: null },
158163
IsCompleted: { $ne: true },
159164
IsDeclined: { $ne: true },
165+
IsArchive: { $ne: true },
160166
CreatedBy: {
161167
__type: 'Pointer',
162168
className: '_User',
@@ -176,6 +182,7 @@ export default function reportJson(id, userId) {
176182
Type: { $ne: 'Folder' },
177183
IsCompleted: { $ne: true },
178184
IsDeclined: { $ne: true },
185+
IsArchive: { $ne: true },
179186
ExpiryDate: {
180187
$gt: { __type: 'Date', iso: new Date().toISOString() },
181188
},
@@ -200,11 +207,11 @@ export default function reportJson(id, userId) {
200207
return {
201208
reportName: 'Drafts',
202209
params: {
203-
Type: null,
204-
$or: [
205-
{ Signers: null, SignedUrl: null },
206-
{ Signers: { $exists: true }, Placeholders: null },
207-
],
210+
Type: { $ne: 'Folder' },
211+
IsCompleted: { $ne: true },
212+
IsDeclined: { $ne: true },
213+
IsArchive: { $ne: true },
214+
$or: [{ Signers: null }, { Signers: { $exists: true }, Placeholders: null }],
208215
CreatedBy: {
209216
__type: 'Pointer',
210217
className: '_User',
@@ -235,6 +242,7 @@ export default function reportJson(id, userId) {
235242
reportClass: 'contracts_Template',
236243
params: {
237244
Type: { $ne: 'Folder' },
245+
IsArchive: { $ne: true },
238246
CreatedBy: {
239247
__type: 'Pointer',
240248
className: '_User',

apps/OpenSignServer/databases/migrations/20231208132950-update_template_menu.cjs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ exports.up = async Parse => {
5959
},
6060
{
6161
icon: 'fas fa-folder',
62-
title: 'OpenSignDrive™',
62+
title: 'OpenSign™ Drive',
6363
target: '_self',
6464
pageType: 'mf',
6565
description: '',
@@ -206,6 +206,15 @@ exports.up = async Parse => {
206206
description: '',
207207
objectId: '6TeaPr321t',
208208
},
209+
{
210+
icon: 'fas fa-folder',
211+
title: 'OpenSign™ Drive',
212+
target: '_self',
213+
pageType: 'mf',
214+
description: '',
215+
objectId:
216+
'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/legadrive',
217+
},
209218
{
210219
icon: 'fas fa-address-card',
211220
title: 'Reports',
@@ -576,4 +585,4 @@ exports.down = async Parse => {
576585
// schema.addString('name').addNumber('cash');
577586
const batch = [revertUserMenu, revertAdminMenu];
578587
return Parse.Object.saveAll(batch, { useMasterKey: true });
579-
};
588+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
*
3+
* @param {Parse} Parse
4+
*/
5+
exports.up = async Parse => {
6+
// TODO: set className here
7+
const className = 'contracts_Document';
8+
const schema = new Parse.Schema(className);
9+
schema.addBoolean('IsArchive');
10+
return schema.update();
11+
};
12+
13+
/**
14+
*
15+
* @param {Parse} Parse
16+
*/
17+
exports.down = async Parse => {
18+
// TODO: set className here
19+
const className = 'contracts_Document';
20+
const schema = new Parse.Schema(className);
21+
schema.deleteField('IsArchive');
22+
return schema.update();
23+
};

microfrontends/SignDocuments/src/Component/DraftDocument.js

Lines changed: 20 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -47,65 +47,34 @@ function DraftDocument() {
4747
//check document type and render on signyour self and placeholder route
4848
const handleDraftDoc = () => {
4949
const data = pdfDetails[0];
50-
const checkSignerExist =
51-
pdfDetails[0] && pdfDetails[0].Signers && pdfDetails[0].Signers;
52-
const isPlaceholder =
53-
pdfDetails[0].Placeholders && pdfDetails[0].Placeholders;
54-
const isDecline = data.IsDeclined && data.IsDeclined;
55-
const signUrl = data.SignedUrl && data.SignedUrl;
56-
const expireDate =
57-
pdfDetails[0] &&
58-
pdfDetails[0].ExpiryDate.iso &&
59-
pdfDetails[0].ExpiryDate.iso;
60-
const expireUpdateDate = new Date(expireDate).getTime();
61-
const currDate = new Date().getTime();
6250
const hostUrl = getHostUrl();
51+
const signerExist = data.Signers && data.Signers;
52+
const isDecline = data.IsDeclined && data.IsDeclined;
53+
const isPlaceholder = data.Placeholders && data.Placeholders;
6354

64-
//checking document is completed and signer exist then navigate to pdfRequestFiles file
65-
if (data.IsCompleted && checkSignerExist) {
66-
navigate(`${hostUrl}pdfRequestFiles`);
55+
//checking if document has completed and request signature flow
56+
if (data?.IsCompleted && signerExist?.length > 0) {
57+
navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`);
6758
}
68-
//checking document is completed and signer does not exist then navigate to recipientSignPdf file
69-
else if (data.IsCompleted && !checkSignerExist) {
70-
navigate(`${hostUrl}signaturePdf`);
59+
//checking if document has completed and signyour-self flow
60+
else if (!signerExist && !isPlaceholder) {
61+
navigate(`${hostUrl}signaturePdf/${data.objectId}`);
7162
}
72-
//checking document is declined by someone then navigate to pdfRequestFiles file
63+
//checking if document has declined by someone
7364
else if (isDecline) {
74-
navigate(`${hostUrl}pdfRequestFiles`);
75-
}
76-
//checking document has expired and signers exist and placeholder does not set yet then navigate to pdfRequestFiles file
77-
//draft type request sign document
78-
else if (
79-
currDate > expireUpdateDate &&
80-
checkSignerExist &&
81-
!isPlaceholder
82-
) {
83-
navigate(`${hostUrl}placeHolderSign`);
65+
navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`);
66+
//checking draft type document
8467
}
85-
//checking document has expired and signers does not exist and document not signed yet then navigate to pdfRequestFiles file
86-
//draft type signyouselfdocument
68+
//Inprogress document
69+
else if (isPlaceholder?.length > 0 && signerExist?.length > 0) {
70+
navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`);
71+
} //placeholder draft document
8772
else if (
88-
currDate > expireUpdateDate &&
89-
!checkSignerExist &&
90-
!isPlaceholder &&
91-
!signUrl
73+
(signerExist?.length > 0 &&
74+
(!isPlaceholder || isPlaceholder?.length === 0)) ||
75+
((!signerExist || signerExist?.length === 0) && isPlaceholder?.length > 0)
9276
) {
93-
// window.location.hash = `/signaturePdf`;
94-
navigate(`${hostUrl}signaturePdf`);
95-
}
96-
//checking document has expired and signers exist and document then navigate to pdfRequestFiles file
97-
else if (currDate > expireUpdateDate) {
98-
// window.location.hash = `/pdfRequestFiles`;
99-
navigate(`${hostUrl}pdfRequestFiles`);
100-
}
101-
//checking document has expired not been expired yet and signers exist and placeholder does not set yet then navigate to pdfRequestFiles file
102-
//draft type request sign document
103-
else if (!signUrl && checkSignerExist) {
104-
navigate(`${hostUrl}placeHolderSign`);
105-
// window.location.hash = `/placeHolderSign`;
106-
} else {
107-
// window.location.hash = `/signaturePdf/`;
108-
navigate(`${hostUrl}signaturePdf`);
77+
navigate(`${hostUrl}placeHolderSign/${data.objectId}`);
10978
}
11079
};
11180

0 commit comments

Comments
 (0)