Skip to content

ANW-1763: Add "Create and Link" for Related Accessions#3830

Merged
brianzelip merged 3 commits intomasterfrom
ANW-1763-accession-link-create-option
Feb 4, 2026
Merged

ANW-1763: Add "Create and Link" for Related Accessions#3830
brianzelip merged 3 commits intomasterfrom
ANW-1763-accession-link-create-option

Conversation

@Zeff
Copy link
Copy Markdown
Collaborator

@Zeff Zeff commented Dec 19, 2025

Summary

Adds inline creation functionality for Related Accessions on Resource forms. Users can now create a new accession directly from the Resource edit form via a modal, without navigating away from the page.

ANW-1763

Implementation Details

  • Follows existing inline creation pattern used by Subjects, Agents, and Top Containers
  • Controller checks inline? parameter to return JSON (inline) vs redirect (normal)
  • Permission-gated: "Create" button only visible to users with update_accession_record permission
  • Full form rendered in modal (not minimal form) for complete data entry in one step
  • JavaScript handled by existing linker.js (no JS changes needed)

Screenshots

SCR-20251219-imtk SCR-20251219-infu

How to Test

  1. Create a new resource (or navigate to a Resource edit page)
  2. Fill out required Resource fields if needed
  3. Find "Related Accessions" section
  4. Click the Accession dropdown
  5. Click the new "Create" option in the dropdown
  6. Create Accession form should be displayed in a modal window
  7. Fill out required fields and save
  8. Modal form should close and linked accession displayed in resource

@Zeff
Copy link
Copy Markdown
Collaborator Author

Zeff commented Dec 19, 2025

@thimios this still needs work but the basic functions are there. I need to get rid of the extra Create and Cancel buttons. I tried to reuse the full form and didn't think about that. Looks like that weird formatting you found in my last PR is in many files. So still cleaning up and need to add specs. Took some time trying to wrap my head around some of our helper functions.

@coveralls
Copy link
Copy Markdown

coveralls commented Dec 19, 2025

Pull Request Test Coverage Report for Build 21668976405

Details

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • 9509 unchanged lines in 269 files lost coverage.
  • Overall coverage decreased (-27.4%) to 51.925%

Files with Coverage Reduction New Missed Lines %
backend/app/controllers/component_transfer.rb 1 75.0%
backend/app/controllers/version.rb 1 80.0%
backend/app/model/mixins/directional_relationships.rb 1 97.44%
backend/app/model/vocabulary.rb 1 85.71%
backend/app/model/structured_date_range.rb 1 77.78%
backend/app/model/ASModel.rb 1 97.14%
backend/app/controllers/assessment.rb 1 91.67%
backend/app/model/collection_management.rb 1 86.67%
backend/app/controllers/system.rb 1 33.33%
frontend/app/models/edit_mediator.rb 1 91.53%
Totals Coverage Status
Change from base Build 15878865621: -27.4%
Covered Lines: 16336
Relevant Lines: 31461

💛 - Coveralls

@thimios
Copy link
Copy Markdown
Collaborator

thimios commented Dec 19, 2025

@Zeff looks good!

@Zeff Zeff force-pushed the ANW-1763-accession-link-create-option branch from cadd8e3 to f2f913f Compare December 19, 2025 21:24
@Zeff Zeff force-pushed the ANW-1763-accession-link-create-option branch 2 times, most recently from aa81074 to 48eb162 Compare January 6, 2026 23:21
Comment thread e2e-tests/staff_features/resources/step_definitions/resource_related_accession.rb Outdated
Comment thread frontend/spec/controllers/accessions_controller_spec.rb
Comment thread frontend/spec/controllers/accessions_controller_spec.rb
Comment thread frontend/spec/controllers/accessions_controller_spec.rb
@Zeff Zeff marked this pull request as ready for review January 7, 2026 13:30
@Zeff Zeff requested review from brianzelip and thimios January 7, 2026 13:34
Copy link
Copy Markdown
Collaborator

@brianzelip brianzelip left a comment

Choose a reason for hiding this comment

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

@Zeff looks great! The patterns here match the other three record types for including the linker Create option.

