diff --git a/apps/OpenSign/src/styles/loader.css b/apps/OpenSign/src/styles/loader.css index a401728ee..e6e1624f8 100644 --- a/apps/OpenSign/src/styles/loader.css +++ b/apps/OpenSign/src/styles/loader.css @@ -2211,7 +2211,5 @@ background-position: -2em 0; } } - .box:nth-of-type(n + 43) { - display: none; - } - \ No newline at end of file + + diff --git a/apps/OpenSignServer/cloud/parsefunction/getDocument.js b/apps/OpenSignServer/cloud/parsefunction/getDocument.js index 8666cafdf..a88a97cf4 100644 --- a/apps/OpenSignServer/cloud/parsefunction/getDocument.js +++ b/apps/OpenSignServer/cloud/parsefunction/getDocument.js @@ -21,6 +21,7 @@ export default async function getDocument(request) { query.include('Signers'); query.include('AuditTrail.UserPtr'); query.include('Placeholders'); + query.notEqualTo('IsArchive', true) const res = await query.first({ useMasterKey: true }); if (res) { const acl = res.getACL(); diff --git a/apps/OpenSignServer/cloud/parsefunction/getDrive.js b/apps/OpenSignServer/cloud/parsefunction/getDrive.js index 1813bc069..516ca9764 100644 --- a/apps/OpenSignServer/cloud/parsefunction/getDrive.js +++ b/apps/OpenSignServer/cloud/parsefunction/getDrive.js @@ -16,9 +16,9 @@ export default async function getDrive(request) { if (userId) { let url; if (docId) { - url = `${classUrl}?where={"Folder":{"__type":"Pointer","className":"contracts_Document","objectId":"${docId}"},"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${userId}"}}&include=ExtUserPtr,Signers,Folder`; + 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`; } else { - url = `${classUrl}?where={"Folder":{"$exists":false},"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${userId}"}}&include=ExtUserPtr,Signers`; + url = `${classUrl}?where={"Folder":{"$exists":false},"CreatedBy":{"__type":"Pointer","className":"_User","objectId":"${userId}"},"IsArchive":{"$ne":true}}&include=ExtUserPtr,Signers`; } try { const res = await axios.get(url, { diff --git a/apps/OpenSignServer/cloud/parsefunction/reportsJson.js b/apps/OpenSignServer/cloud/parsefunction/reportsJson.js index 12adf13a8..1ee858372 100644 --- a/apps/OpenSignServer/cloud/parsefunction/reportsJson.js +++ b/apps/OpenSignServer/cloud/parsefunction/reportsJson.js @@ -7,11 +7,11 @@ export default function reportJson(id, userId) { return { reportName: 'Draft Documents', params: { - Type: null, - $or: [ - { Signers: null, SignedUrl: null }, - { Signers: { $exists: true }, Placeholders: null }, - ], + Type: { $ne: 'Folder' }, + IsCompleted: { $ne: true }, + IsDeclined: { $ne: true }, + IsArchive: { $ne: true }, + $or: [{ Signers: null }, { Signers: { $exists: true }, Placeholders: null }], CreatedBy: { __type: 'Pointer', className: '_User', @@ -28,6 +28,7 @@ export default function reportJson(id, userId) { Type: { $ne: 'Folder' }, IsCompleted: { $ne: true }, IsDeclined: { $ne: true }, + IsArchive: { $ne: true }, ExpiryDate: { $gt: { __type: 'Date', iso: new Date().toISOString() }, }, @@ -66,6 +67,7 @@ export default function reportJson(id, userId) { Placeholders: { $ne: null }, IsCompleted: { $ne: true }, IsDeclined: { $ne: true }, + IsArchive: { $ne: true }, CreatedBy: { __type: 'Pointer', className: '_User', @@ -82,7 +84,7 @@ export default function reportJson(id, userId) { return { reportName: 'Completed Documents', params: { - Type: null, + Type: { $ne: 'Folder' }, IsCompleted: true, CreatedBy: { __type: 'Pointer', @@ -90,6 +92,7 @@ export default function reportJson(id, userId) { objectId: currentUserId, }, IsDeclined: { $ne: true }, + IsArchive: { $ne: true }, }, keys: [ 'Name', @@ -108,6 +111,7 @@ export default function reportJson(id, userId) { reportName: 'Declined Documents', params: { Type: null, + IsArchive: { $ne: true }, IsDeclined: true, CreatedBy: { __type: 'Pointer', @@ -125,6 +129,7 @@ export default function reportJson(id, userId) { params: { IsCompleted: { $ne: true }, IsDeclined: { $ne: true }, + IsArchive: { $ne: true }, Type: { $ne: 'Folder' }, $and: [ { @@ -157,6 +162,7 @@ export default function reportJson(id, userId) { Placeholders: { $ne: null }, IsCompleted: { $ne: true }, IsDeclined: { $ne: true }, + IsArchive: { $ne: true }, CreatedBy: { __type: 'Pointer', className: '_User', @@ -176,6 +182,7 @@ export default function reportJson(id, userId) { Type: { $ne: 'Folder' }, IsCompleted: { $ne: true }, IsDeclined: { $ne: true }, + IsArchive: { $ne: true }, ExpiryDate: { $gt: { __type: 'Date', iso: new Date().toISOString() }, }, @@ -200,11 +207,11 @@ export default function reportJson(id, userId) { return { reportName: 'Drafts', params: { - Type: null, - $or: [ - { Signers: null, SignedUrl: null }, - { Signers: { $exists: true }, Placeholders: null }, - ], + Type: { $ne: 'Folder' }, + IsCompleted: { $ne: true }, + IsDeclined: { $ne: true }, + IsArchive: { $ne: true }, + $or: [{ Signers: null }, { Signers: { $exists: true }, Placeholders: null }], CreatedBy: { __type: 'Pointer', className: '_User', @@ -235,6 +242,7 @@ export default function reportJson(id, userId) { reportClass: 'contracts_Template', params: { Type: { $ne: 'Folder' }, + IsArchive: { $ne: true }, CreatedBy: { __type: 'Pointer', className: '_User', diff --git a/apps/OpenSignServer/databases/migrations/20231208132950-update_template_menu.cjs b/apps/OpenSignServer/databases/migrations/20231208132950-update_template_menu.cjs index 774855dc6..e092c2db5 100644 --- a/apps/OpenSignServer/databases/migrations/20231208132950-update_template_menu.cjs +++ b/apps/OpenSignServer/databases/migrations/20231208132950-update_template_menu.cjs @@ -59,7 +59,7 @@ exports.up = async Parse => { }, { icon: 'fas fa-folder', - title: 'OpenSignDrive™', + title: 'OpenSign™ Drive', target: '_self', pageType: 'mf', description: '', @@ -206,6 +206,15 @@ exports.up = async Parse => { description: '', objectId: '6TeaPr321t', }, + { + icon: 'fas fa-folder', + title: 'OpenSign™ Drive', + target: '_self', + pageType: 'mf', + description: '', + objectId: + 'remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9TaWduLU1pY3JvYXBwVjIvcmVtb3RlRW50cnkuanM=&moduleToLoad=AppRoutes&remoteName=signmicroapp/legadrive', + }, { icon: 'fas fa-address-card', title: 'Reports', @@ -576,4 +585,4 @@ exports.down = async Parse => { // schema.addString('name').addNumber('cash'); const batch = [revertUserMenu, revertAdminMenu]; return Parse.Object.saveAll(batch, { useMasterKey: true }); -}; +}; \ No newline at end of file diff --git a/apps/OpenSignServer/databases/migrations/20240110100110-update_document_cls_cjs.cjs b/apps/OpenSignServer/databases/migrations/20240110100110-update_document_cls_cjs.cjs new file mode 100644 index 000000000..1a95b4f46 --- /dev/null +++ b/apps/OpenSignServer/databases/migrations/20240110100110-update_document_cls_cjs.cjs @@ -0,0 +1,23 @@ +/** + * + * @param {Parse} Parse + */ +exports.up = async Parse => { + // TODO: set className here + const className = 'contracts_Document'; + const schema = new Parse.Schema(className); + schema.addBoolean('IsArchive'); + return schema.update(); + }; + + /** + * + * @param {Parse} Parse + */ + exports.down = async Parse => { + // TODO: set className here + const className = 'contracts_Document'; + const schema = new Parse.Schema(className); + schema.deleteField('IsArchive'); + return schema.update(); + }; \ No newline at end of file diff --git a/microfrontends/SignDocuments/src/Component/DraftDocument.js b/microfrontends/SignDocuments/src/Component/DraftDocument.js index 95ab370b9..8384871f4 100644 --- a/microfrontends/SignDocuments/src/Component/DraftDocument.js +++ b/microfrontends/SignDocuments/src/Component/DraftDocument.js @@ -47,65 +47,34 @@ function DraftDocument() { //check document type and render on signyour self and placeholder route const handleDraftDoc = () => { const data = pdfDetails[0]; - const checkSignerExist = - pdfDetails[0] && pdfDetails[0].Signers && pdfDetails[0].Signers; - const isPlaceholder = - pdfDetails[0].Placeholders && pdfDetails[0].Placeholders; - const isDecline = data.IsDeclined && data.IsDeclined; - const signUrl = data.SignedUrl && data.SignedUrl; - const expireDate = - pdfDetails[0] && - pdfDetails[0].ExpiryDate.iso && - pdfDetails[0].ExpiryDate.iso; - const expireUpdateDate = new Date(expireDate).getTime(); - const currDate = new Date().getTime(); const hostUrl = getHostUrl(); + const signerExist = data.Signers && data.Signers; + const isDecline = data.IsDeclined && data.IsDeclined; + const isPlaceholder = data.Placeholders && data.Placeholders; - //checking document is completed and signer exist then navigate to pdfRequestFiles file - if (data.IsCompleted && checkSignerExist) { - navigate(`${hostUrl}pdfRequestFiles`); + //checking if document has completed and request signature flow + if (data?.IsCompleted && signerExist?.length > 0) { + navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`); } - //checking document is completed and signer does not exist then navigate to recipientSignPdf file - else if (data.IsCompleted && !checkSignerExist) { - navigate(`${hostUrl}signaturePdf`); + //checking if document has completed and signyour-self flow + else if (!signerExist && !isPlaceholder) { + navigate(`${hostUrl}signaturePdf/${data.objectId}`); } - //checking document is declined by someone then navigate to pdfRequestFiles file + //checking if document has declined by someone else if (isDecline) { - navigate(`${hostUrl}pdfRequestFiles`); + navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`); + //checking draft type document } - //checking document has expired and signers exist and placeholder does not set yet then navigate to pdfRequestFiles file - //draft type request sign document + //Inprogress document + else if (isPlaceholder?.length > 0 && signerExist?.length > 0) { + navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`); + } //placeholder draft document else if ( - currDate > expireUpdateDate && - checkSignerExist && - !isPlaceholder + (signerExist?.length > 0 && + (!isPlaceholder || isPlaceholder?.length === 0)) || + ((!signerExist || signerExist?.length === 0) && isPlaceholder?.length > 0) ) { - navigate(`${hostUrl}placeHolderSign`); - } - //checking document has expired and signers does not exist and document not signed yet then navigate to pdfRequestFiles file - //draft type signyouselfdocument - else if ( - currDate > expireUpdateDate && - !checkSignerExist && - !isPlaceholder && - !signUrl - ) { - // window.location.hash = `/signaturePdf`; - navigate(`${hostUrl}signaturePdf`); - } - //checking document has expired and signers exist and document then navigate to pdfRequestFiles file - else if (currDate > expireUpdateDate) { - // window.location.hash = `/pdfRequestFiles`; - navigate(`${hostUrl}pdfRequestFiles`); - } - //checking document has expired not been expired yet and signers exist and placeholder does not set yet then navigate to pdfRequestFiles file - //draft type request sign document - else if (!signUrl && checkSignerExist) { - navigate(`${hostUrl}placeHolderSign`); - // window.location.hash = `/placeHolderSign`; - } else { - // window.location.hash = `/signaturePdf/`; - navigate(`${hostUrl}signaturePdf`); + navigate(`${hostUrl}placeHolderSign/${data.objectId}`); } }; diff --git a/microfrontends/SignDocuments/src/Component/LegaDrive/FolderDrive/legaDriveComponent.js b/microfrontends/SignDocuments/src/Component/LegaDrive/FolderDrive/legaDriveComponent.js index 1c7ae57c1..760ce39af 100644 --- a/microfrontends/SignDocuments/src/Component/LegaDrive/FolderDrive/legaDriveComponent.js +++ b/microfrontends/SignDocuments/src/Component/LegaDrive/FolderDrive/legaDriveComponent.js @@ -10,6 +10,9 @@ import { getHostUrl } from "../../../utils/Utils"; import { useNavigate } from "react-router-dom"; import Table from "react-bootstrap/Table"; import * as HoverCard from "@radix-ui/react-hover-card"; +import SelectFolder from "../../../premitives/SelectFolder"; +import ModalUi from "../../../premitives/ModalUi"; +import { themeColor } from "../../../utils/ThemeColor/backColor"; function PdfFileComponent({ pdfData, @@ -22,7 +25,15 @@ function PdfFileComponent({ const [rename, setRename] = useState(""); const [renameValue, setRenameValue] = useState(""); const inputRef = useRef(null); - + const [isOpenMoveModal, setIsOpenMoveModal] = useState(false); + const [selectDoc, setSelectDoc] = useState(); + const [isDeleteDoc, setIsDeleteDoc] = useState(false); + const contextMenu = [ + { type: "Download", icon: "fa-solid fa-arrow-down" }, + { type: "Rename", icon: "fa-solid fa-font" }, + { type: "Move", icon: "fa-solid fa-file-export" }, + { type: "Delete", icon: "fa-solid fa-trash" } + ]; const navigate = useNavigate(); //to focus input box on press rename to change doc name @@ -100,74 +111,175 @@ function PdfFileComponent({ //function for navigate user to microapp-signature component const checkPdfStatus = async (data) => { const hostUrl = getHostUrl(); - const expireDate = data.ExpiryDate.iso; - const expireUpdateDate = new Date(expireDate).getTime(); - const currDate = new Date().getTime(); + const signerExist = data.Signers && data.Signers; - const signUrl = data.SignedUrl && data.SignedUrl; const isDecline = data.IsDeclined && data.IsDeclined; const isPlaceholder = data.Placeholders && data.Placeholders; - //checking and navigate to signyouself page - const checkPlaceHolder = data.Placeholders; - //checking if document has completed - if (data.IsCompleted && signerExist) { - navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`); - // window.location.hash = `/pdfRequestFiles/${data.objectId}`; - } else if (data.IsCompleted && !signerExist) { + //checking if document has completed and request signature flow + if (data?.IsCompleted && signerExist?.length > 0) { + navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`); + } + //checking if document has completed and signyour-self flow + else if (!signerExist && !isPlaceholder) { navigate(`${hostUrl}signaturePdf/${data.objectId}`); } //checking if document has declined by someone else if (isDecline) { navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`); - // window.location.hash = `/pdfRequestFiles/${data.objectId}`; - } else if (currDate > expireUpdateDate && signerExist && !isPlaceholder) { - // window.location.hash = `/placeHolderSign/${data.objectId}`; - navigate(`${hostUrl}placeHolderSign/${data.objectId}`); - } else if ( - currDate > expireUpdateDate && - !signerExist && - !isPlaceholder && - !signUrl - ) { - navigate(`${hostUrl}signaturePdf/${data.objectId}`); - // window.location.hash = `/signaturePdf/${data.objectId}`; + //checking draft type document } - //checking if document has expired - else if (currDate > expireUpdateDate) { + //Inprogress document + else if (isPlaceholder?.length > 0 && signerExist?.length > 0) { navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`); - // window.location.hash = `/pdfRequestFiles/${data.objectId}`; - } //checking if document is draft signers type and signers placeholder does not placed yet - else if (!signUrl && signerExist) { - // window.location.hash = `/placeHolderSign/${data.objectId}`; - navigate(`${hostUrl}placeHolderSign/${data.objectId}`); - } - //checking if document is request type and signers placeholder exist and does not completed yet - //then user can check progress of document and sign also + } //placeholder draft document else if ( - checkPlaceHolder && - checkPlaceHolder.length > 0 && - !data.IsCompleted + (signerExist?.length > 0 && + (!isPlaceholder || isPlaceholder?.length === 0)) || + ((!signerExist || signerExist?.length === 0) && isPlaceholder?.length > 0) ) { - navigate(`${hostUrl}pdfRequestFiles/${data.objectId}`); - // window.location.hash = `/pdfRequestFiles/${data.objectId}`; + navigate(`${hostUrl}placeHolderSign/${data.objectId}`); } - //checking document is draft and signyourself type then user can sign document - else { - navigate(`${hostUrl}signaturePdf/${data.objectId}`); - // navigate(`/signaturePdf/${data.objectId}`); - // window.location.hash = `/signaturePdf/${data.objectId}`; + }; + + const handleMenuItemClick = (selectType, data) => { + switch (selectType) { + case "Download": + const pdfName = data && data.Name; + const pdfUrl = data && data.SignedUrl ? data.SignedUrl : data.URL; + saveAs(pdfUrl, `${sanitizeFileName(pdfName)}_signed_by_OpenSign™.pdf`); + break; + case "Rename": + setRenameValue(data.Name); + setRename(data.objectId); + break; + case "Delete": + setIsDeleteDoc(true); + setSelectDoc(data); + break; + + case "Move": + handleMoveDocument(data); + break; } }; + //function for delete document + const handleDeleteDocument = async (docData) => { + setIsDeleteDoc(false); + const docId = docData.objectId; + const data = { + IsArchive: true + }; + + await axios + .put( + `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( + "_appName" + )}_Document/${docId}`, + data, + { + headers: { + "Content-Type": "application/json", + "X-Parse-Application-Id": localStorage.getItem("parseAppId"), + "X-Parse-Session-Token": localStorage.getItem("accesstoken") + } + } + ) + .then((result) => { + const res = result.data; + const updatedData = pdfData.filter((x) => x.objectId !== docId); + setPdfData(updatedData); + }) + .catch((err) => { + console.log("err", err); + }); + }; + const handleMoveDocument = async (docData) => { + setIsOpenMoveModal(true); + setSelectDoc(docData); + }; + //function for move document from one folder to another folder + const handleMoveFolder = async (selectFolderData) => { + const selecFolderId = selectDoc?.Folder?.objectId; + const moveFolderId = selectFolderData?.ObjectId; + let updateDocId = selectDoc?.objectId; + let updateData; + const checkExist = moveFolderId + ? selecFolderId === moveFolderId + ? true + : false + : selecFolderId + ? false + : true; + if (!checkExist) { + if (moveFolderId) { + updateData = { + Folder: { + __type: "Pointer", + className: `${localStorage.getItem("_appName")}_Document`, + objectId: moveFolderId + } + }; + } else { + updateData = { + Folder: { __op: "Delete" } + }; + } + + await axios + .put( + `${localStorage.getItem("baseUrl")}classes/${localStorage.getItem( + "_appName" + )}_Document/${updateDocId}`, + updateData, + { + headers: { + "Content-Type": "application/json", + "X-Parse-Application-Id": localStorage.getItem("parseAppId"), + "X-Parse-Session-Token": localStorage.getItem("accesstoken") + } + } + ) + + .then((Listdata) => { + // console.log("Listdata ", Listdata); + const json = Listdata.data; + + const updatedData = pdfData.filter((x) => x.objectId !== updateDocId); + setPdfData(updatedData); + }) + .catch((err) => { + console.log("err", err); + }); + + setIsOpenMoveModal(false); + } else { + alert("folder already exist!"); + setIsOpenMoveModal(false); + } + }; + + const sanitizeFileName = (pdfName) => { + // Replace spaces with underscore + return pdfName.replace(/ /g, "_"); + }; + + const handleEnterPress = (e, data) => { + if (e.key === "Enter") { + handledRenameDoc(data); + } + }; + + const handleDraftDoc = (data) => { + window.location.hash = `/mf/remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9MZWdhR2VuaWUtTWljcm9hcHBWMi9yZW1vdGVFbnRyeS5qcw==&moduleToLoad=AppRoutes&remoteName=legageniemicroapp/legagenie?${data.objectId}`; + }; //component to handle type of document and render according to type const handleFolderData = (data, ind, listType) => { - // console.log("data", data); let createddate, status, isDecline, signerExist, - isExpire, isComplete, signUrl, isPlaceholder; @@ -182,64 +294,48 @@ function PdfFileComponent({ signUrl = data.SignedUrl && data.SignedUrl; const expireUpdateDate = new Date(expireDate).getTime(); const currDate = new Date().getTime(); - + let isExpire = false; if (currDate > expireUpdateDate) { isExpire = true; - } else { - isExpire = false; } + if (isComplete) { status = "Completed"; } else if (isDecline) { status = "Declined"; - } else if (isExpire && !isPlaceholder && signerExist) { - // status = "Expired"; + } else if (!signerExist || signerExist?.length === 0) { status = "Draft"; - } else if (isExpire && !isPlaceholder && !signerExist && !signUrl) { - // status = "Expired"; + } else if ( + signerExist?.length > 0 && + (!isPlaceholder || isPlaceholder?.length === 0) + ) { status = "Draft"; } else if (isExpire) { status = "Expired"; - } else if (!signUrl) { - status = "Draft"; } else { - status = "InComplete"; + status = "In Progress"; } } - const handleDraftDoc = (data) => { - window.location.hash = `/mf/remoteUrl=aHR0cHM6Ly9xaWstYWktb3JnLmdpdGh1Yi5pby9MZWdhR2VuaWUtTWljcm9hcHBWMi9yZW1vdGVFbnRyeS5qcw==&moduleToLoad=AppRoutes&remoteName=legageniemicroapp/legagenie?${data.objectId}`; - }; + const signersName = () => { + const getSignersName = signerExist.map((data) => data.Name); + const signerName = getSignersName.join(","); - const handleMenuItemClick = (selectType, data) => { - // console.log("data",data) - if (selectType === "Download") { - // console.log("download") - const pdfName = data && data.Name; - const pdfUrl = data && data.SignedUrl ? data.SignedUrl : data.URL; - saveAs(pdfUrl, `${sanitizeFileName(pdfName)}_signed_by_OpenSign™.pdf`); - } else if (selectType === "Rename") { - // console.log("rename") - setRenameValue(data.Name); - setRename(data.objectId); - } + return ( + + {signerName}{" "} + + ); }; - - const sanitizeFileName = (pdfName) => { - // Replace spaces with underscore - return pdfName.replace(/ /g, "_"); - }; - - const handleEnterPress = (e, data) => { - if (e.key === "Enter") { - handledRenameDoc(data); - } - }; - return listType === "table" ? ( data.Type === "Folder" ? ( handleOnclikFolder(data)}> - +