-
Notifications
You must be signed in to change notification settings - Fork 67
Add new receipt input partial with support for receipt bin #11660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
polypixeldev
wants to merge
28
commits into
main
Choose a base branch
from
polypixeldev/link-receipt-input
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
5fbc859
Add receipt bin select to ach transfer input
polypixeldev dd42fd2
Move controller
polypixeldev fadb5ae
Merge branch 'main' into polypixeldev/link-receipt-input
polypixeldev 84e6703
Improve frontend for new receipt input
polypixeldev 6cdc257
Add padding
polypixeldev 4c6cc3b
Add extraction from receipt bin
polypixeldev acf9e13
Fix extraction bug
polypixeldev bd26d4b
Rename inline-receipt to receipt-input
polypixeldev 3428204
Disable add button when no receipts
polypixeldev 50d8cde
Add newlines
polypixeldev 29608b7
Add required option
polypixeldev f8cdeb2
Add extraction option
polypixeldev f24cb7a
Add receipt input to disbursements
polypixeldev 285d4e2
Add new receipt input to checks
polypixeldev f4b53df
Add new receipt input to paypal transfers
polypixeldev a692490
Add new receipt input to wires
polypixeldev fb6b14a
Add new receipt input to wise transfers
polypixeldev badadf0
Don't add extraction action if not enabled
polypixeldev 558a347
Merge branch 'main' into polypixeldev/link-receipt-input
polypixeldev b0020db
Fix disabling of add button
polypixeldev 666f1c0
Fix ERB formatting
polypixeldev 51b70ca
Send receipts link list as array instead of string
polypixeldev 2a21f26
Use current_user.receipts
polypixeldev bc39304
Fix JS formatting
polypixeldev c85e442
Remove extra class
polypixeldev 715c9e2
Add new receipt list with previews
polypixeldev 8900545
Fix light mode
polypixeldev d5a8f8a
Fix CSS and JS formatting
polypixeldev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,12 +26,20 @@ export default class extends Controller { | |
Turbo.navigator.delegate.adapter.progressBar.hide() | ||
document.querySelector('html').setAttribute('data-ai-loading', false) | ||
|
||
this.pasteData(response) | ||
} | ||
|
||
pasteData(response) { | ||
Comment on lines
+29
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. by "pasting" do you mean filling the form? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
let empty = true | ||
|
||
const extractedKeys = Object.keys(response).filter( | ||
key => response[key] !== null | ||
) | ||
|
||
Array.from(this.formTarget.elements).map(element => { | ||
if ( | ||
element.dataset.extractionField && | ||
Object.keys(response).includes(element.dataset.extractionField) | ||
extractedKeys.includes(element.dataset.extractionField) | ||
) { | ||
if (element.value != '') { | ||
empty = false | ||
|
@@ -40,42 +48,47 @@ export default class extends Controller { | |
}) | ||
|
||
if (empty) { | ||
let success = false | ||
|
||
Array.from(this.formTarget.elements).map(element => { | ||
if ( | ||
element.dataset.extractionField && | ||
Object.keys(response).includes(element.dataset.extractionField) | ||
extractedKeys.includes(element.dataset.extractionField) | ||
) { | ||
element.value = response[element.dataset.extractionField] | ||
element.dispatchEvent(new Event('paste')) | ||
success = true | ||
} | ||
}) | ||
|
||
let dropzone = document.createElement('div') | ||
dropzone.classList.add('file-dropzone') | ||
dropzone.classList.add('data-extracted') | ||
if (success) { | ||
let dropzone = document.createElement('div') | ||
dropzone.classList.add('file-dropzone') | ||
dropzone.classList.add('data-extracted') | ||
|
||
const title = document.createElement('h1') | ||
title.innerText = '🧾 Successfully extracted!' | ||
dropzone.appendChild(title) | ||
const title = document.createElement('h1') | ||
title.innerText = '🧾 Successfully extracted!' | ||
dropzone.appendChild(title) | ||
|
||
document.body.appendChild(dropzone) | ||
document.body.style.overflow = 'hidden' | ||
document.body.appendChild(dropzone) | ||
document.body.style.overflow = 'hidden' | ||
|
||
// Explanation: https://stackoverflow.com/a/24195487/10987085 | ||
window.getComputedStyle(dropzone).opacity | ||
// Explanation: https://stackoverflow.com/a/24195487/10987085 | ||
window.getComputedStyle(dropzone).opacity | ||
|
||
dropzone.classList.add('visible') | ||
dropzone.classList.add('visible') | ||
|
||
const jsConfetti = new JSConfetti() | ||
const jsConfetti = new JSConfetti() | ||
|
||
jsConfetti | ||
.addConfetti({ | ||
emojis: '✨', | ||
}) | ||
.then(() => { | ||
dropzone.remove() | ||
document.body.style.overflow = 'auto' | ||
}) | ||
jsConfetti | ||
.addConfetti({ | ||
emojis: '✨', | ||
}) | ||
.then(() => { | ||
dropzone.remove() | ||
document.body.style.overflow = 'auto' | ||
}) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.