fix: attachment behavior allows and respects custom view definitions#7811
Merged
acwhite211 merged 6 commits intomainfrom Mar 18, 2026
Merged
fix: attachment behavior allows and respects custom view definitions#7811acwhite211 merged 6 commits intomainfrom
acwhite211 merged 6 commits intomainfrom
Conversation
Triggered by 07dacdd on branch refs/heads/issue-5078
alesan99
approved these changes
Mar 16, 2026
Contributor
alesan99
left a comment
There was a problem hiding this comment.
- Define a custom Attachment view definition (
Collection Object Attachment, for example) - Upload an attachment to a Collection Object
- Confirm that custom view definition is respected in the UI
- Click on the form’s meta tools button then click the "From Definition" button and see that there is a link to “Edit Form Definition”
- Confirm that you are routed to the correct view definition
- Go back to the image you uploaded on the CO form and save it
- Confirm that custom view definition is still respected
- Confirm that image is saved (via Attachments tab or QB)
Edit form definition button appears correctly
Works for both Collection Object Attachments and Accession Attachments, nice job!
CarolineDenis
approved these changes
Mar 18, 2026
Triggered by a204b89 on branch refs/heads/issue-5078
bhumikaguptaa
approved these changes
Mar 18, 2026
Collaborator
bhumikaguptaa
left a comment
There was a problem hiding this comment.
- Define a custom Attachment view definition (
Collection Object Attachment, for example) - Upload an attachment to a Collection Object
- Confirm that custom view definition is respected in the UI
- Click on the form’s meta tools button then click the "From Definition" button and see that there is a link to “Edit Form Definition”
- Confirm that you are routed to the correct view definition
- Go back to the image you uploaded on the CO form and save it
- Confirm that custom view definition is still respected
- Confirm that image is saved (via Attachments tab or QB)
--
Looks good! I am able to see the correct view definition and verify image being saved.
acwhite211
approved these changes
Mar 18, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #5078
Before this fix, when a user defined a custom view definition for an attachment form (
CollectionObjectAttachment, for example), the "Edit Form Definition" link never appeared in the form meta tools button. This was because attachment views were resolved from a local hardcoded definition; the server was never queried, so noviewSetIdwas ever available.This fix introduces changes that enable a user to define a custom view definition and have it honored when they are uploading an image to a Collection Object, for example.
Regarding image uploads, Specify defines the following view definitions (non-exhaustive):
ObjectAttachmentview definition is assigned when viewing an attachment from Gift, Loan, Permit, Preparation, Locality, etc.CollectionObjectAttachmentview definition when viewing a Collection Object’s attachmentAttachmentFormview definition when viewing an Attachment form directlyThe specific changes are outlined as follows:
useViewDefinition.tsx: When resolving an attachment view, now fetches both the specific table view (CollectionObjectAttachment) and the generic ObjectAttachment view in parallel. Whichever has a viewsetId wins, and that ID is surfaced as viewSetId on the returned ViewDescription so the "Edit Form Definition" link can appearindex.ts: AddedisAttachmentPlugin?: trueto theViewDescriptiontype. This is a flag set on all attachment views, used bySpecifyForm.tsxandFormTable.tsxto decide when to render the attachment pluginSpecifyForm.tsxandFormTable.tsx: Replaced theviewDefinition.name === 'ObjectAttachment'condition withviewDefinition.isAttachmentPluginso any view with a different name (likeCollectionObjectAttachment) is now acceptedPlugin.tsx: FixedtableIDbeing set incorrectly on upload. The code now removes the "Attachment" suffix from the resource's table name to find the parent table (locates CollectionObject from CollectionObjectAttachment, for example) and uses that table's ID instead to determine where the attachment should liveChecklist
self-explanatory (or properly documented)
Testing instructions
Collection Object Attachment, for example)