-
Notifications
You must be signed in to change notification settings - Fork 62
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
||
def inline_link | ||
skip_authorization | ||
|
||
@receipts = Receipt.in_receipt_bin.with_attached_file.where(user: current_user).order(created_at: :desc) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should authorise this imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be as simple as current_user.receipts.build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose to skip authorization here since the the /my/inbox
page doesn't authorize anything either - what would the policy be checking?
this.pasteData(response) | ||
} | ||
|
||
pasteData(response) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
const files = this.fileInputTarget.files | ||
const newFile = files[files.length - 1] | ||
|
||
const html = `<li>${newFile.name}</li>` | ||
this.listTarget.innerHTML += html | ||
this.clearButtonTarget.classList.remove('hidden') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think may want to work on the styling a bit more. The list feels a little out of place at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary of the problem
https://hackclub.slack.com/archives/C068U0JMV19/p1757243106361769 - it'd be great to be able to choose from the receipt bin when attaching a receipt to a form! Plus, the current input for receipts was already repeated a lot and should be extracted into a partial.
Describe your changes
This extracts the receipt input into a new partial, which integrates the existing file upload with the receipt bin link form, which has also been extracted into a new partial. With the new
receipt-input
Stimulus controller, users can upload or link any number of receipts to the form. Receipt data extraction is supported for receipts linked from the bin.On the controller side, each controller will parse the receipts parameter in addition to the file parameter and link them to the new receiptable if authorized.
Screencast.From.2025-09-12.17-51-55.mp4