Skip to content

Conversation

polypixeldev
Copy link
Member

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

@polypixeldev polypixeldev requested review from a team as code owners September 12, 2025 21:53
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Comment on lines 94 to 99

def inline_link
skip_authorization

@receipts = Receipt.in_receipt_bin.with_attached_file.where(user: current_user).order(created_at: :desc)
end
Copy link
Member

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

Copy link
Member

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

Copy link
Member Author

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?

Comment on lines +29 to +32
this.pasteData(response)
}

pasteData(response) {
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Comment on lines 15 to 20
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')
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worked on a new list that incorporates the file preview (using the payment-docs icon as fallback when there's no preview) - what do you think?
image

polypixeldev and others added 2 commits September 15, 2025 21:08
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants