samvera / hyrax

Hyrax is a Ruby on Rails Engine built by the Samvera community. Hyrax provides a foundation for creating many different digital repository applications.
http://hyrax.samvera.org/
Apache License 2.0
183 stars 124 forks source link

When creating a work with an embargo - entry disappears #1701

Closed vantuyls closed 6 years ago

vantuyls commented 6 years ago

Descriptive summary

@julesies: I tried to create a work and set an embargo, however as soon as you hit save, the entire description and file disappears. This was with the Admin set 2.

Works fine with public, institution only, lease, private.

@vantuyls can you try to confirm this?

What I did:Chrome:-Add new work-add MD and Files-Choose Admin Set Test 2-Choose Embargo-Choose Public-Choose Embargo-Click agreement-Click saveDisappeared.

@mjgiarlo: Ah, I see what's going on. The visibility component javascript is disabling the form field that allows users to specify the visibility after embargo, because the Admin Set says that after embargo all works become public. As a result of disabling the form field, the :visibility_after_embargo input parameter is not sent to the controller, and validation of the submitted input fails here:

https://github.com/samvera/hyrax/blob/master/app/models/hyrax/permission_template.rb#L111-L112

Because :visibility_after_embargo is not present. Thus value is nil and it's being compared against 'open', which fails the validation.

@tdonohue did the lion's share of the work on this, and I imagine there might be a handful of related error conditions here. @tdonohue would you be willing to take a hack at this? (This is an issue with Hyrax, not Nurax. I can create a Hyrax issue if necessary, else let's run with this one.) To reproduce, create an AdminSet with release = "Varies between now and 2yrs after deposit" (though this may not be part of the specific error condition) and visibility = "Everyone".

@tdonohue Verified this also exists in Hyrax (and Hyku). My suspicion here is that this visibility_after_embargo field shouldn't be disabled but rather made read-only (e.g. readonly='readonly'). That way it isn't editable, but it is still included in the submitted form. So, it might be a pretty quick fix here (and we may want to verify other fields won't have this same issue).

I may be able to dig into this in the next few days, if no one else gets to it.

@mjgiarlo : personally, I'm of the opinion that this should be logged as a Hyrax ticket (too), so it is tracked there as a bug (for others unaware of this issue) and I can assign it to myself once I get to it. As-is, this ticket is on the sidelines of the larger Samvera community.

@mjgiarlo: @tdonohue I believe @vantuyls will be adding an issue for this in Hyrax soon. Thanks for taking this on! This and samvera/hyrax#1700 and samvera/hyrax#1687 are blocking the 2.0.0.rc1 release, and I'll be seeing to those other two PRs today.

Related work

https://github.com/curationexperts/nurax/issues/43

mjgiarlo commented 6 years ago

@tdonohue heads-up!