I notice that Accessions also have frontend/app/views/accession_links/_accession_linker.html.erb, which is the linker used by Archival Objects. (I'm not sure why this is the case.)

So this PR adds the Create option for the Related Accessions linker for the Resources and Accessions forms, but not the Archival Object form, see below:

ANW-1763-AO

Can you look into extending the linker Create option to this second accession linker?

@Zeff Zeff marked this pull request as draft January 7, 2026 16:08
@Zeff Zeff self-assigned this Jan 7, 2026
@Zeff
Copy link
Copy Markdown
Collaborator Author

Zeff commented Jan 7, 2026

@brianzelip

I notice that Accessions also have frontend/app/views/accession_links/_accession_linker.html.erb, which is the linker used by Archival Objects. (I'm not sure why this is the case.)

So this PR adds the Create option for the Related Accessions linker for the Resources and Accessions forms, but not the Archival Object form, see below:
Can you look into extending the linker Create option to this second accession linker?

Great catch! Digging in.

@Zeff Zeff force-pushed the ANW-1763-accession-link-create-option branch from 48eb162 to c0cdeb2 Compare January 7, 2026 20:12
@Zeff Zeff marked this pull request as ready for review January 8, 2026 19:49
@thimios thimios requested a review from brianzelip January 14, 2026 15:08
Copy link
Copy Markdown
Collaborator

@brianzelip brianzelip left a comment

Choose a reason for hiding this comment

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

@Zeff I noticed on the "Create modal" that pops up via the "Accession Links" subform on an Archival Object form which you just added, there's no modal header. The modal header should contain the heading "Create Accession" and a close button, but it's not there. It's possible this is unrelated to your work.

Can you please look into correcting this?

Screenshots

No header on an Archival Object "Accession Links" subform Create modal

Screenshot 2026-01-16 at 6 48 28 AM

With header on the Archival Object "Subjects" subform Create modal

(This subform is just beneath the "Accession Links" subform)

Screenshot 2026-01-16 at 6 49 06 AM

With header on the Resource "Related Accessions" Create modal

Screenshot 2026-01-16 at 6 49 49 AM

@Zeff
Copy link
Copy Markdown
Collaborator Author

Zeff commented Jan 20, 2026

@Zeff I noticed on the "Create modal" that pops up via the "Accession Links" subform on an Archival Object form which you just added, there's no modal header. The modal header should contain the heading "Create Accession" and a close button, but it's not there. It's possible this is unrelated to your work.

Can you please look into correcting this?

Fixed with latest commit.

@Zeff Zeff requested a review from brianzelip January 20, 2026 15:40
wait_for_ajax
end

When('the user clicks {string} in the dropdown menu') do |menu_item|
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

wait_for_ajax
end

Then('the related accession creation modal should be displayed') do
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rephrase as "the Related Accession creation modal is displayed" to follow the language of the rest of the test suite

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

end
end

When('the user fills in the inline accession form') do |table|
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed. Ultimately, I was able to get rid of two of my step definitions with reusing the shared ones. Took a little tweaking. Also, I missed the selector pattern that was being used and fixed that in a few places as well where I went with the modal ID.

Thanks, @thimios! This is definitely better. I'd love to spend some time in this to really get our e2e tests in my head and do even more cleanup.

You'll notice the entire feature was updated ... it was a line ending issue. In addition to the few step changes, changed all the line endings from CR/LF to LF. Not sure how that happened. Might have been my editor.

@brianzelip
Copy link
Copy Markdown
Collaborator

@Zeff @thimios This PR should wait for #3876 to be merged into master for any potential linker merge conflicts.

@Zeff Zeff force-pushed the ANW-1763-accession-link-create-option branch 2 times, most recently from cc2250e to 7537d52 Compare January 28, 2026 15:34
And the user fills in 'accession_title_' with 'Test Related Accession' in the modal
And the user fills in 'accession_accession_date_' with '2026-01-05' in the modal
And the user clicks on 'Create and Link' in the modal
Then the modal should close
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's remove this assertion as discussed

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

And the user fills in 'accession_accession_date_' with '2026-01-05' in the modal
And the user clicks on 'Create and Link' in the modal
Then the modal should close
And the accession 'Test Related Accession' should appear in the related accessions linker
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's remove also this then step from here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Then the modal should close
And the accession 'Test Related Accession' should appear in the related accessions linker

When the user saves the resource
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use the 'click the "save resource" step'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@brianzelip
Copy link
Copy Markdown
Collaborator

@Zeff the linker-related PR has now been merged, so this is ready to go once the feedback from @thimios has been implemented.

@Zeff Zeff force-pushed the ANW-1763-accession-link-create-option branch from 7537d52 to 725d765 Compare February 2, 2026 23:40
@Zeff
Copy link
Copy Markdown
Collaborator Author

Zeff commented Feb 2, 2026

@thimios I believe I was able to address the few things you mentioned, but overall I actually:

  • got rid of almost half of my step definitions in favor of shared step definitions
  • updated language appropriately
  • also created a new shared step definition as opposed to having it in my custom step definitions for resources that checks for error messages in modals

So thanks for your guidance here. I feel a lot better about it in its current state.

Ultimately, I found several other things I would like to change, but chose to stop as we should just refactor later. For example, in the helper.rb file, there's a step definition called "Given a Resource has been created", which would make you think you will end on a resource page, but it actually ends on an archival object page because it does more than just create a resource. So my step, 'When the user navigates to edit the resource" is a hack to get around that, but I didn't want to keep fixing these things and hold up the release.

==================== UPDATE =========================
After all that I found two more step definitions I forgot to delete, so I've actually removed more than half of my original step definitions. Thank you for dealing with the churn.

@Zeff Zeff requested a review from thimios February 3, 2026 15:05
@thimios thimios force-pushed the ANW-1763-accession-link-create-option branch from 7a0bc06 to f177cd1 Compare February 4, 2026 08:44
Zeff and others added 3 commits February 4, 2026 13:03
- Add inline Create and Link functionality for Related Accessions
- Create accessions controller inline mode (new, create actions)
- Add accessions form partials (_new, _form_inline)
- Add Create button to accessions linker dropdown
- Add E2E tests and RSpec feature tests
- Fix child record Accession Links
- Add .tool-versions file for e2e-tests
* Fix missing title for Archival Object accession linker
* Simplify and reuse shared steps
* Correct shared step and tense usage
* Remove two more non-shared step definitions
* prefer reusing existing steps than creating new ones
* follow existing wording pattern for new steps
@thimios thimios force-pushed the ANW-1763-accession-link-create-option branch from f177cd1 to f2d5305 Compare February 4, 2026 11:04
@brianzelip brianzelip merged commit cc68eb2 into master Feb 4, 2026
35 of 40 checks passed
@brianzelip brianzelip deleted the ANW-1763-accession-link-create-option branch February 4, 2026 15:55
@cdibella cdibella added this to the 4.2.0 milestone Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants