Skip to content

Conversation

@masaball
Copy link
Contributor

@masaball masaball commented Oct 13, 2025

Related issue: #6054

By changing Units from a controlled vocab list to a model, this PR changes Collections to have a foreign key relationship to the unit. Is this how it should actually be implemented? There is definitely the has_many -> belongs_to database relationship, but remediating the data on application update is likely significant. All existing Unit values would need to have a corresponding instance created and then each collection would need to be changed to have the appropriate foreign key. This is probably doable with a rake task, but we need to make sure it is ironclad.

Edit: created potential rake task. It uses update_all which is more efficient since it is a single database injection, but does skip validations and callbacks. Since this is a rake task that should only need to be used once, maybe it is better to cycle through and individually update each record so all the callbacks and everything are properly set off...

TODO:

  • Do we need to implement a public Units tab like we have with collections? Or is the Unit meant as an administrative aspect that is only surfaced for organizing the collection index? If we need the tab, the views need to be added and controller/model code needs to be tweaked for functionality. If we are not adding the tab we can likely remove some of the files added in this PR.
  • Verify that permissions are accurate to the levels of control we want each staff role to have at the unit level.
  • Is it possible to initialize a default unit when the application is first created?

@masaball masaball marked this pull request as ready for review October 14, 2025 20:54
Copy link
Member

@cjcolvar cjcolvar left a comment

Choose a reason for hiding this comment

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

Wow! Great work! You've filled out a lot of the functionality beyond just scaffolding!

I did a first pass and overall looks really good. I'll have to digest it a bit more to consider if we want to make any more fundamental changes to the approach taken in this PR. But I'm sort of inclined to merge now and make any changes in follow on PRs.

temp_solr_parameters = {}
add_access_controls_to_solr_params_if_not_admin(temp_solr_parameters)

query = "{!join from=heldBy_ssim to=id}"
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 we may need to doubly join here to get from the unit down to the media object. I forget if it works to chain them:
{!join from=heldBy_ssim to=id}{!join from=isMemberOfCollection_ssim to=id}

Copy link
Contributor Author

@masaball masaball Oct 15, 2025

Choose a reason for hiding this comment

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

Do we need to drill down to the media object? In the current implementation, this is primarily (solely?) used by the Units index where my assumption was we would be only concerned that child collections were being returned.

masaball and others added 13 commits November 4, 2025 14:22
This commit creates (hopefully) all the controllers, models, and views
for the new Units structure. Initial code for the Units is copied from
the Admin::Collection model and given some tweaking. Tests are not
passing in the work for this commit.

TODO: Properly map hierarchy of permissions for Unit. Do managers,
editors, depositors have permissions to do anything to the Unit or are
they only relevant for being assigned to child collections? If they do
have permissions, how do they differ from the new unit administrator
role?
This commit reworks collections to belong_to a Unit. Is this the
approach that should be taken? This would require a large effort data
remediation to create Unit entries for all existing units in a
repository and making sure that all collections are assigned to the
proper new Unit, while retaining all the current permissions structures.
Is there a way to have both the modelled Units and the controlled vocab
based units exist alongside each other to ease the remediation burden?
This commit effectively copies and tweaks the collections ability checks
over to the Units. There will need to be a conversation on if these
changes are all that is necessary.
…ns for updating pulling unit name from the RDF
cjcolvar and others added 12 commits November 5, 2025 15:59
This commit makes use of the auto-complete-element
'data-autocomplete-value' feature which allows a separate input value to
be assigned to a given display value. The issue is that when a selection
is made, the input is changed to the input value. So a user inputting
'Defaul' then selecting 'Default Unit' will see the input field change
to the unit id. This could be confusing for users, but might be alright?
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.

3 participants