Merged
Conversation
…item-metadata-edit
… remove operation issue
Member
|
@Atmire-Kristof : just a quick FYI...this PR now has a minor code conflict |
Conflicts: src/app/+item-page/edit-item-page/item-metadata/item-metadata.component.ts
tdonohue
approved these changes
Sep 29, 2020
Member
tdonohue
left a comment
There was a problem hiding this comment.
👍 Code looks good. I've tested it and verified that #821 is fixed. I also tried some complex patches, updated, adding and removing fields all in one request....and I ran into no problems. So, I'm satisfied that this is a major improvement over current behaviors (on main). If we notice minor issues later, we can resolve them in a follow-up PR. Thanks @Atmire-Kristof !
LucaGiamminonni
approved these changes
Oct 6, 2020
LucaGiamminonni
left a comment
There was a problem hiding this comment.
The code looks good. I have verified that #821 is fixed and I also tried other patches without encountering problems 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
References
This PR closes #821
Description
This PR refactors the ItemMetadataComponent and ObjectUpdatesService to create a patch from the updates in the store and pass it on to the data-service's
patchmethod instead ofupdate. This allows us to create a better, more specific patch instead of comparing the old and new objects.Instructions for Reviewers
Changes made:
MetadataPatchOperationService(implementing new interfacePatchOperationService), which is able to transform aFieldUpdatesobject from the store into an array of fast-json-patch operations. This happens in two major steps:-- All updates are transformed into a
MetadataPatchOperation. Each operation (add, remove and replace) has its own implementation of this wrapper object, each defining their own way to transform the information into anOperation.-- These operations are iterated over and modified depending on previous operations and finally added to the patch to return. (for example, when two values of the same field are removed, the second remove operation should take the first into account, because it might alter its position)
METADATA_PATCH_OPERATION_SERVICE_TOKENItemMetadataComponent.createPatch()to theObjectUpdatesService, which injects our new service using the token we stored and calls thefieldUpdatesToPatchOperations()method to create and return a patchItemMetadataComponentto use this newcreatePatch()method and pass the created patch on to the data-service's patch method. It now also displays error notifications if the patch fails.How to test:
Visit the edit-metadata page for any item and perform a bunch of operations on its metadata like adding, removing and editing values, as well as combining multiple operations at once.
Also try to reproduce the issue from #821, which should now be fixed.
Checklist
This checklist provides a reminder of what we are going to look for when reviewing your PR. You need not complete this checklist prior to creating your PR (draft PRs are always welcome). If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!
yarn run lintpackage.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.