From 8887da414f5a49ea9b19ae967364fa13807178d3 Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Wed, 24 Jan 2024 17:07:11 -0400 Subject: [PATCH 1/6] feat(utils): Adds helper method to create new button for filers --- src/assets/css/style.css | 11 +++++++++++ src/utils.js | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/assets/css/style.css b/src/assets/css/style.css index bc18d6f0..3e3168ad 100644 --- a/src/assets/css/style.css +++ b/src/assets/css/style.css @@ -522,6 +522,17 @@ footer #version { margin-right: 0.25rem; } +.recap-bttn-for-filers { + margin-left: 5px; + border-radius: 3px; + border-style: solid; + border-width: thin; + font-family: helvetica, arial, serif; + font-size: 13px; + height: 21.5px; + border-color: #255885; +} + /* For printed pages, we want to hide anything that we add. */ @media print { [class^="recap-"], [id^="recap-"] { /* Any class or ID that starts with `recap-` */ diff --git a/src/utils.js b/src/utils.js index 8aa69e2e..8d6a19f5 100644 --- a/src/utils.js +++ b/src/utils.js @@ -458,4 +458,13 @@ async function getPacerCaseIdFromPacerDocId(tabId, pacer_doc_id) { const success = `RECAP: Got case number ${caseId} for docId ${pacer_doc_id}`; console.info(success); return caseId; -} \ No newline at end of file +} + +//Creates an extra button for filer accounts +function createRecapButtonForFilers(description) { + let button = document.createElement('input'); + button.type = 'submit'; + button.value = description; + button.classList.add('btn-primary', 'recap-bttn-for-filers'); + return button +} From ae4f39cfdad02e25df92447a0151326e28d0f588 Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Wed, 24 Jan 2024 17:23:12 -0400 Subject: [PATCH 2/6] feat(district): Adds the new button for filers to the single doc page --- spec/ContentDelegateSpec.js | 1 + src/content_delegate.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/spec/ContentDelegateSpec.js b/spec/ContentDelegateSpec.js index 80182889..0a39ff19 100644 --- a/spec/ContentDelegateSpec.js +++ b/spec/ContentDelegateSpec.js @@ -957,6 +957,7 @@ describe('The ContentDelegate class', function () { table.appendChild(table_tr); document.body.appendChild(table); spyOn(window, 'addEventListener').and.callThrough(); + spyOnProperty(document, 'cookie').and.returnValue('test_cookie1=false; test_cookie2=true; isFilingAccount=false'); }); afterEach(function () { diff --git a/src/content_delegate.js b/src/content_delegate.js index 974f51b1..b2c05c44 100644 --- a/src/content_delegate.js +++ b/src/content_delegate.js @@ -482,7 +482,23 @@ ContentDelegate.prototype.handleSingleDocumentPageView = function () { return; } - overwriteFormSubmitMethod(); + if (PACER.hasFilingCookie(document.cookie)) { + let table = document.querySelector('form > center'); + table.style.paddingBottom = '10px'; + + // Create a new button for filers accounts and add onclick + // event listener to intercept navigation to the PDF document + let button = createRecapButtonForFilers('View and RECAP Document'); + button.addEventListener('click', () => { + overwriteFormSubmitMethod(); + }); + + // add the new button inside the form + let form = document.querySelector('form'); + form.append(button); + } else { + overwriteFormSubmitMethod(); + } // When we receive the message from the above submit method, submit the form // via XHR so we can get the document before the browser does. From a99e47df45741d3dc28841d9ff85d6b0c35eb797 Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Wed, 24 Jan 2024 17:24:59 -0400 Subject: [PATCH 3/6] feat(district): Adds the new button to the download ZIP page --- src/content_delegate.js | 45 +++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/src/content_delegate.js b/src/content_delegate.js index b2c05c44..8d25316f 100644 --- a/src/content_delegate.js +++ b/src/content_delegate.js @@ -679,6 +679,7 @@ ContentDelegate.prototype.onDownloadAllSubmit = async function (event) { document.getElementById('recap-download').click(); } history.pushState({ content: document.body.innerHTML }, ''); + $('body').css('cursor', 'pointer'); } } ); @@ -714,21 +715,35 @@ ContentDelegate.prototype.handleZipFilePageView = function () { } // imperatively manipulate hte dom elements without injecting a script - const forms = [...document.querySelectorAll('form')]; - forms.map((form) => { - form.removeAttribute('action'); - const input = form.querySelector('input'); - input.removeAttribute('onclick'); - input.disabled = true; - form.hidden = true; - const div = document.createElement('div'); - const button = document.createElement('button'); - button.textContent = 'Download Documents'; - button.addEventListener('click', () => window.postMessage({ id: url })); - div.appendChild(button); - const parentNode = form.parentNode; - parentNode.insertBefore(div, form); - }); + if (PACER.hasFilingCookie(document.cookie)) { + const inputs = [...document.querySelectorAll("form > input[type='button']")]; + inputs.map((input) => { + let button = createRecapButtonForFilers('Download and RECAP Documents'); + button.addEventListener('click', (event) => { + event.preventDefault(); + window.postMessage({ id: url }); + }); + // insert new button next to the "Download Documents" button + input.after(button); + }); + } else { + // imperatively manipulate html dom elements without injecting a script + const forms = [...document.querySelectorAll('form')]; + forms.map((form) => { + form.removeAttribute('action'); + const input = form.querySelector('input'); + input.removeAttribute('onclick'); + input.disabled = true; + form.hidden = true; + const div = document.createElement('div'); + const button = document.createElement('button'); + button.textContent = 'Download Documents'; + button.addEventListener('click', () => window.postMessage({ id: url })); + div.appendChild(button); + const parentNode = form.parentNode; + parentNode.insertBefore(div, form); + }); + } // When we receive the message from the above submit method, submit the form // via fetch so we can get the document before the browser does. window.addEventListener('message', this.onDownloadAllSubmit.bind(this)); From 2bcf5592e07ed183b38655b0199afa8ae748cf38 Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Wed, 24 Jan 2024 17:29:10 -0400 Subject: [PATCH 4/6] feat(appellate): Adds the new button for filers to the single doc page --- src/appellate/appellate.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/appellate/appellate.js b/src/appellate/appellate.js index cdd09cc2..9cab4969 100644 --- a/src/appellate/appellate.js +++ b/src/appellate/appellate.js @@ -396,7 +396,20 @@ AppellateDelegate.prototype.handleCombinedPdfPageView = async function () { // If this page offers a single document, intercept navigation to the document view page. AppellateDelegate.prototype.handleSingleDocumentPageView = async function () { - overwriteFormSubmitMethod(); + if (PACER.hasFilingCookie(document.cookie)) { + let button = createRecapButtonForFilers('Accept Charges and RECAP Document'); + button.addEventListener('click', (event) => { + event.preventDefault(); + let form = event.target.parentNode; + form.id = 'form' + new Date().getTime(); + window.postMessage({ id: form.id }, '*'); + }); + + let form = document.querySelector('form'); + form.append(button); + } else { + overwriteFormSubmitMethod(); + } this.pacer_case_id = await APPELLATE.getCaseId(this.tabId, this.queryParameters, this.docId); From 4c8bdb2fe3a2fc0ad38725a19ed31ef91a2e998d Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Wed, 24 Jan 2024 18:37:28 -0400 Subject: [PATCH 5/6] docs(changelog): Updates the changes.md file --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 47863ceb..8b35e4b3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ The following changes are not yet released, but are code complete: Features: - Hide recap UI elements from printed pages([#360](https://github.com/freelawproject/recap/issues/360), [#355](https://github.com/freelawproject/recap-chrome/pull/355)). + - Provide two clearly labeled buttons on the RECAP receipt page for accounts with filing permissions: one to RECAP the document and the other to download it normally([#360](https://github.com/freelawproject/recap/issues/357), [#355](https://github.com/freelawproject/recap-chrome/pull/357)). Changes: - Shift focus to support: Rename 'Help' tab to 'Donate' and enhance content.([#359](https://github.com/freelawproject/recap/issues/359), [#356](https://github.com/freelawproject/recap-chrome/pull/356)). From 72b2c7d53ca50eb3dd3e3d5726f26d2c1fc962a8 Mon Sep 17 00:00:00 2001 From: Eduardo Rosendo Date: Wed, 24 Jan 2024 20:02:21 -0400 Subject: [PATCH 6/6] feat(utils): Tweak the order of css classes for the new bttn This PR updates the order of the CSS classes for the new filter button, allowing us to hide it during printing. --- src/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.js b/src/utils.js index 8d6a19f5..0030d4d3 100644 --- a/src/utils.js +++ b/src/utils.js @@ -465,6 +465,6 @@ function createRecapButtonForFilers(description) { let button = document.createElement('input'); button.type = 'submit'; button.value = description; - button.classList.add('btn-primary', 'recap-bttn-for-filers'); + button.classList.add('recap-bttn-for-filers', 'btn-primary'); return button }