Code setting for Resources when using copy
Currently, admin users can copy a resource. In some cases, a GLRI resource is created out of a central resource.
For institutional users, the ResourceCodeService sets the code and the user only sees the code value after the record is saved.
For an admin user, the Resource form presents a code input that requires a valid code to be input.
We can set a code value behind the scenes if an GLRI institution is selected, and handle the case similarly to how the institutional case is handled. But if a Resource is copied for the purposes of creating a new central resource, we'll want to allow the value from the code input to take precedence.
So here's my suggestion:
-
when an admin user saves the Resource form, use the ResourceCodeService
to set a code value if a GLRI Institution is selected - ignoring any value entered into thecode
field of the form -
when an admin user saves the Resource form, use the value of the code
field to set the code value. this should validate as a required field if and only if the GLRI Resource is not included in the submitted form params (institution_id
)