hyrax icon indicating copy to clipboard operation
hyrax copied to clipboard

Adding work to multiple single membership collections from new work form does not forward as expected

Open elrayle opened this issue 6 years ago • 1 comments

Descriptive summary

This issue lays out expected forwarding behavior when adding a new work to multiple collections through the new work form fails.

NOTE: This likely uses the same behaviors when performing the same actions on the edit work form. This issue and issue #4011 are tightly related and the fix for one may fix both.

Rationale

Provide intuitive forwarding behavior that focuses on the actions a user will most likely want to take next. Provide error message that is easy to understand.

Expected behavior

When adding a work to multiple collections from the work new form...

FAILURE to add the work to the collections should:

  • [ ] stay on new form (Relationships tab)
  • [ ] no changes are saved
  • [ ] should maintain filled in metadata (Descriptions tab)
  • [ ] should maintain any files added for upload (Files tab)
  • [ ] show flash error (red): Collections Error: You have specified more than one collection of the same single-membership collection type (collection type: name of collection type, collections: list of effected collections). The work was not added to those collections.

Testing

  • [ ] Need to update specs added in PR #2687 to match the forwards described in this issue.

Actual behavior

When adding a work to multiple collections from the work new form...

FAILURE to add the work to the collections should:

  • forwards to Descriptions tab on new form
  • no changes are saved
  • all metadata fields are cleared (Descriptions tab)
  • files for upload are no longer listed (Files tab)
  • shows flash error: Collections Error: You have specified more than one of the same single-membership collection type (type: name of collection type, collections: list of effected collections)

Steps to reproduce the behavior

Prerequisites:

Need a collection type that is set to allow single membership. If testing on Nurax, this collection type may already exist. Look for Collection Type Single Membership. If it doesn't exist, then create a single membership collection type using...

  • Dashboard -> Settings -> Collection Types -> Create new collection type
  • Assign type name Single Membership and Save
  • On Settings tab, uncheck MULTIPLE MEMBERSHIP and Save changes

Need two collections of type Single Membership. You can create using...

  • Dashboard -> Collections -> New Collection -> select Single Membership type -> Create Collection
  • Assign suitable titles for the two collections and save. This issue will refer to them as SM1 and SM2.

Test:

Verify FAILURE behaves as expected.

  1. Dashboard -> Works -> Add new work
  2. select type (if needed) -> Create work
  3. fill in required metadata on Descriptions tab
  4. add file from Files tab
  5. check box for Depositor Agreement (if required)
  6. on Relationships tab -> Collections -> Add to collection -> type SM1 -> Add
  7. on Relationships tab -> Collections -> Add to collection -> type SM2 -> Add
  8. click Save button
  • [ ] Verify stays in new form on Relationships tab.
  • [ ] Verify flash error (red) with message "Collections Error: You have specified more than one collection of the same single-membership collection type (collection type: Single Membership, collections: SM1, SM2). The work was not added to those collections."
  • [ ] Verify that metadata filled in on Descriptions tab is still filed in as expected.
  • [ ] Verify that any files added on the Files tab are still ready for upload.
  • [ ] Verify work was not created.

Related work

  • Issue #4006 Batch add works to collection from Dashboard->Works when all fail doesn't forward as expected
  • Issue #4007 Batch add works to collection from Dashboard->Works when some fail doesn't forward as expected
  • Issue #4008 Batch add works to collection from collection admin show page when all fail doesn't forward as expected
  • Issue #4009 Batch add works to collection from collection admin show page when some fail doesn't forward as expected
  • Issue #4011 Adding work to multiple single membership collections from edit work form does not forward as expected
  • PR #2687 - fix single membership and add single/multi-membership spec tests

elrayle avatar Sep 17 '19 13:09 elrayle

I looked at this issue and was not successful. Basically, when there is an error creating a work, this is called: https://github.com/samvera/hyrax/blob/master/app/controllers/concerns/hyrax/works_controller_behavior.rb#L61

From there you go here: https://github.com/samvera/hyrax/blob/master/app/controllers/concerns/hyrax/works_controller_behavior.rb#L166

The first parameter being passed is curation_concern which will contain the work model (for example, GenericWork ) to use when building the form. When there is an error, the model contains no data. This happens because when an error is encountered while traversing the actor stack, the model is not built.

This is where the model would be completed had the work input by the user had no errors: https://github.com/samvera/hyrax/blob/master/app/actors/hyrax/actors/base_actor.rb#L20

So the form is built without any of the user's previously input data. I tried to build the model containing the values in param, but was not successful. I could get the metadata in the model, but the rest of the user input, I could not.

blancoj avatar Jun 24 '20 15:06 blancoj