From 9d2d3604e113fb16cb8ebd7eda541b2ab8f989d1 Mon Sep 17 00:00:00 2001 From: divyav-aot Date: Wed, 6 Dec 2023 14:29:45 -0500 Subject: [PATCH 01/13] statuslabel changes --- api/reviewer_api/resources/document.py | 2 +- .../services/docReviewerService.tsx | 2 +- web/src/constants/enum.ts | 36 +++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/api/reviewer_api/resources/document.py b/api/reviewer_api/resources/document.py index e398d6bc8..cde76a9fd 100644 --- a/api/reviewer_api/resources/document.py +++ b/api/reviewer_api/resources/document.py @@ -103,7 +103,7 @@ def get(requestid): "requesttype": jsonobj["requestType"] } result = documentservice().getdocuments(requestid, requestinfo["bcgovcode"]) - return json.dumps({"requeststatusid": jsonobj["requeststatusid"], "documents": result, "requestnumber":jsonobj["axisRequestId"], "requestinfo":requestinfo}), 200 + return json.dumps({"requeststatuslabel": jsonobj["requeststatuslabel"], "documents": result, "requestnumber":jsonobj["axisRequestId"], "requestinfo":requestinfo}), 200 except KeyError as error: return {'status': False, 'message': CUSTOM_KEYERROR_MESSAGE + str(error)}, 400 except BusinessException as exception: diff --git a/web/src/apiManager/services/docReviewerService.tsx b/web/src/apiManager/services/docReviewerService.tsx index 9570161d5..33107e644 100644 --- a/web/src/apiManager/services/docReviewerService.tsx +++ b/web/src/apiManager/services/docReviewerService.tsx @@ -23,7 +23,7 @@ export const fetchDocuments = ( const __files = res.data.documents.filter((d: any) => !d.attributes.incompatible); store.dispatch(setDocumentList(__files) as any); store.dispatch(setRequestNumber(res.data.requestnumber) as any); - store.dispatch(setRequestStatus(res.data.requeststatusid) as any); + store.dispatch(setRequestStatus(res.data.requeststatuslabel) as any); store.dispatch(setRequestInfo(res.data.requestinfo) as any); callback(res.data.documents); } else { diff --git a/web/src/constants/enum.ts b/web/src/constants/enum.ts index 4d27fe768..4c31ff2d5 100644 --- a/web/src/constants/enum.ts +++ b/web/src/constants/enum.ts @@ -66,27 +66,27 @@ const pageFlagTypes:pageFlagType = { }; type RequestStatesType = { - [key: string]: number + [key: string]: string } const RequestStates:RequestStatesType = { - "Open": 1, - "Call For Records": 2, - "Closed": 3, - "Redirect": 4, - "Unopened": 5, - "Intake in Progress": 6, - "Records Review": 7, - "Fee Estimate": 8, - "Consult": 9, - "Ministry Sign Off": 10, - "On Hold": 11, - "Deduplication": 12, - "Harms Assessment": 13, - "Response": 14, - "Archived": 15, - "Peer Review": 16, - "Call For Records Overdue": 17 + "Open": "open", + "Call For Records": "callforrecords", + "Closed": "closed", + "Redirect": "redirect", + "Unopened": "unopened", + "Intake in Progress": "intakeinprogress", + "Records Review": "recordsreview", + "Fee Estimate": "feeestimate", + "Consult": "consult", + "Ministry Sign Off": "ministrysignoff", + "On Hold": "onhold", + "Deduplication": "deduplication", + "Harms Assessment": "harmsassessment", + "Response": "response", + "Archived": "archived", + "Peer Review": "peerreview", + "Call For Records Overdue": "callforrecordsoverdue" }; export { From 97f8228034765b34de9c3c2f35da9e700f203582 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Dec 2023 17:10:06 -0800 Subject: [PATCH 02/13] revert to old regex for side by side image and add regex start at to test memory performance --- .../MCS.FOI.MSGToPDF/MSGFileProcessor.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDF/MSGFileProcessor.cs b/MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDF/MSGFileProcessor.cs index d0e0bb009..a05a4265d 100644 --- a/MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDF/MSGFileProcessor.cs +++ b/MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDF/MSGFileProcessor.cs @@ -142,6 +142,7 @@ public MSGFileProcessor(Stream sourceStream) } foreach (var inlineAttachment in inlineAttachments.OrderBy(m => m.GetType().GetProperty("RenderingPosition").GetValue(m, null))) { + var startAt = 0; if (rtfInline) { if (!inlineAttachment.GetType().FullName.ToLower().Contains("message")) @@ -172,7 +173,10 @@ public MSGFileProcessor(Stream sourceStream) else if (htmlInline) { var _inlineAttachment = (Storage.Attachment)inlineAttachment; - bodyreplaced = Regex.Replace(bodyreplaced, "src=\"cid:" + _inlineAttachment.ContentId, "style=\"max-width: 700px\" src=\"data:" + _inlineAttachment.MimeType + ";base64," + Convert.ToBase64String(_inlineAttachment.Data)); + Regex regex = new Regex(").)*cid:" + _inlineAttachment.ContentId + ".*?>"); + Match match = regex.Match(bodyreplaced, startAt); + bodyreplaced = regex.Replace(bodyreplaced, "", 1, startAt); + startAt = match.Index + match.Length; foreach (KeyValuePair> attachment in attachmentsObj) { if (attachment.Value.ContainsKey("cid") && attachment.Value["cid"] == _inlineAttachment.ContentId) From 2ae04cb173b5252bac6f895f1f3a4afaa1de0cfc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Dec 2023 19:28:39 -0800 Subject: [PATCH 03/13] fix logic for starting off regex from the previous match for inline attachments --- MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDF/MSGFileProcessor.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDF/MSGFileProcessor.cs b/MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDF/MSGFileProcessor.cs index a05a4265d..1226ddfa3 100644 --- a/MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDF/MSGFileProcessor.cs +++ b/MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDF/MSGFileProcessor.cs @@ -140,9 +140,9 @@ public MSGFileProcessor(Stream sourceStream) inlineAttachments.Add(_attachment); } } + var startAt = 0; foreach (var inlineAttachment in inlineAttachments.OrderBy(m => m.GetType().GetProperty("RenderingPosition").GetValue(m, null))) { - var startAt = 0; if (rtfInline) { if (!inlineAttachment.GetType().FullName.ToLower().Contains("message")) @@ -173,7 +173,7 @@ public MSGFileProcessor(Stream sourceStream) else if (htmlInline) { var _inlineAttachment = (Storage.Attachment)inlineAttachment; - Regex regex = new Regex(").)*cid:" + _inlineAttachment.ContentId + ".*?>"); + Regex regex = new Regex(""); Match match = regex.Match(bodyreplaced, startAt); bodyreplaced = regex.Replace(bodyreplaced, "", 1, startAt); startAt = match.Index + match.Length; From 3b2c1f614ef2ba04de1531641d7b4c18f7b3c74f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Dec 2023 20:54:09 -0800 Subject: [PATCH 04/13] additional fix for logic for starting from last regex match --- .../MCS.FOI.MSGToPDF/MSGFileProcessor.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDF/MSGFileProcessor.cs b/MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDF/MSGFileProcessor.cs index 1226ddfa3..7788ca506 100644 --- a/MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDF/MSGFileProcessor.cs +++ b/MCS.FOI.S3FileConversion/MCS.FOI.MSGToPDF/MSGFileProcessor.cs @@ -175,8 +175,12 @@ public MSGFileProcessor(Stream sourceStream) var _inlineAttachment = (Storage.Attachment)inlineAttachment; Regex regex = new Regex(""); Match match = regex.Match(bodyreplaced, startAt); - bodyreplaced = regex.Replace(bodyreplaced, "", 1, startAt); - startAt = match.Index + match.Length; + if (match.Success) + { + string imgReplacementString = ""; + bodyreplaced = regex.Replace(bodyreplaced, imgReplacementString, 1, startAt); + startAt = match.Index + imgReplacementString.Length; + } foreach (KeyValuePair> attachment in attachmentsObj) { if (attachment.Value.ContainsKey("cid") && attachment.Value["cid"] == _inlineAttachment.ContentId) From d946232f33ef6a91fd8a3699ae1053816572b796 Mon Sep 17 00:00:00 2001 From: divyav-aot Date: Wed, 13 Dec 2023 11:18:46 -0500 Subject: [PATCH 05/13] fix related to dedupe --- .../DedupeServices/services/s3documentservice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/computingservices/DedupeServices/services/s3documentservice.py b/computingservices/DedupeServices/services/s3documentservice.py index d6545f851..957da66cb 100644 --- a/computingservices/DedupeServices/services/s3documentservice.py +++ b/computingservices/DedupeServices/services/s3documentservice.py @@ -77,8 +77,8 @@ def extract_annotations_from_pdf(pdf_document, output_bytestream): new_content = legend_text + ":The comment text of the annotation is added as part of the pdf." index += 1 author = annot.info.get('title', '') - if author: - new_author = "Original Document Comment" + # if author: + new_author = "Original Document Comment" annot.set_info(content=new_content,title=new_author) annot.update() annot_dict = { From 953fca2f5e5d5cdeb5acf44b37c6a65a393baa7f Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Mon, 8 Jan 2024 15:16:39 -0800 Subject: [PATCH 06/13] Upgraded PyMuPDF in pdf stitching to latest version 1.28.3 which now better supports large complex PDF files. Therefore, these pdf files are now being stitched accoringly for harms. Additionally, upgradded PyMuPDf library for other computing services (dedupe and zipping) as well. --- .../DedupeServices/requirements.txt | Bin 828 -> 828 bytes .../PDFStitchServices/requirements.txt | Bin 794 -> 794 bytes .../ZippingServices/requirements.txt | Bin 794 -> 794 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/computingservices/DedupeServices/requirements.txt b/computingservices/DedupeServices/requirements.txt index e37cdf8ed73f8796e78c3e49ffa6195ef9b0dee4..9daf46526c5d86a11167a4dd9e6e85f8fc57ee0b 100644 GIT binary patch delta 13 UcmdnPwufzl95bWEWO-&;03A>RVE_OC delta 13 UcmdnPwufzl95bWYWO-&;03AjHUjP6A diff --git a/computingservices/PDFStitchServices/requirements.txt b/computingservices/PDFStitchServices/requirements.txt index 7d9085b5a04a6a9f5682534942d258defd126530..b3534182531b7515a69641cd7e53a6dcfeb1eb50 100644 GIT binary patch delta 18 ZcmbQmHj8b;3r1FB20aFg&2JfX838vy1xEk? delta 18 ZcmbQmHj8b;3r1EW20aGD&2JfX838v81wQ}) diff --git a/computingservices/ZippingServices/requirements.txt b/computingservices/ZippingServices/requirements.txt index 7d9085b5a04a6a9f5682534942d258defd126530..b3534182531b7515a69641cd7e53a6dcfeb1eb50 100644 GIT binary patch delta 18 ZcmbQmHj8b;3r1FB20aFg&2JfX838vy1xEk? delta 18 ZcmbQmHj8b;3r1EW20aGD&2JfX838v81wQ}) From 1839e99af8c57160a22465a0ffb54724b814a2cc Mon Sep 17 00:00:00 2001 From: divyav-aot Date: Thu, 11 Jan 2024 11:20:04 -0500 Subject: [PATCH 07/13] filtered comments added in state variable --- web/src/components/FOI/Home/Redlining.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/web/src/components/FOI/Home/Redlining.js b/web/src/components/FOI/Home/Redlining.js index 743a88a1e..6038901cc 100644 --- a/web/src/components/FOI/Home/Redlining.js +++ b/web/src/components/FOI/Home/Redlining.js @@ -273,6 +273,8 @@ const Redlining = React.forwardRef( isReadyForSignOff() && requestStatus == RequestStates["Response"] ); + const [filteredComments, setFilteredComments] = useState({}); + // if using a class, equivalent of componentDidMount useEffect(() => { let initializeWebViewer = async () => { @@ -308,6 +310,7 @@ const Redlining = React.forwardRef( documentViewer.setToolMode( documentViewer.getTool(instance.Core.Tools.ToolNames.REDACTION) ); + const UIEvents = instance.UI.Events; //customize header - insert a dropdown button const document = instance.UI.iframeWindow.document; setIframeDocument(document); @@ -524,6 +527,22 @@ const Redlining = React.forwardRef( console.log("Error:", error); }); }); + + instance.UI.addEventListener(UIEvents.ANNOTATION_FILTER_CHANGED, e => { + e.detail.types = e.detail.types.map(type => { + switch (type) { + case "stickyNote": + return "text"; + case "rectangle": + return "square"; + case "freehand": + return "ink"; + default: + return type; + } + }); + setFilteredComments(e.detail); + }); documentViewer.addEventListener("click", async () => { scrollLeftPanel(documentViewer.getCurrentPage()); From 2c2268e3f2d17aa885789fe6f4a8ae3f6d3a997d Mon Sep 17 00:00:00 2001 From: divyav-aot Date: Thu, 11 Jan 2024 11:26:18 -0500 Subject: [PATCH 08/13] filtered comments added in state variable --- web/src/components/FOI/Home/Redlining.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/web/src/components/FOI/Home/Redlining.js b/web/src/components/FOI/Home/Redlining.js index 743a88a1e..6038901cc 100644 --- a/web/src/components/FOI/Home/Redlining.js +++ b/web/src/components/FOI/Home/Redlining.js @@ -273,6 +273,8 @@ const Redlining = React.forwardRef( isReadyForSignOff() && requestStatus == RequestStates["Response"] ); + const [filteredComments, setFilteredComments] = useState({}); + // if using a class, equivalent of componentDidMount useEffect(() => { let initializeWebViewer = async () => { @@ -308,6 +310,7 @@ const Redlining = React.forwardRef( documentViewer.setToolMode( documentViewer.getTool(instance.Core.Tools.ToolNames.REDACTION) ); + const UIEvents = instance.UI.Events; //customize header - insert a dropdown button const document = instance.UI.iframeWindow.document; setIframeDocument(document); @@ -524,6 +527,22 @@ const Redlining = React.forwardRef( console.log("Error:", error); }); }); + + instance.UI.addEventListener(UIEvents.ANNOTATION_FILTER_CHANGED, e => { + e.detail.types = e.detail.types.map(type => { + switch (type) { + case "stickyNote": + return "text"; + case "rectangle": + return "square"; + case "freehand": + return "ink"; + default: + return type; + } + }); + setFilteredComments(e.detail); + }); documentViewer.addEventListener("click", async () => { scrollLeftPanel(documentViewer.getCurrentPage()); From cd50f5d21fd28159ca8a22e85e908823e97515e6 Mon Sep 17 00:00:00 2001 From: Aparna Date: Thu, 11 Jan 2024 15:48:47 -0800 Subject: [PATCH 09/13] Filter on redline - 4862 --- web/src/components/FOI/Home/Redlining.js | 42 ++++++++++++++++++++---- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/web/src/components/FOI/Home/Redlining.js b/web/src/components/FOI/Home/Redlining.js index 6038901cc..36406a592 100644 --- a/web/src/components/FOI/Home/Redlining.js +++ b/web/src/components/FOI/Home/Redlining.js @@ -2358,6 +2358,7 @@ const Redlining = React.forwardRef( docCounter++; documentRedlineAnnotations[documentid] = data[documentid]; if (docCounter == documentids.length) { + console.log("documentRedlineAnnotations:",documentRedlineAnnotations) setRedlineDocumentAnnotations(documentRedlineAnnotations); } } @@ -2412,12 +2413,20 @@ const Redlining = React.forwardRef( documentid ) => { let updatedXML = []; + let _freeTextIds=[]; for (let annotxml of data) { let xmlObj = parser.parseFromString(annotxml); - if (xmlObj.name === "redact" || xmlObj.name === "freetext") { + //console.log("xmlObj:", xmlObj); + let filterComments = {"types":["note","rectangle"],"authors":["dviswana@idir"], + "colors":["#ffcd45ff","#4e7de9ff","#007a3bff"],"statuses":[],"checkRepliesForAuthorFilter":true}; + //if (xmlObj.name === "redact" || xmlObj.name === "freetext" || xmlObj.name === "text") { + if(xmlObj.name === "freetext") + _freeTextIds.push(xmlObj.attributes.name); let customfield = xmlObj.children.find( (xmlfield) => xmlfield.name == "trn-custom-data" ); + let flags = xmlObj.attributes.flags; + //console.log("flags:",flags) let txt = domParser.parseFromString( customfield.attributes.bytes, "text/html" @@ -2434,17 +2443,36 @@ const Redlining = React.forwardRef( 'page="' + (redlinepageMappings[documentid][originalPageNo + 1] - 1) + '"'; + // let updatedBytes= customfield.attributes.bytes.slice(0, 1) +""trn-annot-locked":"true","trn-annot-no-move":"true","+ + // customfield.attributes.bytes.slice(1); + + let updatedFlags = xmlObj.attributes.flags+',locked'; + + annotxml = annotxml.replace(flags, updatedFlags); + //console.log("annotxml AFTER:",annotxml) annotxml = annotxml.replace(oldPageNum, newPage); + console.log("filteredComments:",filteredComments); - if (xmlObj.name === "redact" || customData["parentRedaction"]) { - updatedXML.push(annotxml); - } - } + //if (xmlObj.name === "redact" || customData["parentRedaction"] || xmlObj.name === "text") { + if (xmlObj.name === "redact" || customData["parentRedaction"] || + (Object.entries(filteredComments).length> 0 && checkFilter(xmlObj,_freeTextIds))) + updatedXML.push(annotxml); + //} } } return updatedXML.join(); }; + const checkFilter = (xmlObj,_freeTextIds) => { + console.log("Color:",xmlObj.attributes.color+'ff'); + if(filteredComments['types'].length >0 || filteredComments["colors"].length >0 || filteredComments["authors"].length >0){ + return (filteredComments['types'].includes(xmlObj.name) && !_freeTextIds.includes(xmlObj.attributes.InReplyTo))|| + filteredComments["colors"].includes(xmlObj.attributes.color.toLowerCase()+'ff')|| + filteredComments["authors"].includes(xmlObj.attributes.title); + } + return false; + } + const cancelSaveRedlineDoc = () => { setRedlineModalOpen(false); }; @@ -2886,6 +2914,8 @@ const Redlining = React.forwardRef( redlinepageMappings["pagestoremove"][divisionid] ); } + // const annotManager1= docViewer.getAnnotationManager(); + // let abcannot= annotManager1.flattenAnnotations(formattedAnnotationXML) let xfdfString = '' + formattedAnnotationXML + @@ -2895,7 +2925,7 @@ const Redlining = React.forwardRef( // saves the document with annotations in it xfdfString: xfdfString, downloadType: downloadType, - flatten: true, + //flatten: true, }) .then(async (_data) => { const _arr = new Uint8Array(_data); From b52774b2f5d7186740df7901faba39f925c93d76 Mon Sep 17 00:00:00 2001 From: Aparna Date: Fri, 12 Jan 2024 12:07:28 -0800 Subject: [PATCH 10/13] Fix for replies --- web/src/components/FOI/Home/Redlining.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/web/src/components/FOI/Home/Redlining.js b/web/src/components/FOI/Home/Redlining.js index 36406a592..7efb40158 100644 --- a/web/src/components/FOI/Home/Redlining.js +++ b/web/src/components/FOI/Home/Redlining.js @@ -2414,6 +2414,7 @@ const Redlining = React.forwardRef( ) => { let updatedXML = []; let _freeTextIds=[]; + let _annoteIds=[]; for (let annotxml of data) { let xmlObj = parser.parseFromString(annotxml); //console.log("xmlObj:", xmlObj); @@ -2422,6 +2423,8 @@ const Redlining = React.forwardRef( //if (xmlObj.name === "redact" || xmlObj.name === "freetext" || xmlObj.name === "text") { if(xmlObj.name === "freetext") _freeTextIds.push(xmlObj.attributes.name); + else if(xmlObj.name != "redact" && xmlObj.name != "freetext") + _annoteIds.push(xmlObj.attributes.name) let customfield = xmlObj.children.find( (xmlfield) => xmlfield.name == "trn-custom-data" ); @@ -2455,7 +2458,7 @@ const Redlining = React.forwardRef( //if (xmlObj.name === "redact" || customData["parentRedaction"] || xmlObj.name === "text") { if (xmlObj.name === "redact" || customData["parentRedaction"] || - (Object.entries(filteredComments).length> 0 && checkFilter(xmlObj,_freeTextIds))) + (Object.entries(filteredComments).length> 0 && checkFilter(xmlObj,_freeTextIds,_annoteIds))) updatedXML.push(annotxml); //} } @@ -2463,10 +2466,11 @@ const Redlining = React.forwardRef( return updatedXML.join(); }; - const checkFilter = (xmlObj,_freeTextIds) => { + const checkFilter = (xmlObj,_freeTextIds, _annoteIds) => { console.log("Color:",xmlObj.attributes.color+'ff'); if(filteredComments['types'].length >0 || filteredComments["colors"].length >0 || filteredComments["authors"].length >0){ - return (filteredComments['types'].includes(xmlObj.name) && !_freeTextIds.includes(xmlObj.attributes.InReplyTo))|| + return (filteredComments['types'].includes(xmlObj.name) && !_freeTextIds.includes(xmlObj.attributes.inreplyto))|| + _annoteIds.includes(xmlObj.attributes.inreplyto)|| filteredComments["colors"].includes(xmlObj.attributes.color.toLowerCase()+'ff')|| filteredComments["authors"].includes(xmlObj.attributes.title); } From 7db32096983ef019e9cbcc1bd5bbc176cd55b032 Mon Sep 17 00:00:00 2001 From: Aparna Date: Fri, 12 Jan 2024 15:13:25 -0800 Subject: [PATCH 11/13] Need fixes --- web/src/components/FOI/Home/Redlining.js | 63 +++++++++++++++++++++--- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/web/src/components/FOI/Home/Redlining.js b/web/src/components/FOI/Home/Redlining.js index 7efb40158..708ae8e2e 100644 --- a/web/src/components/FOI/Home/Redlining.js +++ b/web/src/components/FOI/Home/Redlining.js @@ -2423,8 +2423,12 @@ const Redlining = React.forwardRef( //if (xmlObj.name === "redact" || xmlObj.name === "freetext" || xmlObj.name === "text") { if(xmlObj.name === "freetext") _freeTextIds.push(xmlObj.attributes.name); - else if(xmlObj.name != "redact" && xmlObj.name != "freetext") - _annoteIds.push(xmlObj.attributes.name) + else if(xmlObj.name != "redact" && xmlObj.name != "freetext"){ + let xmlObjAnnotId = xmlObj.attributes.name; + _annoteIds.push({ [xmlObjAnnotId]: xmlObj }); + + } + let customfield = xmlObj.children.find( (xmlfield) => xmlfield.name == "trn-custom-data" ); @@ -2468,13 +2472,56 @@ const Redlining = React.forwardRef( const checkFilter = (xmlObj,_freeTextIds, _annoteIds) => { console.log("Color:",xmlObj.attributes.color+'ff'); - if(filteredComments['types'].length >0 || filteredComments["colors"].length >0 || filteredComments["authors"].length >0){ - return (filteredComments['types'].includes(xmlObj.name) && !_freeTextIds.includes(xmlObj.attributes.inreplyto))|| - _annoteIds.includes(xmlObj.attributes.inreplyto)|| - filteredComments["colors"].includes(xmlObj.attributes.color.toLowerCase()+'ff')|| - filteredComments["authors"].includes(xmlObj.attributes.title); + let isType = filteredComments['types'].includes(xmlObj.name) && !_freeTextIds.includes(xmlObj.attributes.inreplyto); + let isColor = filteredComments["colors"].includes(xmlObj.attributes.color.toLowerCase()+'ff'); + let isAuthor = filteredComments["authors"].includes(xmlObj.attributes.title); + + let parentIsType = _annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + filteredComments['types'].includes(_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto))?.[xmlObj.attributes.inreplyto].name) && + !_freeTextIds.includes(_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto))?.[xmlObj.attributes.inreplyto].attributes.inreplyto); + let parentIsColor = _annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + filteredComments["colors"].length >0 && + filteredComments["colors"].includes(_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto))?.[xmlObj.attributes.inreplyto].attributes.color.toLowerCase()+'ff'); + let parentIsAuthor = _annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + filteredComments["authors"].length >0 && + filteredComments["authors"].includes(_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto))?.[xmlObj.attributes.inreplyto].attributes.title); + + // if(filteredComments['types'].length >0 || filteredComments["colors"].length >0 || filteredComments["authors"].length >0){ + // return (filteredComments['types'].includes(xmlObj.name) && !_freeTextIds.includes(xmlObj.attributes.inreplyto)) + // && filteredComments["colors"].includes(xmlObj.attributes.color.toLowerCase()+'ff') && + // filteredComments["authors"].includes(xmlObj.attributes.title) || + // (_annoteIds.find(xmlObj.attributes.inreplyto) && _annoteIds.includes(xmlObj.attributes.inreplyto)); + // } + let inreplytoBool = _annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + (parentIsType || parentIsColor || parentIsAuthor); + + if(!(_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + (parentIsType || parentIsColor || parentIsAuthor))){ + return false; + } + else{ + if (filteredComments['types'].length > 0 && filteredComments['colors'].length > 0 && filteredComments['authors'].length > 0) { + return isType && isColor && isAuthor + } + else if (filteredComments['types'].length > 0 && filteredComments['colors'].length > 0) { + return isType && isColor } - return false; + else if (filteredComments['types'].length > 0 && filteredComments['authors'].length > 0) { + return isType && isAuthor + } + else if (filteredComments['colors'].length > 0 && filteredComments['authors'].length > 0) { + return isColor && isAuthor + } + else if (filteredComments['types'].length > 0 ) { + return isType + } + else if (filteredComments['colors'].length > 0 ) { + return isColor + } + else { + return isAuthor + } + } } const cancelSaveRedlineDoc = () => { From c59ddf32d228ff7513221f0e6fed804c682b7ba7 Mon Sep 17 00:00:00 2001 From: divyav-aot Date: Mon, 15 Jan 2024 17:51:30 -0500 Subject: [PATCH 12/13] filter validation updated --- web/src/components/FOI/Home/Redlining.js | 115 +++++++++++++++-------- 1 file changed, 76 insertions(+), 39 deletions(-) diff --git a/web/src/components/FOI/Home/Redlining.js b/web/src/components/FOI/Home/Redlining.js index 708ae8e2e..b8833c00e 100644 --- a/web/src/components/FOI/Home/Redlining.js +++ b/web/src/components/FOI/Home/Redlining.js @@ -2471,57 +2471,94 @@ const Redlining = React.forwardRef( }; const checkFilter = (xmlObj,_freeTextIds, _annoteIds) => { - console.log("Color:",xmlObj.attributes.color+'ff'); - let isType = filteredComments['types'].includes(xmlObj.name) && !_freeTextIds.includes(xmlObj.attributes.inreplyto); - let isColor = filteredComments["colors"].includes(xmlObj.attributes.color.toLowerCase()+'ff'); - let isAuthor = filteredComments["authors"].includes(xmlObj.attributes.title); + let filtered = false; + + const isType = filteredComments.types.includes(xmlObj.name) && !_freeTextIds.includes(xmlObj.attributes.inreplyto); + const isColor = filteredComments.colors.includes(xmlObj.attributes.color.toLowerCase() + 'ff'); + const isAuthor = filteredComments.authors.includes(xmlObj.attributes.title); - let parentIsType = _annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && - filteredComments['types'].includes(_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto))?.[xmlObj.attributes.inreplyto].name) && + const parentIsType = _annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + filteredComments.types?.includes(_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto))?.[xmlObj.attributes.inreplyto].name) && !_freeTextIds.includes(_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto))?.[xmlObj.attributes.inreplyto].attributes.inreplyto); - let parentIsColor = _annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && - filteredComments["colors"].length >0 && - filteredComments["colors"].includes(_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto))?.[xmlObj.attributes.inreplyto].attributes.color.toLowerCase()+'ff'); - let parentIsAuthor = _annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && - filteredComments["authors"].length >0 && - filteredComments["authors"].includes(_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto))?.[xmlObj.attributes.inreplyto].attributes.title); - - // if(filteredComments['types'].length >0 || filteredComments["colors"].length >0 || filteredComments["authors"].length >0){ - // return (filteredComments['types'].includes(xmlObj.name) && !_freeTextIds.includes(xmlObj.attributes.inreplyto)) - // && filteredComments["colors"].includes(xmlObj.attributes.color.toLowerCase()+'ff') && - // filteredComments["authors"].includes(xmlObj.attributes.title) || - // (_annoteIds.find(xmlObj.attributes.inreplyto) && _annoteIds.includes(xmlObj.attributes.inreplyto)); - // } - let inreplytoBool = _annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && - (parentIsType || parentIsColor || parentIsAuthor); - - if(!(_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && - (parentIsType || parentIsColor || parentIsAuthor))){ - return false; - } - else{ - if (filteredComments['types'].length > 0 && filteredComments['colors'].length > 0 && filteredComments['authors'].length > 0) { - return isType && isColor && isAuthor + + const parentIsColor = _annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + filteredComments.colors?.includes(_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto))?.[xmlObj.attributes.inreplyto].attributes.color.toLowerCase()+'ff'); + + const parentIsAuthor = _annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + filteredComments.authors?.includes(_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto))?.[xmlObj.attributes.inreplyto].attributes.title); + + if (filteredComments.types.length > 0 && filteredComments.colors.length > 0 && filteredComments.authors.length > 0) { + if((_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + (parentIsType && parentIsColor && parentIsAuthor))){ + return true; + } + else if (typeof parentIsType !== 'undefined' && typeof parentIsColor !== 'undefined' && typeof parentIsAuthor !== 'undefined') { + return parentIsType && parentIsColor && parentIsAuthor + } + filtered = isType && (isColor || parentIsColor) && isAuthor } - else if (filteredComments['types'].length > 0 && filteredComments['colors'].length > 0) { - return isType && isColor + else if (filteredComments.types.length > 0 && filteredComments.colors.length > 0) { + if((_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + (parentIsType && parentIsColor))){ + return true; + } + else if (typeof parentIsType !== 'undefined' && typeof parentIsColor !== 'undefined') { + return parentIsType && parentIsColor + } + filtered = isType && (isColor || parentIsColor) } - else if (filteredComments['types'].length > 0 && filteredComments['authors'].length > 0) { - return isType && isAuthor + else if (filteredComments.types.length > 0 && filteredComments.authors.length > 0) { + if((_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + (parentIsType && parentIsAuthor))){ + return true; + } + else if (typeof parentIsType !== 'undefined' && typeof parentIsAuthor !== 'undefined') { + return parentIsType && parentIsAuthor + } + filtered = isType && isAuthor } - else if (filteredComments['colors'].length > 0 && filteredComments['authors'].length > 0) { - return isColor && isAuthor + else if (filteredComments.colors.length > 0 && filteredComments.authors.length > 0) { + if((_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + (parentIsColor && parentIsAuthor))){ + return true; + } + else if (typeof parentIsColor !== 'undefined' && typeof parentIsAuthor !== 'undefined') { + return parentIsColor && parentIsAuthor + } + filtered = (isColor || parentIsColor) && isAuthor } - else if (filteredComments['types'].length > 0 ) { + + else if (filteredComments.types.length > 0) { + if((_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + (parentIsType ))){ + return true; + } + else if (typeof parentIsType !== 'undefined') { + return parentIsType + } return isType } - else if (filteredComments['colors'].length > 0 ) { + else if (filteredComments.colors.length > 0) { + if((_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + (parentIsColor ))){ + return true; + } + else if (typeof parentIsColor !== 'undefined') { + return parentIsColor + } return isColor } - else { + else if (filteredComments.authors.length > 0) { + if((_annoteIds.find(obj => obj.hasOwnProperty(xmlObj.attributes.inreplyto)) && + (parentIsAuthor ))){ + return true; + } + else if (typeof parentIsAuthor !== 'undefined') { + return parentIsAuthor + } return isAuthor } - } + return filtered; } const cancelSaveRedlineDoc = () => { From 3f46eb5f603b40923508f2ccfd5fe88934385a34 Mon Sep 17 00:00:00 2001 From: divyav-aot Date: Tue, 16 Jan 2024 13:26:14 -0500 Subject: [PATCH 13/13] removed logs, commented line, reverted #4707 changed --- api/reviewer_api/resources/document.py | 2 +- .../services/docReviewerService.tsx | 2 +- web/src/components/FOI/Home/Redlining.js | 23 ++---------- web/src/constants/enum.ts | 36 +++++++++---------- 4 files changed, 23 insertions(+), 40 deletions(-) diff --git a/api/reviewer_api/resources/document.py b/api/reviewer_api/resources/document.py index cde76a9fd..e398d6bc8 100644 --- a/api/reviewer_api/resources/document.py +++ b/api/reviewer_api/resources/document.py @@ -103,7 +103,7 @@ def get(requestid): "requesttype": jsonobj["requestType"] } result = documentservice().getdocuments(requestid, requestinfo["bcgovcode"]) - return json.dumps({"requeststatuslabel": jsonobj["requeststatuslabel"], "documents": result, "requestnumber":jsonobj["axisRequestId"], "requestinfo":requestinfo}), 200 + return json.dumps({"requeststatusid": jsonobj["requeststatusid"], "documents": result, "requestnumber":jsonobj["axisRequestId"], "requestinfo":requestinfo}), 200 except KeyError as error: return {'status': False, 'message': CUSTOM_KEYERROR_MESSAGE + str(error)}, 400 except BusinessException as exception: diff --git a/web/src/apiManager/services/docReviewerService.tsx b/web/src/apiManager/services/docReviewerService.tsx index 33107e644..9570161d5 100644 --- a/web/src/apiManager/services/docReviewerService.tsx +++ b/web/src/apiManager/services/docReviewerService.tsx @@ -23,7 +23,7 @@ export const fetchDocuments = ( const __files = res.data.documents.filter((d: any) => !d.attributes.incompatible); store.dispatch(setDocumentList(__files) as any); store.dispatch(setRequestNumber(res.data.requestnumber) as any); - store.dispatch(setRequestStatus(res.data.requeststatuslabel) as any); + store.dispatch(setRequestStatus(res.data.requeststatusid) as any); store.dispatch(setRequestInfo(res.data.requestinfo) as any); callback(res.data.documents); } else { diff --git a/web/src/components/FOI/Home/Redlining.js b/web/src/components/FOI/Home/Redlining.js index b8833c00e..128243989 100644 --- a/web/src/components/FOI/Home/Redlining.js +++ b/web/src/components/FOI/Home/Redlining.js @@ -2358,7 +2358,6 @@ const Redlining = React.forwardRef( docCounter++; documentRedlineAnnotations[documentid] = data[documentid]; if (docCounter == documentids.length) { - console.log("documentRedlineAnnotations:",documentRedlineAnnotations) setRedlineDocumentAnnotations(documentRedlineAnnotations); } } @@ -2417,23 +2416,16 @@ const Redlining = React.forwardRef( let _annoteIds=[]; for (let annotxml of data) { let xmlObj = parser.parseFromString(annotxml); - //console.log("xmlObj:", xmlObj); - let filterComments = {"types":["note","rectangle"],"authors":["dviswana@idir"], - "colors":["#ffcd45ff","#4e7de9ff","#007a3bff"],"statuses":[],"checkRepliesForAuthorFilter":true}; - //if (xmlObj.name === "redact" || xmlObj.name === "freetext" || xmlObj.name === "text") { if(xmlObj.name === "freetext") _freeTextIds.push(xmlObj.attributes.name); else if(xmlObj.name != "redact" && xmlObj.name != "freetext"){ let xmlObjAnnotId = xmlObj.attributes.name; _annoteIds.push({ [xmlObjAnnotId]: xmlObj }); - - } - + } let customfield = xmlObj.children.find( (xmlfield) => xmlfield.name == "trn-custom-data" ); let flags = xmlObj.attributes.flags; - //console.log("flags:",flags) let txt = domParser.parseFromString( customfield.attributes.bytes, "text/html" @@ -2450,21 +2442,14 @@ const Redlining = React.forwardRef( 'page="' + (redlinepageMappings[documentid][originalPageNo + 1] - 1) + '"'; - // let updatedBytes= customfield.attributes.bytes.slice(0, 1) +""trn-annot-locked":"true","trn-annot-no-move":"true","+ - // customfield.attributes.bytes.slice(1); - - let updatedFlags = xmlObj.attributes.flags+',locked'; + let updatedFlags = xmlObj.attributes.flags+',locked'; annotxml = annotxml.replace(flags, updatedFlags); - //console.log("annotxml AFTER:",annotxml) annotxml = annotxml.replace(oldPageNum, newPage); console.log("filteredComments:",filteredComments); - - //if (xmlObj.name === "redact" || customData["parentRedaction"] || xmlObj.name === "text") { if (xmlObj.name === "redact" || customData["parentRedaction"] || (Object.entries(filteredComments).length> 0 && checkFilter(xmlObj,_freeTextIds,_annoteIds))) updatedXML.push(annotxml); - //} } } return updatedXML.join(); @@ -3002,8 +2987,6 @@ const Redlining = React.forwardRef( redlinepageMappings["pagestoremove"][divisionid] ); } - // const annotManager1= docViewer.getAnnotationManager(); - // let abcannot= annotManager1.flattenAnnotations(formattedAnnotationXML) let xfdfString = '' + formattedAnnotationXML + @@ -3013,7 +2996,7 @@ const Redlining = React.forwardRef( // saves the document with annotations in it xfdfString: xfdfString, downloadType: downloadType, - //flatten: true, + //flatten: true, //commented this as part of #4862 }) .then(async (_data) => { const _arr = new Uint8Array(_data); diff --git a/web/src/constants/enum.ts b/web/src/constants/enum.ts index 4c31ff2d5..4d27fe768 100644 --- a/web/src/constants/enum.ts +++ b/web/src/constants/enum.ts @@ -66,27 +66,27 @@ const pageFlagTypes:pageFlagType = { }; type RequestStatesType = { - [key: string]: string + [key: string]: number } const RequestStates:RequestStatesType = { - "Open": "open", - "Call For Records": "callforrecords", - "Closed": "closed", - "Redirect": "redirect", - "Unopened": "unopened", - "Intake in Progress": "intakeinprogress", - "Records Review": "recordsreview", - "Fee Estimate": "feeestimate", - "Consult": "consult", - "Ministry Sign Off": "ministrysignoff", - "On Hold": "onhold", - "Deduplication": "deduplication", - "Harms Assessment": "harmsassessment", - "Response": "response", - "Archived": "archived", - "Peer Review": "peerreview", - "Call For Records Overdue": "callforrecordsoverdue" + "Open": 1, + "Call For Records": 2, + "Closed": 3, + "Redirect": 4, + "Unopened": 5, + "Intake in Progress": 6, + "Records Review": 7, + "Fee Estimate": 8, + "Consult": 9, + "Ministry Sign Off": 10, + "On Hold": 11, + "Deduplication": 12, + "Harms Assessment": 13, + "Response": 14, + "Archived": 15, + "Peer Review": 16, + "Call For Records Overdue": 17 }; export {