Skip to content
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

Partner profile -- rework additional documents to be more workable #4821

Open
3 tasks
cielf opened this issue Dec 1, 2024 · 7 comments
Open
3 tasks

Partner profile -- rework additional documents to be more workable #4821

cielf opened this issue Dec 1, 2024 · 7 comments

Comments

@cielf
Copy link
Collaborator

cielf commented Dec 1, 2024

Summary

Currently, the Additional documents only allows access to one document. We want to really allow multiple documents, and to also allow deleting documents

Why?

We need both the ability to have multiple documents and user deletion of old documents to support long term partner bank relationships.

Details

  • This is on the partner profile edit - both as a bank and as a partner
  • We should be able to actually upload more than one document
  • We need to add the ability to selectively delete documents. The interface for this should similar to how we allow removal of items. Provide a remove button, which, when pushed, makes the file disappear from the interface. Once saved, it is gone.

HINT: From Discussion on PR 4505

"The Partner::Profile model does in theory support multiple attached documents:

has_many_attached :documents
But when I attach a new one, there's an ActiveStorage::PurgeJob running that removes the old one."

Criteria for completion

  • Behaviour as described above
  • Tests to support
  • This will also need a change to the user docs
@danielabar danielabar self-assigned this Dec 2, 2024
@github-actions github-actions bot removed the Help Wanted Groomed + open to all! label Dec 2, 2024
@danielabar
Copy link
Collaborator

Found this in the Rails Guide on Active Storage that might explain the existing observed behaviour that old docs are getting removed when more are attached later:

Replacing vs Adding Attachments

By default in Rails, attaching files to a has_many_attached association will replace any existing attachments. To keep existing attachments, you can use hidden form fields with the signed_id of each attached file

@danielabar
Copy link
Collaborator

@cielf Just fyi, this commit fixes the original observed bug that if a user uploads an attached doc during profile edit, saves, then comes back later to add more, the first one is removed. It also supports attaching multiple docs, then coming back and adding one or more later, and all are preserved.

From there I can continue on the additional requirements re: selectively deleting.

But just in case the bug of losing documents when uploading more is urgent, that initial commit fixes that.

@cielf
Copy link
Collaborator Author

cielf commented Dec 9, 2024

I think it would be a fine idea to put that in as an initial PR that partially resolves this issue, as it is fixing a current problem, and the rest is adding functionality. Please and thanks!

@danielabar
Copy link
Collaborator

With regards to the related issue #4472 , where if a user selects a new document for upload, and enters something invalid in one of the other fields, and them submits the form for update, then they get a 500 Internal Server Error.

I have a solution on my branch that doesn't involve changing to direct uploads and new CORS config:

Firstly, when the form renders with validation errors, check that the existing documents are persisted before attempting to render them. This fixes the 500 Internal Server Error that would otherwise occur from trying to render a new unpersisted document.

Second, in the update action, it's possible to detect that user was trying to upload something. In this case, if a validation error occurs AND user was trying to upload an attached doc, render an additional alert telling them they'll need to select that doc again.

It will look like this:
image

Note that my solution fixes this for the Attached Documents section, not the IRS document (didn't want to scope creep into another ticket). If this solution is acceptable, then the developer working on the other ticket could use this solution as well.

@cielf
Copy link
Collaborator Author

cielf commented Dec 14, 2024

In an ideal world, they wouldn't have to re-upload.
It's better to have a world where they have to re-upload than a world where they lose the upload silently. IMO

Copy link
Contributor

This issue is marked as stale due to no activity within 30 days. If no further activity is detected within 7 days, it will be unassigned.

@github-actions github-actions bot added the stale label Jan 14, 2025
@danielabar
Copy link
Collaborator

Still a work-in-progress, although working on kind of related #4472 first.

@github-actions github-actions bot removed the stale label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants